Implement first working commands

This commit is contained in:
XANTRONIX 2024-11-25 00:49:53 -05:00
parent aeb32934ac
commit 9763ea0cdf

View file

@ -291,10 +291,40 @@ class Session():
return self.end() 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): def handle(self):
line = self.readline() line = self.readline()
if line == '': if line == '':
return 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)