aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2020-10-05 23:00:43 +0200
committerTrygve Aaberge <trygveaa@gmail.com>2020-10-05 23:00:58 +0200
commit19aff6d7b6feb28acdb13f2ad5ecdbb3fe44ea88 (patch)
tree69b12c905bb2b92acbb722ce3d2a522a3762348e /wee_slack.py
parent3be133d473a1a3965efb1bfcb2927325f6bdfd67 (diff)
downloadwee-slack-19aff6d7b6feb28acdb13f2ad5ecdbb3fe44ea88.tar.gz
Combine duplicated send_message code
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py33
1 files changed, 14 insertions, 19 deletions
diff --git a/wee_slack.py b/wee_slack.py
index e0ad9bf..79ce80a 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -1614,6 +1614,17 @@ class SlackChannelCommon(object):
config.thread_messages_in_channel and self.pending_history_requests):
self.print_getting_history()
+ def send_message(self, message, subtype=None, request_dict_ext={}):
+ message = linkify_text(message, self.team)
+ if subtype == 'me_message':
+ s = SlackRequest(self.team, "chat.meMessage", {"channel": self.identifier, "text": message}, channel=self)
+ self.eventrouter.receive(s)
+ else:
+ request = {"type": "message", "channel": self.identifier,
+ "text": message, "user": self.team.myidentifier}
+ request.update(request_dict_ext)
+ self.team.send_to_websocket(request)
+
def send_add_reaction(self, msg_id, reaction):
self.send_change_reaction("reactions.add", msg_id, reaction)
@@ -2034,18 +2045,6 @@ class SlackChannel(SlackChannelCommon):
if backlog or self_msg:
self.mark_read(ts, update_remote=False, force=True)
- def send_message(self, message, subtype=None, request_dict_ext={}):
- message = linkify_text(message, self.team)
- dbg(message)
- if subtype == 'me_message':
- s = SlackRequest(self.team, "chat.meMessage", {"channel": self.identifier, "text": message}, channel=self)
- self.eventrouter.receive(s)
- else:
- request = {"type": "message", "channel": self.identifier,
- "text": message, "user": self.team.myidentifier}
- request.update(request_dict_ext)
- self.team.send_to_websocket(request)
-
def store_message(self, message_to_store):
if not self.active:
return
@@ -2563,14 +2562,10 @@ class SlackThreadChannel(SlackChannelCommon):
if subtype == 'me_message':
w.prnt("", "ERROR: /me is not supported in threads")
return w.WEECHAT_RC_ERROR
- message = linkify_text(message, self.team)
- dbg(message)
- request = {"type": "message", "text": message,
- "channel": self.parent_channel.identifier,
- "thread_ts": str(self.thread_ts),
- "user": self.team.myidentifier}
+
+ request = {"thread_ts": str(self.thread_ts)}
request.update(request_dict_ext)
- self.team.send_to_websocket(request)
+ super(SlackThreadChannel, self).send_message(message, subtype, request)
def open(self, update_remote=True):
self.create_buffer()