From 0cce6ca4885c986e09b4afba78a416cf9016538b Mon Sep 17 00:00:00 2001 From: James Lu Date: Fri, 23 Sep 2016 23:07:42 -0700 Subject: [PATCH] service_support: allow specifying modes to join with for each service (#326) This updates the example config to, by default, join Automode bots as op in channels. --- coremods/service_support.py | 11 ++++++++++- example-conf.yml | 5 +++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/coremods/service_support.py b/coremods/service_support.py index ec26e58..5ef98f3 100644 --- a/coremods/service_support.py +++ b/coremods/service_support.py @@ -26,6 +26,10 @@ def spawn_service(irc, source, command, args): nick = irc.serverdata.get("%s_nick" % name) or conf.conf.get(name, {}).get('nick') or sbot.nick or name ident = irc.serverdata.get("%s_ident" % name) or conf.conf.get(name, {}).get('ident') or sbot.ident or name + # Specify modes to join the services bot with. + joinmodes = irc.serverdata.get("%s_joinmodes" % name) or conf.conf.get(name, {}).get('joinmodes') or '' + joinmodes = ''.join([m for m in joinmodes if m in irc.prefixmodes]) + if name != 'pylink' and irc.protoname == 'clientbot': # Prefix service bots spawned on Clientbot to prevent possible nick collisions. nick = 'PyLinkService@' + nick @@ -65,7 +69,12 @@ def spawn_service(irc, source, command, args): for chan in channels: if utils.isChannel(chan): - irc.proto.join(u, chan) + log.debug('(%s) Joining services %s to channel %s with modes %r', irc.name, name, chan, joinmodes) + if joinmodes: # Modes on join were specified; use SJOIN to burst our service + irc.proto.sjoin(irc.sid, chan, [(joinmodes, u)]) + else: + irc.proto.join(u, chan) + irc.callHooks([irc.sid, 'PYLINK_SERVICE_JOIN', {'channel': chan, 'users': [u]}]) else: log.warning('(%s) Ignoring invalid autojoin channel %r.', irc.name, chan) diff --git a/example-conf.yml b/example-conf.yml index aa8e716..9bf9270 100644 --- a/example-conf.yml +++ b/example-conf.yml @@ -488,3 +488,8 @@ games: automode: # Sets the nick of the Automode service, if you're using it. This defaults to "automode" if not defined. nick: Automode + + # For each service, you can also specify what prefix modes you want the service bot to join channels with. + # Setting this to op (+o) for Automode makes it appear more like a standard IRC service, and lessens + # the risk of mode overrides being dropped. + joinmodes: 'o'