mirror of
https://github.com/jlu5/PyLink.git
synced 2024-12-24 11:42:51 +01:00
core: allow defining service bots with custom nicks/idents
This commit is contained in:
parent
bb265189a4
commit
118d76fd5a
@ -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.
|
||||
|
11
utils.py
11
utils.py
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user