mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-01 01:09:22 +01:00
ServiceBot: handle autojoin additions even if bots haven't spawned yet
This commit is contained in:
parent
1c60ad7251
commit
438838f81d
@ -104,7 +104,6 @@ def handle_kick(irc, source, command, args):
|
|||||||
sbot = irc.isServiceBot(kicked)
|
sbot = irc.isServiceBot(kicked)
|
||||||
if sbot:
|
if sbot:
|
||||||
sbot.join(irc, channel)
|
sbot.join(irc, channel)
|
||||||
irc.callHooks([irc.sid, 'PYLINK_SERVICE_JOIN', {'channel': channel, 'users': [kicked]}])
|
|
||||||
utils.add_hook(handle_kick, 'KICK')
|
utils.add_hook(handle_kick, 'KICK')
|
||||||
|
|
||||||
def handle_commands(irc, source, command, args):
|
def handle_commands(irc, source, command, args):
|
||||||
|
@ -78,8 +78,7 @@ def main(irc=None):
|
|||||||
netname, channel = entry.split('#', 1)
|
netname, channel = entry.split('#', 1)
|
||||||
channel = '#' + channel
|
channel = '#' + channel
|
||||||
log.debug('automode: auto-joining %s on %s', channel, netname)
|
log.debug('automode: auto-joining %s on %s', channel, netname)
|
||||||
if netname in world.networkobjects:
|
modebot.join(netname, channel)
|
||||||
modebot.join(world.networkobjects[netname], channel)
|
|
||||||
|
|
||||||
def die(sourceirc):
|
def die(sourceirc):
|
||||||
"""Saves the Automode database and quit."""
|
"""Saves the Automode database and quit."""
|
||||||
|
31
utils.py
31
utils.py
@ -239,25 +239,38 @@ class ServiceBot():
|
|||||||
"""
|
"""
|
||||||
Joins the given service bot to the given channel(s).
|
Joins the given service bot to the given channel(s).
|
||||||
"""
|
"""
|
||||||
try:
|
|
||||||
u = self.uids[irc.name]
|
if type(irc) == str:
|
||||||
except KeyError:
|
netname = irc
|
||||||
log.debug('(%s/%s) Skipping join(), UID not initialized yet', irc.name, self.name)
|
else:
|
||||||
return
|
netname = irc.name
|
||||||
|
|
||||||
# Ensure type safety: pluralize strings if only one channel was given, then convert to set.
|
# Ensure type safety: pluralize strings if only one channel was given, then convert to set.
|
||||||
if type(channels) == str:
|
if type(channels) == str:
|
||||||
channels = [channels]
|
channels = [channels]
|
||||||
channels = set(channels)
|
channels = set(channels)
|
||||||
|
|
||||||
|
if autojoin:
|
||||||
|
log.debug('(%s/%s) Adding channels %s to autojoin', netname, self.name, channels)
|
||||||
|
self.extra_channels[netname] |= channels
|
||||||
|
|
||||||
|
# If the network was given as a string, look up the Irc object here.
|
||||||
|
try:
|
||||||
|
irc = world.networkobjects[netname]
|
||||||
|
except KeyError:
|
||||||
|
log.debug('(%s/%s) Skipping join(), IRC object not initialized yet', irc, self.name)
|
||||||
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
|
u = self.uids[irc.name]
|
||||||
|
except KeyError:
|
||||||
|
log.debug('(%s/%s) Skipping join(), UID not initialized yet', irc.name, self.name)
|
||||||
|
return
|
||||||
|
|
||||||
# Specify modes to join the services bot with.
|
# Specify modes to join the services bot with.
|
||||||
joinmodes = irc.serverdata.get("%s_joinmodes" % self.name) or conf.conf.get(self.name, {}).get('joinmodes') or ''
|
joinmodes = irc.serverdata.get("%s_joinmodes" % self.name) or conf.conf.get(self.name, {}).get('joinmodes') or ''
|
||||||
joinmodes = ''.join([m for m in joinmodes if m in irc.prefixmodes])
|
joinmodes = ''.join([m for m in joinmodes if m in irc.prefixmodes])
|
||||||
|
|
||||||
if autojoin:
|
|
||||||
log.debug('(%s/%s) Adding channels %s to autojoin', irc.name, self.name, channels)
|
|
||||||
self.extra_channels[irc.name] |= channels
|
|
||||||
|
|
||||||
for chan in channels:
|
for chan in channels:
|
||||||
if isChannel(chan):
|
if isChannel(chan):
|
||||||
if u in irc.channels[chan].users:
|
if u in irc.channels[chan].users:
|
||||||
|
Loading…
Reference in New Issue
Block a user