aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2020-04-19 23:37:16 +0200
committerTrygve Aaberge <trygveaa@gmail.com>2020-05-30 21:11:27 +0200
commit356b56882768b43ad4e9598866d6e27f6ad92c56 (patch)
tree5a97d7eebbd5f017f696afa656c38e6d163296cd /wee_slack.py
parentc82299963bd108eb1eb570254c4e356e5f0c3d56 (diff)
downloadwee-slack-356b56882768b43ad4e9598866d6e27f6ad92c56.tar.gz
Move store/prnt_message out of subprocess functions
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py23
1 files changed, 10 insertions, 13 deletions
diff --git a/wee_slack.py b/wee_slack.py
index ab855ac..e1e0d73 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -3032,12 +3032,14 @@ def process_message(message_json, eventrouter, team, channel, metadata, history_
subtype_functions = get_functions_with_prefix("subprocess_")
if subtype in subtype_functions:
- subtype_functions[subtype](message_json, eventrouter, team, channel, history_message)
+ message = subtype_functions[subtype](message_json, eventrouter, team, channel, history_message)
else:
message = SlackMessage(subtype or "normal", message_json, team, channel)
+ channel.unread_count_display += 1
+
+ if message:
channel.store_message(message)
channel.prnt_message(message, history_message)
- channel.unread_count_display += 1
if not history_message:
download_files(message_json, team)
@@ -3082,18 +3084,14 @@ def download_files(message_json, team):
def subprocess_thread_message(message_json, eventrouter, team, channel, history_message):
- dbg("THREAD MESSAGE {}".format(message_json))
parent_ts = message_json.get('thread_ts')
if parent_ts:
parent_message = channel.messages.get(SlackTS(parent_ts))
if parent_message:
- message = SlackThreadMessage(
- parent_message, message_json, team, channel)
+ message = SlackThreadMessage(parent_message, message_json, team, channel)
parent_message.submessages.append(message)
channel.hash_message(parent_ts)
- channel.store_message(message)
channel.change_message(parent_ts)
- channel.prnt_message(message, history_message)
if parent_message.thread_channel and parent_message.thread_channel.active:
parent_message.thread_channel.prnt_message(message, history_message)
@@ -3102,6 +3100,8 @@ def subprocess_thread_message(message_json, eventrouter, team, channel, history_
elif message.ts > parent_message.last_read and parent_message.subscribed:
parent_message.notify_thread(action="subscribed", sender_id=message_json["user"])
+ return message
+
subprocess_thread_broadcast = subprocess_thread_message
@@ -3109,22 +3109,19 @@ subprocess_thread_broadcast = subprocess_thread_message
def subprocess_channel_join(message_json, eventrouter, team, channel, history_message):
message = SlackMessage("join", message_json, team, channel)
channel.user_joined(message_json["user"])
- channel.store_message(message)
- channel.prnt_message(message, history_message)
+ return message
def subprocess_channel_leave(message_json, eventrouter, team, channel, history_message):
message = SlackMessage("leave", message_json, team, channel)
channel.user_left(message_json["user"])
- channel.store_message(message)
- channel.prnt_message(message, history_message)
+ return message
def subprocess_channel_topic(message_json, eventrouter, team, channel, history_message):
message = SlackMessage("topic", message_json, team, channel)
channel.set_topic(message_json["topic"])
- channel.store_message(message)
- channel.prnt_message(message, history_message)
+ return message
subprocess_group_join = subprocess_channel_join