diff options
Diffstat (limited to 'wee_slack.py')
-rw-r--r-- | wee_slack.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/wee_slack.py b/wee_slack.py index 2d2fb2b..55e9462 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -121,6 +121,7 @@ class SlackServer(object): self.nick = None self.name = None self.domain = None + self.server_alias = None self.login_data = None self.buffer = None self.token = token @@ -202,6 +203,12 @@ class SlackServer(object): self.domain = login_data["team"]["domain"] + ".slack.com" dbg("connected to {}".format(self.domain)) self.identifier = self.domain + + if not w.config_get_plugin("server_alias.{}".format(login_data["team"]["domain"])): + self.server_alias = login_data["team"]["domain"] + else: + self.server_alias = w.config_get_plugin("server_alias.{}".format(login_data["team"]["domain"])) + self.nick = login_data["self"]["name"] self.create_local_buffer() @@ -243,7 +250,7 @@ class SlackServer(object): def create_local_buffer(self): if not w.buffer_search("", self.domain): - self.buffer = w.buffer_new(self.domain, "buffer_input_cb", "", "", "") + self.buffer = w.buffer_new("{}.server".format(self.server_alias), "buffer_input_cb", "", "", "") w.buffer_set(self.buffer, "nicklist", "1") w.nicklist_add_group(self.buffer, '', NICK_GROUP_HERE, "weechat.color.nicklist_group", 1) @@ -376,11 +383,11 @@ class Channel(object): self.members_table[user] = self.server.users.find(user) def create_buffer(self): - channel_buffer = w.buffer_search("", "{}.{}".format(self.server.domain, self.name)) + channel_buffer = w.buffer_search("", "{}.{}".format(self.server.server_alias, self.name)) if channel_buffer: self.channel_buffer = channel_buffer else: - self.channel_buffer = w.buffer_new("{}.{}".format(self.server.domain, self.name), "buffer_input_cb", self.name, "", "") + self.channel_buffer = w.buffer_new("{}.{}".format(self.server.server_alias, self.name), "buffer_input_cb", self.name, "", "") if self.type == "im": w.buffer_set(self.channel_buffer, "localvar_set_type", 'private') else: @@ -389,7 +396,7 @@ class Channel(object): buffer_list_update_next() def attach_buffer(self): - channel_buffer = w.buffer_search("", "{}.{}".format(self.server.domain, self.name)) + channel_buffer = w.buffer_search("", "{}.{}".format(self.server.server_alias, self.name)) if channel_buffer != main_weechat_buffer: self.channel_buffer = channel_buffer w.buffer_set(self.channel_buffer, "localvar_set_nick", self.server.nick) @@ -424,7 +431,7 @@ class Channel(object): dbg("DEBUG: {} {} {}".format(self.identifier, self.name, e)) def fullname(self): - return "{}.{}".format(self.server.domain, self.name) + return "{}.{}".format(self.server.server_alias, self.name) def has_user(self, name): return name in self.members |