mirror of
https://github.com/jlu5/PyLink.git
synced 2024-12-24 19:52:53 +01:00
prs+IrcUser: add incoming (handle_away) and outgoing (awayClient) AWAY handling
This commit is contained in:
parent
7bccb37ddf
commit
1a57dfcdc3
@ -21,6 +21,7 @@ class IrcUser():
|
||||
|
||||
self.identified = False
|
||||
self.channels = set()
|
||||
self.away = ''
|
||||
|
||||
def __repr__(self):
|
||||
return repr(self.__dict__)
|
||||
|
@ -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):
|
||||
"""<irc object> <numeric> <text>
|
||||
|
||||
Sends an AWAY message with text <text> from PyLink client <numeric>.
|
||||
<text> 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': ''}
|
||||
|
@ -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):
|
||||
"""<irc object> <numeric> <text>
|
||||
|
||||
Sends an AWAY message with text <text> from PyLink client <numeric>.
|
||||
<text> 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}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user