From ba53d63d376fde26aeb363dc5c94b1ab3cd0fe3b Mon Sep 17 00:00:00 2001 From: James Lu Date: Thu, 7 Jul 2016 22:54:57 -0700 Subject: [PATCH] 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. --- utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils.py b/utils.py index 10f98fa..a79f8e8 100644 --- a/utils.py +++ b/utils.py @@ -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