3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-23 19:19:31 +01:00

protocols: move handlers for AWAY, VERSION, WHOIS, and QUIT to ircs2s_common

This commit is contained in:
James Lu 2016-07-11 16:08:46 -07:00
parent d91589c4da
commit c04f9d1879
3 changed files with 40 additions and 57 deletions

View File

@ -77,3 +77,43 @@ class IRCS2SProtocol(Protocol):
return {'target': split_server, 'users': affected_users, 'name': sname,
'uplink': uplink}
def handle_away(self, numeric, command, args):
"""Handles incoming AWAY messages."""
# TS6:
# <- :6ELAAAAAB AWAY :Auto-away
# P10:
# <- ABAAA A :blah
# <- ABAAA A
try:
self.irc.users[numeric].away = text = args[0]
except IndexError: # User is unsetting away status
self.irc.users[numeric].away = text = ''
return {'text': text}
def handle_version(self, numeric, command, args):
"""Handles requests for the PyLink server version."""
return {} # See coremods/handlers.py for how this hook is used
def handle_whois(self, numeric, command, args):
"""Handles incoming WHOIS commands.."""
# TS6:
# <- :42XAAAAAB WHOIS 5PYAAAAAA :pylink-devel
# P10:
# <- ABAAA W Ay :PyLink-devel
# First argument is the server that should reply to the WHOIS request
# or the server hosting the UID given. We can safely assume that any
# WHOIS commands received are for us, since we don't host any real servers
# to route it to.
return {'target': self._getUid(args[-1])}
def handle_quit(self, numeric, command, args):
"""Handles incoming QUIT commands."""
# TS6:
# <- :1SRAAGB4T QUIT :Quit: quit message goes here
# P10:
# <- ABAAB Q :Killed (GL_ (bangbang))
self.removeClient(numeric)
return {'text': args[0]}

View File

@ -1175,12 +1175,6 @@ class P10Protocol(IRCS2SProtocol):
self.handle_part(kicked, 'KICK', [channel, args[2]])
return {'channel': channel, 'target': kicked, 'text': args[2]}
def handle_quit(self, numeric, command, args):
"""Handles incoming QUITs."""
# <- ABAAB Q :Killed (GL_ (bangbang))
self.removeClient(numeric)
return {'text': args[0]}
def handle_topic(self, source, command, args):
"""Handles TOPIC changes."""
# <- ABAAA T #test GL!~gl@nefarious.midnight.vpn 1460852591 1460855795 :blah
@ -1206,22 +1200,6 @@ class P10Protocol(IRCS2SProtocol):
return {'target': target, 'channel': channel}
def handle_away(self, numeric, command, args):
"""Handles incoming AWAY messages."""
# <- ABAAA A :blah
# <- ABAAA A
try:
self.irc.users[numeric].away = text = args[0]
except IndexError: # User is unsetting away status
self.irc.users[numeric].away = text = ''
return {'text': text}
def handle_whois(self, numeric, command, args):
"""Handles incoming WHOIS requests."""
# <- ABAAA W Ay :PyLink-devel
return {'target': self._getUid(args[-1])}
def handle_clearmode(self, numeric, command, args):
"""Handles CLEARMODE, which is used to clear a channel's modes."""
# <- ABAAA CM #test ovpsmikbl
@ -1303,9 +1281,4 @@ class P10Protocol(IRCS2SProtocol):
self.checkCloakChange(target)
# We don't need to send any hooks here, checkCloakChange does that for us.
def handle_version(self, numeric, command, args):
# <- ABAAA V :Ay
"""Handles requests for the PyLink server version."""
return {} # See coreplugin.py for how this hook is used
Class = P10Protocol

View File

@ -388,12 +388,6 @@ class TS6BaseProtocol(IRCS2SProtocol):
return {'newnick': newnick, 'oldnick': oldnick, 'ts': ts}
def handle_quit(self, numeric, command, args):
"""Handles incoming QUIT commands."""
# <- :1SRAAGB4T QUIT :Quit: quit message goes here
self.removeClient(numeric)
return {'text': args[0]}
def handle_save(self, numeric, command, args):
"""Handles incoming SAVE messages, used to handle nick collisions."""
# In this below example, the client Derp_ already exists,
@ -446,27 +440,3 @@ class TS6BaseProtocol(IRCS2SProtocol):
if not (self.irc.channels[channel].users or ((self.irc.cmodes.get('permanent'), None) in self.irc.channels[channel].modes)):
del self.irc.channels[channel]
return {'channels': channels, 'text': reason}
def handle_away(self, numeric, command, args):
"""Handles incoming AWAY messages."""
# <- :6ELAAAAAB AWAY :Auto-away
try:
self.irc.users[numeric].away = text = args[0]
except IndexError: # User is unsetting away status
self.irc.users[numeric].away = text = ''
return {'text': text}
def handle_version(self, numeric, command, args):
"""Handles requests for the PyLink server version."""
return {} # See coremods/handlers.py for how this hook is used
def handle_whois(self, numeric, command, args):
"""Handles incoming WHOIS commands.."""
# <- :42XAAAAAB WHOIS 5PYAAAAAA :pylink-devel
# First argument is the server that should reply to the WHOIS request
# or the server hosting the UID given. We can safely assume that any
# WHOIS commands received are for us, since we don't host any real servers
# to route it to.
return {'target': self._getUid(args[-1])}