diff --git a/coremods/service_support.py b/coremods/service_support.py index ccdd6d0..0079dbc 100644 --- a/coremods/service_support.py +++ b/coremods/service_support.py @@ -104,7 +104,6 @@ def handle_kick(irc, source, command, args): sbot = irc.isServiceBot(kicked) if sbot: sbot.join(irc, channel) - irc.callHooks([irc.sid, 'PYLINK_SERVICE_JOIN', {'channel': channel, 'users': [kicked]}]) utils.add_hook(handle_kick, 'KICK') def handle_commands(irc, source, command, args): diff --git a/plugins/automode.py b/plugins/automode.py index 59fb927..aed4f8b 100644 --- a/plugins/automode.py +++ b/plugins/automode.py @@ -78,8 +78,7 @@ def main(irc=None): netname, channel = entry.split('#', 1) channel = '#' + channel log.debug('automode: auto-joining %s on %s', channel, netname) - if netname in world.networkobjects: - modebot.join(world.networkobjects[netname], channel) + modebot.join(netname, channel) def die(sourceirc): """Saves the Automode database and quit.""" diff --git a/utils.py b/utils.py index 8e106cc..47093f2 100644 --- a/utils.py +++ b/utils.py @@ -239,25 +239,38 @@ class ServiceBot(): """ Joins the given service bot to the given channel(s). """ - try: - u = self.uids[irc.name] - except KeyError: - log.debug('(%s/%s) Skipping join(), UID not initialized yet', irc.name, self.name) - return + + if type(irc) == str: + netname = irc + else: + netname = irc.name # Ensure type safety: pluralize strings if only one channel was given, then convert to set. if type(channels) == str: channels = [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. 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]) - 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: if isChannel(chan): if u in irc.channels[chan].users: