From 04890f3a4b52243f880cd8728c1e95415a2cddf9 Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Sun, 4 Nov 2018 23:37:00 +0100 Subject: Use buffer from arguments instead of w.current_buffer The buffer given in the arguments refers to the buffer where the command was run, while w.current_buffer refers to the buffer active in weechat. Normally these are the same, but relay clients may have a different buffer active than the one in weechat. Therefore, using w.current_buffer could cause commands sent from those clients to operate on the wrong buffer. Fixes #547 and #615 --- wee_slack.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/wee_slack.py b/wee_slack.py index 2f28bbc..a38f9af 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -820,13 +820,12 @@ def quit_notification_callback(signal, sig_type, data): @utf8_decode -def typing_notification_cb(signal, sig_type, data): - msg = w.buffer_get_string(data, "input") +def typing_notification_cb(data, signal, current_buffer): + msg = w.buffer_get_string(current_buffer, "input") if len(msg) > 8 and msg[:1] != "/": global typing_timer now = time.time() if typing_timer + 4 < now: - current_buffer = w.current_buffer() channel = EVENTROUTER.weechat_controller.buffers.get(current_buffer, None) if channel and channel.type != "thread": identifier = channel.identifier @@ -893,7 +892,6 @@ def nick_completion_cb(data, completion_item, current_buffer, completion): Adds all @-prefixed nicks to completion list """ - current_buffer = w.current_buffer() current_channel = EVENTROUTER.weechat_controller.buffers.get(current_buffer, None) if current_channel is None or current_channel.members is None: @@ -911,7 +909,6 @@ def emoji_completion_cb(data, completion_item, current_buffer, completion): Adds all :-prefixed emoji to completion list """ - current_buffer = w.current_buffer() current_channel = EVENTROUTER.weechat_controller.buffers.get(current_buffer, None) if current_channel is None: @@ -930,7 +927,6 @@ def complete_next_cb(data, current_buffer, command): """ - current_buffer = w.current_buffer() current_channel = EVENTROUTER.weechat_controller.buffers.get(current_buffer, None) # channel = channels.find(current_buffer) @@ -3512,8 +3508,7 @@ def command_showmuted(data, current_buffer, args): @utf8_decode def thread_command_callback(data, current_buffer, args): - current = w.current_buffer() - channel = EVENTROUTER.weechat_controller.buffers.get(current) + channel = EVENTROUTER.weechat_controller.buffers.get(current_buffer) if channel: args = args.split() if args[0] == '/thread': @@ -3546,8 +3541,7 @@ def thread_command_callback(data, current_buffer, args): @utf8_decode def rehistory_command_callback(data, current_buffer, args): - current = w.current_buffer() - channel = EVENTROUTER.weechat_controller.buffers.get(current) + channel = EVENTROUTER.weechat_controller.buffers.get(current_buffer) channel.clear_messages() channel.get_history() return w.WEECHAT_RC_OK_EAT -- cgit