mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-27 21:19:31 +01:00
clientbot: handle prefix modes in NAMES
This commit is contained in:
parent
deddbde2b0
commit
2d886367b5
@ -279,24 +279,36 @@ class ClientbotWrapperProtocol(Protocol):
|
|||||||
self.irc.applyModes(channel, [('+s', None)])
|
self.irc.applyModes(channel, [('+s', None)])
|
||||||
|
|
||||||
names = set()
|
names = set()
|
||||||
|
modes = set()
|
||||||
|
prefix_to_mode = {v:k for k, v in self.irc.prefixmodes.items()}
|
||||||
|
prefixes = ''.join(self.irc.prefixmodes.values())
|
||||||
|
|
||||||
for name in args[-1].split():
|
for name in args[-1].split():
|
||||||
# TODO: process prefix modes instead of just stripping them
|
nick = name.lstrip(prefixes)
|
||||||
name = name.lstrip(string.punctuation)
|
|
||||||
|
|
||||||
# Get the PUID for the given nick. If one doesn't exist, spawn
|
# Get the PUID for the given nick. If one doesn't exist, spawn
|
||||||
# a new virtual user. TODO: wait for WHO responses for each nick before
|
# a new virtual user. TODO: wait for WHO responses for each nick before
|
||||||
# spawning in order to get a real ident/host.
|
# spawning in order to get a real ident/host.
|
||||||
idsource = self.irc.nickToUid(name) or self.spawnClient(name, server=self.irc.uplink).uid
|
idsource = self.irc.nickToUid(nick) or self.spawnClient(nick, server=self.irc.uplink).uid
|
||||||
|
|
||||||
# Queue these virtual users to be joined if they're not already in the channel.
|
# Queue these virtual users to be joined if they're not already in the channel.
|
||||||
if idsource not in self.irc.channels[channel].users:
|
if idsource not in self.irc.channels[channel].users:
|
||||||
names.add(idsource)
|
names.add(idsource)
|
||||||
self.irc.users[idsource].channels.add(channel)
|
self.irc.users[idsource].channels.add(channel)
|
||||||
|
|
||||||
|
# Process prefix modes
|
||||||
|
for char in name:
|
||||||
|
if char in self.irc.prefixmodes.values():
|
||||||
|
modes.add(('+' + prefix_to_mode[char], idsource))
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
|
||||||
# Statekeeping: make sure the channel's user list is updated!
|
# Statekeeping: make sure the channel's user list is updated!
|
||||||
self.irc.channels[channel].users |= names
|
self.irc.channels[channel].users |= names
|
||||||
|
self.irc.applyModes(channel, modes)
|
||||||
|
|
||||||
log.debug('(%s) handle_353: adding users %s to %s', self.irc.name, names, channel)
|
log.debug('(%s) handle_353: adding users %s to %s', self.irc.name, names, channel)
|
||||||
|
log.debug('(%s) handle_353: adding modes %s to %s', self.irc.name, modes, channel)
|
||||||
|
|
||||||
return {'channel': channel, 'users': names, 'modes': self.irc.channels[channel].modes,
|
return {'channel': channel, 'users': names, 'modes': self.irc.channels[channel].modes,
|
||||||
'parse_as': "JOIN"}
|
'parse_as': "JOIN"}
|
||||||
|
Loading…
Reference in New Issue
Block a user