diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2019-08-24 17:55:38 +0200 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2019-08-25 19:42:06 +0200 |
commit | 560a22cf71aa29fbf175510cd0bc0595e4ce568a (patch) | |
tree | ab9c309bf353b071abc872f16b39b757260a493d | |
parent | 88f02db6f1bdade3c745123a6886bf4f47a4ed9c (diff) | |
download | wee-slack-560a22cf71aa29fbf175510cd0bc0595e4ce568a.tar.gz |
Include channel prefix in key in get_channel_map
Fixes #587
-rw-r--r-- | _pytest/conftest.py | 2 | ||||
-rw-r--r-- | _pytest/test_topic_command.py | 6 | ||||
-rw-r--r-- | wee_slack.py | 14 |
3 files changed, 11 insertions, 11 deletions
diff --git a/_pytest/conftest.py b/_pytest/conftest.py index 0a770c7..87fa834 100644 --- a/_pytest/conftest.py +++ b/_pytest/conftest.py @@ -57,7 +57,7 @@ def team(realish_eventrouter): @pytest.fixture def channel_general(team): - return team.channels[team.get_channel_map()['general']] + return team.channels[team.get_channel_map()['#general']] @pytest.fixture def user_alice(team): diff --git a/_pytest/test_topic_command.py b/_pytest/test_topic_command.py index 2137c27..5224ab7 100644 --- a/_pytest/test_topic_command.py +++ b/_pytest/test_topic_command.py @@ -29,7 +29,7 @@ def test_parse_topic_with_delete(): def test_parse_topic_with_channel(): channel_name, topic = parse_topic_command('/topic #general') - assert channel_name == 'general' + assert channel_name == '#general' assert topic is None @@ -37,14 +37,14 @@ def test_parse_topic_with_channel_and_text(): channel_name, topic = parse_topic_command( '/topic #general some topic text') - assert channel_name == 'general' + assert channel_name == '#general' assert topic == 'some topic text' def test_parse_topic_with_channel_and_delete(): channel_name, topic = parse_topic_command('/topic #general -delete') - assert channel_name == 'general' + assert channel_name == '#general' assert topic == '' diff --git a/wee_slack.py b/wee_slack.py index 2ca19af..9a17016 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -1320,7 +1320,7 @@ class SlackTeam(object): return channel def get_channel_map(self): - return {v.slack_name: k for k, v in self.channels.items()} + return {v.name: k for k, v in self.channels.items()} def get_username_map(self): return {v.name: k for k, v in self.users.items()} @@ -3215,8 +3215,8 @@ def linkify_text(message, team): if targets and targets.groups()[0] == '#': named = targets.groups() try: - if channels[named[1]]: - message[item[0]] = "<#{}|{}>{}".format(channels[named[1]], named[1], named[2]) + if channels[named[0] + named[1]]: + message[item[0]] = "<#{}|{}>{}".format(channels[named[0] + named[1]], named[1], named[2]) except: message[item[0]] = "#{}{}".format(named[1], named[2]) @@ -3549,7 +3549,7 @@ def parse_topic_command(command): if args: if args[0].startswith('#'): - channel_name = args[0][1:] + channel_name = args[0] topic = args[1:] else: topic = args @@ -3580,7 +3580,7 @@ def topic_command_cb(data, current_buffer, command): channel = EVENTROUTER.weechat_controller.buffers[current_buffer] if not channel: - w.prnt(team.channel_buffer, "#{}: No such channel".format(channel_name)) + w.prnt(team.channel_buffer, "{}: No such channel".format(channel_name)) return w.WEECHAT_RC_OK_EAT if topic is None: @@ -3710,7 +3710,7 @@ def msg_command_cb(data, current_buffer, args): aargs = args.split(None, 2) who = aargs[1].lstrip('@') if who == "*": - who = EVENTROUTER.weechat_controller.buffers[current_buffer].slack_name + who = EVENTROUTER.weechat_controller.buffers[current_buffer].name else: join_query_command_cb(data, current_buffer, '/query ' + who) @@ -3816,7 +3816,7 @@ def join_query_command_cb(data, current_buffer, args): query = split_args[1] # Try finding the channel by name - channel = team.channels.get(team.get_channel_map().get(query.lstrip('#'))) + channel = team.channels.get(team.get_channel_map().get(query)) # If the channel doesn't exist, try finding a DM or MPDM instead if not channel: |