aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2020-03-28 22:46:09 +0100
committerTrygve Aaberge <trygveaa@gmail.com>2020-04-19 12:22:17 +0200
commit15168752c666d821b55a3074cbab9d6d857af5d6 (patch)
tree1d1a618ee5099f7575ddbb57aefa44a5a83d2270 /wee_slack.py
parentb2618afd56650b3154726c216723756b327d7f48 (diff)
downloadwee-slack-15168752c666d821b55a3074cbab9d6d857af5d6.tar.gz
Support multiline input commands
Relates to #728
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/wee_slack.py b/wee_slack.py
index e23d4c9..56e3efa 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -818,6 +818,7 @@ def buffer_input_callback(signal, buffer_ptr, data):
this includes add/remove reactions, modifying messages, and
sending messages.
"""
+ data = data.replace('\r', '\n')
eventrouter = eval(signal)
channel = eventrouter.weechat_controller.get_channel_from_buffer_ptr(buffer_ptr)
if not channel:
@@ -862,15 +863,13 @@ def buffer_input_callback(signal, buffer_ptr, data):
# Workaround for supporting multiline messages. It intercepts before the input
# callback is called, as this is called with the whole message, while it is
-# normally split on newline before being sent to buffer_input_callback
+# normally split on newline before being sent to buffer_input_callback.
+# WeeChat only splits on newline, so we replace it with carriage return, and
+# replace it back in buffer_input_callback.
def input_text_for_buffer_cb(data, modifier, current_buffer, string):
if current_buffer not in EVENTROUTER.weechat_controller.buffers:
return string
- message = decode_from_utf8(string)
- if not message.startswith("/") and "\n" in message:
- buffer_input_callback("EVENTROUTER", current_buffer, message)
- return ""
- return string
+ return re.sub('\r?\n', '\r', decode_from_utf8(string))
@utf8_decode