Implement first working commands
This commit is contained in:
parent
aeb32934ac
commit
9763ea0cdf
1 changed files with 31 additions and 1 deletions
|
@ -291,10 +291,40 @@ class Session():
|
|||
|
||||
return self.end()
|
||||
|
||||
def _cmd_newgroups(self, wildmat, datestr, timestr, *args):
|
||||
gmt = False
|
||||
|
||||
if len(args) == 1:
|
||||
if args[0] == "GMT":
|
||||
gmt = True
|
||||
else:
|
||||
return self.send_response(ResponseCode.NNTP_SYNTAX_ERROR, "Only optional 'GMT' allowed")
|
||||
elif len(args) > 1:
|
||||
return self.send_response(ResponseCode.NNTP_SYNTAX_ERROR, "Too many arguments")
|
||||
|
||||
pass
|
||||
|
||||
COMMANDS = {
|
||||
'CAPABILITIES': _cmd_capabilities,
|
||||
'GROUP': _cmd_group,
|
||||
'LISTGROUP': _cmd_listgroup,
|
||||
'LIST': _cmd_list,
|
||||
'NEWNEWS': _cmd_newnews,
|
||||
'NEWSGROUPS': _cmd_newgroups,
|
||||
}
|
||||
|
||||
def handle(self):
|
||||
line = self.readline()
|
||||
|
||||
if line == '':
|
||||
return
|
||||
|
||||
command, args = self.RE_SPLIT.split(line.rstrip())
|
||||
tokens = self.RE_SPLIT.split(line.rstrip())
|
||||
command, *args = tokens
|
||||
|
||||
fn = self.COMMANDS.get(command.upper())
|
||||
|
||||
if fn is None:
|
||||
return self.respond(ResponseCode.NNTP_COMMAND_UNKNOWN)
|
||||
|
||||
return fn(self, *args)
|
||||
|
|
Loading…
Add table
Reference in a new issue