aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--wee_slack.py23
1 files changed, 12 insertions, 11 deletions
diff --git a/wee_slack.py b/wee_slack.py
index 55e9462..dd0fb6f 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -121,7 +121,7 @@ class SlackServer(object):
self.nick = None
self.name = None
self.domain = None
- self.server_alias = None
+ self.server_buffer_name = None
self.login_data = None
self.buffer = None
self.token = token
@@ -204,10 +204,11 @@ class SlackServer(object):
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"]
+ alias = w.config_get_plugin("server_alias.{}".format(login_data["team"]["domain"]))
+ if alias:
+ self.server_buffer_name = alias
else:
- self.server_alias = w.config_get_plugin("server_alias.{}".format(login_data["team"]["domain"]))
+ self.server_buffer_name = self.domain
self.nick = login_data["self"]["name"]
self.create_local_buffer()
@@ -249,8 +250,8 @@ class SlackServer(object):
self.buffer_prnt('{:<20} {}'.format("Team id", login_data["team"]["id"]), backlog=True)
def create_local_buffer(self):
- if not w.buffer_search("", self.domain):
- self.buffer = w.buffer_new("{}.server".format(self.server_alias), "buffer_input_cb", "", "", "")
+ if not w.buffer_search("", self.server_buffer_name):
+ self.buffer = w.buffer_new(self.server_buffer_name, "buffer_input_cb", "", "", "")
w.buffer_set(self.buffer, "nicklist", "1")
w.nicklist_add_group(self.buffer, '', NICK_GROUP_HERE, "weechat.color.nicklist_group", 1)
@@ -383,11 +384,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.server_alias, self.name))
+ channel_buffer = w.buffer_search("", "{}.{}".format(self.server.server_buffer_name, self.name))
if channel_buffer:
self.channel_buffer = channel_buffer
else:
- self.channel_buffer = w.buffer_new("{}.{}".format(self.server.server_alias, self.name), "buffer_input_cb", self.name, "", "")
+ self.channel_buffer = w.buffer_new("{}.{}".format(self.server.server_buffer_name, self.name), "buffer_input_cb", self.name, "", "")
if self.type == "im":
w.buffer_set(self.channel_buffer, "localvar_set_type", 'private')
else:
@@ -396,7 +397,7 @@ class Channel(object):
buffer_list_update_next()
def attach_buffer(self):
- channel_buffer = w.buffer_search("", "{}.{}".format(self.server.server_alias, self.name))
+ channel_buffer = w.buffer_search("", "{}.{}".format(self.server.server_buffer_name, 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)
@@ -431,7 +432,7 @@ class Channel(object):
dbg("DEBUG: {} {} {}".format(self.identifier, self.name, e))
def fullname(self):
- return "{}.{}".format(self.server.server_alias, self.name)
+ return "{}.{}".format(self.server.server_buffer_name, self.name)
def has_user(self, name):
return name in self.members
@@ -1142,7 +1143,7 @@ def command_openweb(current_buffer, args):
if trigger != "0":
if args is None:
channel = channels.find(current_buffer)
- url = "{}/messages/{}".format(channel.server.domain, channel.name)
+ url = "{}/messages/{}".format(channel.server.server_buffer_name, channel.name)
topic = w.buffer_get_string(channel.channel_buffer, "title")
w.buffer_set(channel.channel_buffer, "title", "{}:{}".format(trigger, url))
w.hook_timer(1000, 0, 1, "command_openweb", json.dumps({"topic": topic, "buffer": current_buffer}))