3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-01 09:19:23 +01:00

ServiceBot: make sure all the defaultdict(set) instances are SEPARATE

Bit of a Python oddity here - If you initialize a class like defaultdict in a class constructor, the same instance is used for all instances of the class?

This fixes all service bots joining the same channel, when they really shouldn't be.
This commit is contained in:
James Lu 2016-07-07 22:54:57 -07:00
parent 7a7b590295
commit ba53d63d37

View File

@ -160,7 +160,7 @@ class ServiceBot():
"""
def __init__(self, name, default_help=True, default_request=False, default_list=True,
nick=None, ident=None, manipulatable=False, extra_channels=collections.defaultdict(set),
nick=None, ident=None, manipulatable=False, extra_channels=None,
desc=None):
# Service name
self.name = name
@ -183,7 +183,7 @@ class ServiceBot():
# Track what channels other than those defined in the config
# that the bot should join by default.
self.extra_channels = extra_channels
self.extra_channels = extra_channels or collections.defaultdict(set)
# Service description, used in the default help command if one is given.
self.desc = desc