diff --git a/classes.py b/classes.py index 729250f..0b7b8dc 100644 --- a/classes.py +++ b/classes.py @@ -21,6 +21,7 @@ class IrcUser(): self.identified = False self.channels = set() + self.away = '' def __repr__(self): return repr(self.__dict__) diff --git a/protocols/inspircd.py b/protocols/inspircd.py index 995dc6c..253516c 100644 --- a/protocols/inspircd.py +++ b/protocols/inspircd.py @@ -297,6 +297,16 @@ def numericServer(irc, source, numeric, text): "locally by InspIRCd servers, so there is no " "need for PyLink to send numerics directly yet.") +def awayClient(irc, source, text): + """ + + Sends an AWAY message with text from PyLink client . + can be an empty string to unset AWAY status.""" + if text: + _send(irc, source, 'AWAY %s :%s' % (int(time.time()), text)) + else: + _send(irc, source, 'AWAY') + def connect(irc): ts = irc.start_ts @@ -664,3 +674,13 @@ def handle_fname(irc, numeric, command, args): def handle_endburst(irc, numeric, command, args): return {} + +def handle_away(irc, numeric, command, args): + # <- :1MLAAAAIG AWAY 1439371390 :Auto-away + try: + ts = args[0] + irc.users[numeric].away = text = args[1] + return {'text': text, 'ts': ts} + except IndexError: # User is unsetting away status + irc.users[numeric].away = '' + return {'text': ''} diff --git a/protocols/ts6.py b/protocols/ts6.py index 6a4f4e5..7f555e5 100644 --- a/protocols/ts6.py +++ b/protocols/ts6.py @@ -231,6 +231,16 @@ def pingServer(irc, source=None, target=None): def numericServer(irc, source, numeric, target, text): _send(irc, source, '%s %s %s' % (numeric, target, text)) +def awayClient(irc, source, text): + """ + + Sends an AWAY message with text from PyLink client . + can be an empty string to unset AWAY status.""" + if text: + _send(irc, source, 'AWAY :%s' % text) + else: + _send(irc, source, 'AWAY') + def connect(irc): ts = irc.start_ts @@ -649,3 +659,13 @@ def handle_472(irc, numeric, command, args): ' desyncs, try adding the line "loadmodule "extensions/%s.so";" to ' 'your IRCd configuration.', irc.name, setter, badmode, charlist[badmode]) + +def handle_away(irc, numeric, command, args): + # <- :6ELAAAAAB AWAY :Auto-away + + try: + irc.users[numeric].away = text = args[0] + except IndexError: # User is unsetting away status + irc.users[numeric].away = text = '' + return {'text': text} +