aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2017-10-31 20:38:39 +0100
committerTrygve Aaberge <trygveaa@gmail.com>2017-11-07 17:14:19 +0100
commit986b294eb0ae6ec5149accbc39d1de41bb5d4bb5 (patch)
treeb3ae73d054953cf175e4abcdb7ca2388febf0f3a /wee_slack.py
parent3eff1de49d3aba1d991b7b6953e6b55a24fdecd9 (diff)
downloadwee-slack-986b294eb0ae6ec5149accbc39d1de41bb5d4bb5.tar.gz
Allow sending special messages by prefixing them with a slash or a space
This allows you to send messages starting with / or messages like s/a/b/ and +:test: as normal text messages instead of performing the action they normally would. This is done by prefixing the message with a slash (/) or a space ( ), and then the prefix character is removed from the resulting message. Allowing / as a prefix, so you can write e.g. //slack is the normal way to send messages starting with / in weechat. This will work for all messages starting with a slash, but won't work for e.g. /+:test:, as that is interpreted as a command. Using space as a prefix is the way Slack does it. This will work for all messages.
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/wee_slack.py b/wee_slack.py
index c354bf5..2cdbb8f 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -644,7 +644,7 @@ def buffer_input_callback(signal, buffer_ptr, data):
if not channel:
return w.WEECHAT_RC_ERROR
- reaction = re.match("^\s*(\d*)(\+|-):(.*):\s*$", data)
+ reaction = re.match("^(\d*)(\+|-):(.*):\s*$", data)
substitute = re.match("^(\d*)s/", data)
if reaction:
if reaction.group(2) == "+":
@@ -664,6 +664,8 @@ def buffer_input_callback(signal, buffer_ptr, data):
old = old.replace(r'\/', '/')
channel.edit_nth_previous_message(msgno, old, new, flags)
else:
+ if data.startswith(('//', ' ')):
+ data = data[1:]
channel.send_message(data)
# this is probably wrong channel.mark_read(update_remote=True, force=True)
return w.WEECHAT_RC_OK