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

clientbot: track channel modes and TS on join

Closes #345.
This commit is contained in:
James Lu 2017-04-09 14:49:19 -07:00
parent 6d96dd21ac
commit bf1d7812e2
2 changed files with 19 additions and 1 deletions

View File

@ -649,7 +649,7 @@ def relay_joins(irc, channel, users, ts, burst=True):
# the different sides of the relay are merged properly. # the different sides of the relay are merged properly.
if not irc.proto.hasCap('has-ts'): if not irc.proto.hasCap('has-ts'):
# Special hack for clientbot: just use the remote's modes so mode changes # Special hack for clientbot: just use the remote's modes so mode changes
# take precendence. protocols/clientbot does not track channel TS. # take precendence. (TS is always outside the clientbot's control)
ts = remoteirc.channels[remotechan].ts ts = remoteirc.channels[remotechan].ts
else: else:
ts = irc.channels[channel].ts ts = irc.channels[channel].ts

View File

@ -151,6 +151,7 @@ class ClientbotWrapperProtocol(Protocol):
if self.irc.pseudoclient and client == self.irc.pseudoclient.uid: if self.irc.pseudoclient and client == self.irc.pseudoclient.uid:
self.irc.send('JOIN %s' % channel) self.irc.send('JOIN %s' % channel)
# Send /names and /who requests right after # Send /names and /who requests right after
self.irc.send('MODE %s' % channel)
self.irc.send('NAMES %s' % channel) self.irc.send('NAMES %s' % channel)
self.irc.send('WHO %s' % channel) self.irc.send('WHO %s' % channel)
else: else:
@ -846,6 +847,23 @@ class ClientbotWrapperProtocol(Protocol):
if (self.irc.pseudoclient and source != self.irc.pseudoclient.uid) or not self.irc.pseudoclient: if (self.irc.pseudoclient and source != self.irc.pseudoclient.uid) or not self.irc.pseudoclient:
return {'target': target, 'modes': changedmodes, 'channeldata': oldobj} return {'target': target, 'modes': changedmodes, 'channeldata': oldobj}
def handle_324(self, source, command, args):
"""Handles MODE announcements via RPL_CHANNELMODEIS (i.e. the response to /mode #channel)"""
# -> MODE #test
# <- :midnight.vpn 324 GL #test +nt
# <- :midnight.vpn 329 GL #test 1491773459
channel = self.irc.toLower(args[1])
modes = args[2:]
log.debug('(%s) Got RPL_CHANNELMODEIS (324) modes %s for %s', self.irc.name, modes, channel)
changedmodes = self.irc.parseModes(channel, modes)
self.irc.applyModes(channel, changedmodes)
def handle_329(self, source, command, args):
"""Handles TS announcements via RPL_CREATIONTIME."""
channel = self.irc.toLower(args[1])
ts = int(args[2])
self.irc.channels[channel].ts = ts
def handle_nick(self, source, command, args): def handle_nick(self, source, command, args):
"""Handles NICK changes.""" """Handles NICK changes."""
# <- :GL|!~GL@127.0.0.1 NICK :GL_ # <- :GL|!~GL@127.0.0.1 NICK :GL_