diff --git a/coreplugin.py b/coreplugin.py index ed7ab13..90614b6 100644 --- a/coreplugin.py +++ b/coreplugin.py @@ -202,7 +202,21 @@ def spawn_service(irc, source, command, args): if not irc.connected.is_set(): return + # Service name name = args['name'] + + # Get the ServiceBot object. + sbot = world.services[name] + + # Look up the nick or ident in the following order: + # 1) Network specific nick/ident settings for this service (servers::irc.name::servicename_nick) + # 2) Global settings for this service (servicename::nick) + # 3) The preferred nick/ident combination defined by the plugin (sbot.nick / sbot.ident) + # 4) The literal service name. + # settings, and then falling back to the literal service name. + nick = irc.serverdata.get("%s_nick" % name) or irc.conf.get(name, {}).get('nick') or sbot.nick or name + ident = irc.serverdata.get("%s_ident" % name) or irc.conf.get(name, {}).get('ident') or sbot.ident or name + # TODO: make this configurable? host = irc.serverdata["hostname"] @@ -215,10 +229,8 @@ def spawn_service(irc, source, command, args): modes.append((mode, None)) # Track the service's UIDs on each network. - sbot = world.services[name] - userobj = irc.proto.spawnClient(sbot.nick, sbot.ident, - host, modes=modes, opertype="PyLink Service", - manipulatable=sbot.manipulatable) + userobj = irc.proto.spawnClient(nick, ident, host, modes=modes, opertype="PyLink Service", + manipulatable=sbot.manipulatable) sbot.uids[irc.name] = u = userobj.uid diff --git a/example-conf.yml b/example-conf.yml index 9cee2ab..e979cea 100644 --- a/example-conf.yml +++ b/example-conf.yml @@ -38,7 +38,7 @@ login: servers: # Please note: these are only EXAMPLE link blocks. You should edit them and # remove ones that you don't need in your config. - + # Short name for the network. This is used for relay's nick suffixes, the # network plugin's (dis)connect commands, and elsewhere internally. # You should change this to some abbreviation representing your network @@ -184,6 +184,13 @@ servers: # same IRCd version. #mixed_link: true + # You can also define network-specific nicks and idents for various service + # bots, using the configuration options "servicename_nick" and "servicename_ident". + #pylink_nick: MagicServ + #pylink_ident: magicserv + #games_nick: MagicGames + #games_ident: magicgames + nefarious: ip: 1.2.3.4 port: 45454 @@ -372,3 +379,7 @@ relay: # Valid options include "all" (show this to everyone), "opers" (show only to # opers), and "none" (disabled). Defaults to none if not specified. whois_show_server: opers + +games: + # Sets the nick of the Games service, if you're using it. + nick: Games