aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2017-09-27 00:33:08 +0200
committerGitHub <noreply@github.com>2017-09-27 00:33:08 +0200
commit055f19717ab034ae8d96220a25df30f9f0576b48 (patch)
treea66fc24ef4323abf87b647d7b6a47b534fa4c965 /wee_slack.py
parent2f43d1b6466c74e8774e2833214f847eb559f15a (diff)
parent4bf54a67516059b352789dc40127d099a06ffd3a (diff)
downloadwee-slack-055f19717ab034ae8d96220a25df30f9f0576b48.tar.gz
Merge pull request #430 from trygveaa/send-multiline-messages
Add support for sending multiline messages
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/wee_slack.py b/wee_slack.py
index 90b56ac..09b4640 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -637,6 +637,19 @@ def buffer_input_callback(signal, buffer_ptr, data):
return w.WEECHAT_RC_OK
+# 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
+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 "\n" in message and not message.startswith("/"):
+ buffer_input_callback("EVENTROUTER", current_buffer, message)
+ return ""
+ return string
+
+
def buffer_switch_callback(signal, sig_type, data):
"""
incomplete
@@ -3555,6 +3568,7 @@ if __name__ == "__main__":
# main_weechat_buffer = w.info_get("irc_buffer", "{}.{}".format(domain, "DOESNOTEXIST!@#$"))
w.hook_config("plugins.var.python." + SCRIPT_NAME + ".*", "config_changed_cb", "")
+ w.hook_modifier("input_text_for_buffer", "input_text_for_buffer_cb", "")
load_emoji()
setup_hooks()