diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2020-05-22 18:00:54 +0200 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2020-05-22 21:27:30 +0200 |
commit | 00382056e72401db918ee253195c41d7dae6476c (patch) | |
tree | dd27fbd92ad92ba296ad96737f65895e1f0f107a /wee_slack.py | |
parent | 3cbc46b07e1ef503672cbb98f21efb559ec64681 (diff) | |
download | wee-slack-00382056e72401db918ee253195c41d7dae6476c.tar.gz |
Move channel type into init arguments
Diffstat (limited to 'wee_slack.py')
-rw-r--r-- | wee_slack.py | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/wee_slack.py b/wee_slack.py index 2c97fab..54f1f42 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -1656,13 +1656,14 @@ class SlackChannel(SlackChannelCommon): Represents an individual slack channel. """ - def __init__(self, eventrouter, **kwargs): + def __init__(self, eventrouter, channel_type="channel", **kwargs): # We require these two things for a valid object, # the rest we can just learn from slack self.active = False for key, value in kwargs.items(): setattr(self, key, value) self.eventrouter = eventrouter + self.type = channel_type self.slack_name = kwargs["name"] self.slack_purpose = kwargs.get("purpose", {"value": ""}) self.topic = kwargs.get("topic", {"value": ""}) @@ -1676,7 +1677,6 @@ class SlackChannel(SlackChannelCommon): self.thread_channels = {} self.new_messages = False self.typing = {} - self.type = 'channel' self.set_name(self.slack_name) # short name relates to the localvar we change for typing indication self.current_short_name = self.name @@ -2073,8 +2073,7 @@ class SlackDMChannel(SlackChannel): def __init__(self, eventrouter, users, **kwargs): dmuser = kwargs["user"] kwargs["name"] = users[dmuser].name if dmuser in users else dmuser - super(SlackDMChannel, self).__init__(eventrouter, **kwargs) - self.type = 'im' + super(SlackDMChannel, self).__init__(eventrouter, "im", **kwargs) self.update_color() self.set_name(self.slack_name) self.members = {self.user} @@ -2146,9 +2145,8 @@ class SlackGroupChannel(SlackChannel): A group channel is a private discussion group. """ - def __init__(self, eventrouter, **kwargs): - super(SlackGroupChannel, self).__init__(eventrouter, **kwargs) - self.type = "group" + def __init__(self, eventrouter, channel_type="group", **kwargs): + super(SlackGroupChannel, self).__init__(eventrouter, channel_type, **kwargs) self.set_name(self.slack_name) def set_name(self, slack_name): @@ -2164,8 +2162,7 @@ class SlackPrivateChannel(SlackGroupChannel): """ def __init__(self, eventrouter, **kwargs): - super(SlackPrivateChannel, self).__init__(eventrouter, **kwargs) - self.type = "private" + super(SlackPrivateChannel, self).__init__(eventrouter, "private", **kwargs) def set_related_server(self, team): super(SlackPrivateChannel, self).set_related_server(team) @@ -2187,8 +2184,7 @@ class SlackMPDMChannel(SlackChannel): for user_id in kwargs["members"] if user_id != myidentifier )) - super(SlackMPDMChannel, self).__init__(eventrouter, **kwargs) - self.type = "mpim" + super(SlackMPDMChannel, self).__init__(eventrouter, "mpim", **kwargs) def open(self, update_remote=True): self.create_buffer() @@ -2225,8 +2221,7 @@ class SlackMPDMChannel(SlackChannel): class SlackSharedChannel(SlackChannel): def __init__(self, eventrouter, **kwargs): - super(SlackSharedChannel, self).__init__(eventrouter, **kwargs) - self.type = 'shared' + super(SlackSharedChannel, self).__init__(eventrouter, "shared", **kwargs) def set_related_server(self, team): super(SlackSharedChannel, self).set_related_server(team) |