3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-12-25 04:02:45 +01:00

core: allow defining service bots with custom nicks/idents

This commit is contained in:
James Lu 2016-05-14 12:52:32 -07:00
parent bb265189a4
commit 118d76fd5a
2 changed files with 18 additions and 5 deletions

View File

@ -210,8 +210,11 @@ def spawn_service(irc, source, command, args):
return
name = args['name']
ident = irc.botdata.get('ident') or 'pylink'
# TODO: make this configurable?
host = irc.serverdata["hostname"]
# Prefer spawning service clients with umode +io, plus hideoper and
# hidechans if supported.
modes = []
for mode in ('oper', 'hideoper', 'hidechans', 'invisible'):
mode = irc.umodes.get(mode)
@ -219,9 +222,10 @@ def spawn_service(irc, source, command, args):
modes.append((mode, None))
# Track the service's UIDs on each network.
service = world.services[name]
service.uids[irc.name] = u = irc.proto.spawnClient(name, name,
irc.serverdata['hostname'], modes=modes, opertype="PyLink Service").uid
sbot = world.services[name]
sbot.uids[irc.name] = u = irc.proto.spawnClient(sbot.nick, sbot.ident,
host, modes=modes, opertype="PyLink Service",
manipulatable=sbot.manipulatable).uid
# TODO: channels should be tracked in a central database, not hardcoded
# in conf.

View File

@ -151,9 +151,18 @@ def getDatabaseName(dbname):
return dbname
class ServiceBot():
def __init__(self, name, default_help=True, default_request=True, default_list=True):
def __init__(self, name, default_help=True, default_request=True, default_list=True,
nick=None, ident=None, manipulatable=False):
# Service name
self.name = name
# Nick/ident to take. Defaults to the same as the service name if not given.
self.nick = nick or name
self.ident = ident or name
# Tracks whether the bot should be manipulatable by the 'bots' plugin and other commands.
self.manipulatable = manipulatable
# We make the command definitions a dict of lists of functions. Multiple
# plugins are actually allowed to bind to one function name; this just causes
# them to be called in the order that they are bound.