aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2019-06-11 17:52:39 +0200
committerTrygve Aaberge <trygveaa@gmail.com>2019-06-11 18:37:12 +0200
commit78cbf1cce093d8e9d682e381e7bfa5dc298d227a (patch)
treec69d45fa3b8017dba7896097c58c6b0360072b8b /wee_slack.py
parente00965c88c3d9ebcd7a639aa643390527c2ae60d (diff)
downloadwee-slack-78cbf1cce093d8e9d682e381e7bfa5dc298d227a.tar.gz
Prevent logging of historic join/leave/topic messages
Commit 79c825d changed logging so only historic messages are prevented from being logged, but join/leave/topic messages were not marked as historic, so they were always logged.
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 b6a3393..070a39f 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -2867,10 +2867,7 @@ def process_message(message_json, eventrouter, store=True, history_message=False
subtype_functions = get_functions_with_prefix("subprocess_")
if subtype in subtype_functions:
- subtype_kwargs = {}
- if message_json["subtype"] == "thread_message":
- subtype_kwargs["history_message"] = history_message
- subtype_functions[subtype](message_json, eventrouter, channel, team, **subtype_kwargs)
+ subtype_functions[subtype](message_json, eventrouter, channel, team, history_message)
else:
message = SlackMessage(message_json, team, channel)
text = channel.render(message)
@@ -2979,18 +2976,18 @@ def subprocess_thread_message(message_json, eventrouter, channel, team, history_
# channel.become_thread(message_json["item"]["ts"], message_json)
-def subprocess_channel_join(message_json, eventrouter, channel, team):
+def subprocess_channel_join(message_json, eventrouter, channel, team, history_message):
prefix_join = w.prefix("join").strip()
message = SlackMessage(message_json, team, channel, override_sender=prefix_join)
- channel.buffer_prnt(prefix_join, channel.render(message), message_json["ts"], tagset='join', tag_nick=message.get_sender()[1])
+ channel.buffer_prnt(prefix_join, channel.render(message), message_json["ts"], tagset='join', tag_nick=message.get_sender()[1], history_message=history_message)
channel.user_joined(message_json['user'])
channel.store_message(message, team)
-def subprocess_channel_leave(message_json, eventrouter, channel, team):
+def subprocess_channel_leave(message_json, eventrouter, channel, team, history_message):
prefix_leave = w.prefix("quit").strip()
message = SlackMessage(message_json, team, channel, override_sender=prefix_leave)
- channel.buffer_prnt(prefix_leave, channel.render(message), message_json["ts"], tagset='leave', tag_nick=message.get_sender()[1])
+ channel.buffer_prnt(prefix_leave, channel.render(message), message_json["ts"], tagset='leave', tag_nick=message.get_sender()[1], history_message=history_message)
channel.user_left(message_json['user'])
channel.store_message(message, team)
@@ -2999,7 +2996,7 @@ subprocess_group_join = subprocess_channel_join
subprocess_group_leave = subprocess_channel_leave
-def subprocess_message_replied(message_json, eventrouter, channel, team):
+def subprocess_message_replied(message_json, eventrouter, channel, team, history_message):
parent_ts = message_json["message"].get("thread_ts")
parent_message = channel.messages.get(SlackTS(parent_ts))
# Thread exists but is not open yet
@@ -3012,20 +3009,20 @@ def subprocess_message_replied(message_json, eventrouter, channel, team):
elif any(team.myidentifier == r["user"] for r in message_json["message"]["replies"]):
parent_message.notify_thread(action="participant", sender_id=last_message["user"])
-def subprocess_message_changed(message_json, eventrouter, channel, team):
+def subprocess_message_changed(message_json, eventrouter, channel, team, history_message):
new_message = message_json.get("message")
channel.change_message(new_message["ts"], message_json=new_message)
-def subprocess_message_deleted(message_json, eventrouter, channel, team):
+def subprocess_message_deleted(message_json, eventrouter, channel, team, history_message):
message = "{}{}{}".format(
w.color("red"), '(deleted)', w.color("reset"))
channel.change_message(message_json["deleted_ts"], text=message)
-def subprocess_channel_topic(message_json, eventrouter, channel, team):
+def subprocess_channel_topic(message_json, eventrouter, channel, team, history_message):
prefix_topic = w.prefix("network").strip()
message = SlackMessage(message_json, team, channel, override_sender=prefix_topic)
- channel.buffer_prnt(prefix_topic, channel.render(message), message_json["ts"], tagset="topic", tag_nick=message.get_sender()[1])
+ channel.buffer_prnt(prefix_topic, channel.render(message), message_json["ts"], tagset="topic", tag_nick=message.get_sender()[1], history_message=history_message)
channel.set_topic(message_json["topic"])
channel.store_message(message, team)