3
0
mirror of https://github.com/jlu5/PyLink.git synced 2025-02-03 08:04:07 +01:00

unreal, p10: condense topic_burst and topic together

Closes #480.
This commit is contained in:
James Lu 2017-07-07 13:35:30 -07:00
parent d2d76baad8
commit c2f12460da
2 changed files with 9 additions and 32 deletions

View File

@ -667,38 +667,22 @@ class P10Protocol(IRCS2SProtocol):
self._send_with_prefix(source, 'SQ %s 0 :%s' % (targetname, text)) self._send_with_prefix(source, 'SQ %s 0 :%s' % (targetname, text))
self.handle_squit(source, 'SQUIT', [target, text]) self.handle_squit(source, 'SQUIT', [target, text])
def topic(self, numeric, target, text): def topic(self, source, target, text):
"""Sends a TOPIC change from a PyLink client.""" """Sends a TOPIC change from a PyLink client or server."""
# <- ABAAA T #test GL!~gl@nefarious.midnight.vpn 1460852591 1460855795 :blah # <- ABAAA T #test GL!~gl@nefarious.midnight.vpn 1460852591 1460855795 :blah
# First timestamp is channel creation time, second is current time, # First timestamp is channel creation time, second is current time,
if (not self.is_internal_client(source)) and (not self.is_internal_server(source)):
raise LookupError('No such PyLink client/server exists.')
if not self.is_internal_client(numeric): sendername = self.get_hostmask(source)
raise LookupError('No such PyLink client exists.')
sendername = self.get_hostmask(numeric)
creationts = self.channels[target].ts creationts = self.channels[target].ts
self._send_with_prefix(numeric, 'T %s %s %s %s :%s' % (target, sendername, creationts, self._send_with_prefix(source, 'T %s %s %s %s :%s' % (target, sendername, creationts,
int(time.time()), text))
self.channels[target].topic = text
self.channels[target].topicset = True
def topic_burst(self, numeric, target, text):
"""Sends a TOPIC change from a PyLink server."""
# <- AB T #test GL!~gl@nefarious.midnight.vpn 1460852591 1460855795 :blah
if not self.is_internal_server(numeric):
raise LookupError('No such PyLink server exists.')
sendername = self.servers[numeric].name
creationts = self.channels[target].ts
self._send_with_prefix(numeric, 'T %s %s %s %s :%s' % (target, sendername, creationts,
int(time.time()), text)) int(time.time()), text))
self.channels[target].topic = text self.channels[target].topic = text
self.channels[target].topicset = True self.channels[target].topicset = True
topic_burst = topic
def update_client(self, target, field, text): def update_client(self, target, field, text):
"""Updates the ident or host of any connected client.""" """Updates the ident or host of any connected client."""

View File

@ -38,8 +38,9 @@ class UnrealProtocol(TS6BaseProtocol):
self.needed_caps = ["VL", "SID", "CHANMODES", "NOQUIT", "SJ3", "NICKIP", "UMODE2", "SJOIN"] self.needed_caps = ["VL", "SID", "CHANMODES", "NOQUIT", "SJ3", "NICKIP", "UMODE2", "SJOIN"]
# Some command aliases # Command aliases to handlers defined in parent modules
self.handle_svskill = self.handle_kill self.handle_svskill = self.handle_kill
self.topic_burst = self.topic
### OUTGOING COMMAND FUNCTIONS ### OUTGOING COMMAND FUNCTIONS
def spawn_client(self, nick, ident='null', host='null', realhost=None, modes=set(), def spawn_client(self, nick, ident='null', host='null', realhost=None, modes=set(),
@ -253,14 +254,6 @@ class UnrealProtocol(TS6BaseProtocol):
joinedmodes = self.join_modes(modes) joinedmodes = self.join_modes(modes)
self._send_with_prefix(target, 'UMODE2 %s' % joinedmodes) self._send_with_prefix(target, 'UMODE2 %s' % joinedmodes)
def topic_burst(self, numeric, target, text):
"""Sends a TOPIC change from a PyLink server."""
if not self.is_internal_server(numeric):
raise LookupError('No such PyLink server exists.')
self._send_with_prefix(numeric, 'TOPIC %s :%s' % (target, text))
self.channels[target].topic = text
self.channels[target].topicset = True
def update_client(self, target, field, text): def update_client(self, target, field, text):
"""Updates the ident, host, or realname of any connected client.""" """Updates the ident, host, or realname of any connected client."""
field = field.upper() field = field.upper()