aboutsummaryrefslogtreecommitdiffstats
path: root/wee_slack.py
diff options
context:
space:
mode:
authorTrygve Aaberge <trygveaa@gmail.com>2020-02-09 22:47:57 +0100
committerTrygve Aaberge <trygveaa@gmail.com>2020-02-23 18:47:05 +0100
commit39e9794c6600306c21d140b8a5cb3ca2f1043688 (patch)
treecae4ff110ba3132365390ca0b8ccb1b5a9d4de94 /wee_slack.py
parentc97e343118edcbdff323e03aa504cb19c5ff58f5 (diff)
downloadwee-slack-39e9794c6600306c21d140b8a5cb3ca2f1043688.tar.gz
Simplify reusing handle/process functions
Diffstat (limited to 'wee_slack.py')
-rw-r--r--wee_slack.py54
1 files changed, 16 insertions, 38 deletions
diff --git a/wee_slack.py b/wee_slack.py
index 9cfacf5..0a866a3 100644
--- a/wee_slack.py
+++ b/wee_slack.py
@@ -2717,26 +2717,6 @@ def handle_mpimopen(mpim_json, eventrouter, object_name='group', **kwargs):
handle_conversationsopen(mpim_json, eventrouter, object_name, **kwargs)
-def handle_groupshistory(message_json, eventrouter, **kwargs):
- handle_history(message_json, eventrouter, **kwargs)
-
-
-def handle_channelshistory(message_json, eventrouter, **kwargs):
- handle_history(message_json, eventrouter, **kwargs)
-
-
-def handle_imhistory(message_json, eventrouter, **kwargs):
- handle_history(message_json, eventrouter, **kwargs)
-
-
-def handle_mpimhistory(message_json, eventrouter, **kwargs):
- handle_history(message_json, eventrouter, **kwargs)
-
-
-def handle_conversationshistory(message_json, eventrouter, **kwargs):
- handle_history(message_json, eventrouter, **kwargs)
-
-
def handle_history(message_json, eventrouter, **kwargs):
request_metadata = message_json["wee_slack_request_metadata"]
kwargs['team'] = request_metadata.team
@@ -2748,6 +2728,13 @@ def handle_history(message_json, eventrouter, **kwargs):
process_message(message, eventrouter, history_message=True, **kwargs)
+handle_channelshistory = handle_history
+handle_conversationshistory = handle_history
+handle_groupshistory = handle_history
+handle_imhistory = handle_history
+handle_mpimhistory = handle_history
+
+
def handle_conversationsreplies(message_json, eventrouter, **kwargs):
request_metadata = message_json['wee_slack_request_metadata']
kwargs['team'] = request_metadata.team
@@ -2842,10 +2829,6 @@ def process_reconnect_url(message_json, eventrouter, **kwargs):
kwargs['team'].set_reconnect_url(message_json['url'])
-def process_manual_presence_change(message_json, eventrouter, **kwargs):
- process_presence_change(message_json, eventrouter, **kwargs)
-
-
def process_presence_change(message_json, eventrouter, **kwargs):
if "user" in kwargs:
# TODO: remove once it's stable
@@ -2859,6 +2842,9 @@ def process_presence_change(message_json, eventrouter, **kwargs):
team.update_member_presence(user, message_json["presence"])
+process_manual_presence_change = process_presence_change
+
+
def process_pref_change(message_json, eventrouter, **kwargs):
team = kwargs["team"]
if message_json['name'] == 'muted_channels':
@@ -2979,10 +2965,6 @@ def download_files(message_json, **kwargs):
break
-def subprocess_thread_broadcast(message_json, eventrouter, channel, team, history_message):
- subprocess_thread_message(message_json, eventrouter, channel, team, history_message)
-
-
def subprocess_thread_message(message_json, eventrouter, channel, team, history_message):
parent_ts = message_json.get('thread_ts')
if parent_ts:
@@ -3012,6 +2994,9 @@ def subprocess_thread_message(message_json, eventrouter, channel, team, history_
)
+subprocess_thread_broadcast = subprocess_thread_message
+
+
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)
@@ -3090,16 +3075,9 @@ def process_channel_marked(message_json, eventrouter, **kwargs):
dbg("tried to mark something weird {}".format(message_json))
-def process_group_marked(message_json, eventrouter, **kwargs):
- process_channel_marked(message_json, eventrouter, **kwargs)
-
-
-def process_im_marked(message_json, eventrouter, **kwargs):
- process_channel_marked(message_json, eventrouter, **kwargs)
-
-
-def process_mpim_marked(message_json, eventrouter, **kwargs):
- process_channel_marked(message_json, eventrouter, **kwargs)
+process_group_marked = process_channel_marked
+process_im_marked = process_channel_marked
+process_mpim_marked = process_channel_marked
def process_channel_joined(message_json, eventrouter, **kwargs):