mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-01 01:09:22 +01:00
ServiceBot: allow configuring extra channels that bots will join
This commit is contained in:
parent
9d7fb4ed70
commit
ceed9346c0
@ -50,7 +50,9 @@ def spawn_service(irc, source, command, args):
|
|||||||
|
|
||||||
# TODO: channels should be tracked in a central database, not hardcoded
|
# TODO: channels should be tracked in a central database, not hardcoded
|
||||||
# in conf.
|
# in conf.
|
||||||
for chan in irc.serverdata['channels']:
|
channels = set(irc.serverdata.get('channels', [])) | sbot.extra_channels
|
||||||
|
|
||||||
|
for chan in channels:
|
||||||
irc.proto.join(u, chan)
|
irc.proto.join(u, chan)
|
||||||
|
|
||||||
utils.add_hook(spawn_service, 'PYLINK_NEW_SERVICE')
|
utils.add_hook(spawn_service, 'PYLINK_NEW_SERVICE')
|
||||||
|
6
utils.py
6
utils.py
@ -148,7 +148,7 @@ def getDatabaseName(dbname):
|
|||||||
|
|
||||||
class ServiceBot():
|
class ServiceBot():
|
||||||
def __init__(self, name, default_help=True, default_request=False, default_list=True,
|
def __init__(self, name, default_help=True, default_request=False, default_list=True,
|
||||||
nick=None, ident=None, manipulatable=False):
|
nick=None, ident=None, manipulatable=False, extra_channels=set()):
|
||||||
# Service name
|
# Service name
|
||||||
self.name = name
|
self.name = name
|
||||||
|
|
||||||
@ -168,6 +168,10 @@ class ServiceBot():
|
|||||||
# spawned.
|
# spawned.
|
||||||
self.uids = {}
|
self.uids = {}
|
||||||
|
|
||||||
|
# Track what channels other than those defined in the config
|
||||||
|
# that the bot should join by default.
|
||||||
|
self.extra_channels = extra_channels
|
||||||
|
|
||||||
if default_help:
|
if default_help:
|
||||||
self.add_cmd(self.help)
|
self.add_cmd(self.help)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user