-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcontroller.py
More file actions
123 lines (113 loc) · 3.68 KB
/
controller.py
File metadata and controls
123 lines (113 loc) · 3.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
from config.env_config import envs
from handler.bigchat.abandon_bigchat import AbandonBigchat
from handler.bigchat.announce_new_channel_created import AnnounceNewChannelCreated
from handler.bigchat.create_bigchat_sheet import CreateBigchatSheet
from handler.bigchat.join_bigchat import JoinBigchat
from handler.bigchat.simple_response import SimpleResponse
from handler.decorator import catch_global_error, loading_emoji_while_processing
from implementation.google_spreadsheet_client import GoogleSpreadsheetClient
from implementation.member_finder import MemberManager
from implementation.slack_client import SlackClient
# reaction_added event sample:
# {
# 'type': 'reaction_added',
# 'user': 'UQJ8HQJG5',
# 'reaction': 'kirbyok',
# 'item': {
# 'type': 'message',
# 'channel': 'C03SZTDEDK3',
# 'ts': '1688801145.307229'
# },
# 'item_user': 'UQJ8HQJG5',
# 'event_ts': '1688833113.003600'
# }
@catch_global_error()
@loading_emoji_while_processing([envs.JOIN_BIGCHAT_EMOJI])
def join_bigchat(event, say, client):
JoinBigchat(
event,
envs.JOIN_BIGCHAT_EMOJI,
SlackClient(say, client),
GoogleSpreadsheetClient(),
MemberManager.get_instance(),
).run()
@catch_global_error()
@loading_emoji_while_processing([envs.JOIN_BIGCHAT_EMOJI])
def abandon_bigchat(event, say, client):
AbandonBigchat(
event,
envs.ANNA_ID,
envs.JOIN_BIGCHAT_EMOJI,
SlackClient(say, client),
MemberManager.get_instance(),
GoogleSpreadsheetClient(),
).run()
# app_mention event sample:
# {
# 'client_msg_id': '8fb50d48-f93d-4cca-b9ca-6965479e9a93',
# 'type': 'app_mention',
# 'text': msg,
# 'user': 'UQJ8HQJG5',
# 'ts': '1689403771.805849',
# 'blocks': [ ... ], # not used and too long, so skipped
# 'team': 'TQLEG4B38',
# 'thread_ts': '1689403100.222939',
# 'parent_user_id': 'UQJ8HQJG5',
# 'channel': 'C03SZTDEDK3',
# 'event_ts': '1689403771.805849'
# }
@catch_global_error()
@loading_emoji_while_processing()
def create_bigchat_sheet(event, say, client):
CreateBigchatSheet(event, SlackClient(say, client), GoogleSpreadsheetClient()).run()
@catch_global_error()
@loading_emoji_while_processing()
def simple_response(event, say, client):
SimpleResponse(event, SlackClient(say, client)).run()
# channel_created event sample:
# {
# 'type': 'channel_created',
# 'channel': {
# 'id': 'C07DB6LPCJE',
# 'name': 'test-create-channel-2',
# 'is_channel': True,
# 'is_group': False,
# 'is_im': False,
# 'is_mpim': False,
# 'is_private': False,
# 'created': 1721484974,
# 'is_archived': False,
# 'is_general': False,
# 'unlinked': 0,
# 'name_normalized': 'test-create-channel-2',
# 'is_shared': False,
# 'is_frozen': False,
# 'is_org_shared': False,
# 'is_pending_ext_shared': False,
# 'pending_shared': [],
# 'context_team_id': 'TQLEG4B38',
# 'updated': 1721484974161,
# 'parent_conversation': None,
# 'creator': 'UQJ8HQJG5',
# 'is_ext_shared': False,
# 'shared_team_ids': [
# 'TQLEG4B38'
# ],
# 'pending_connected_team_ids': [],
# 'topic': {
# 'value': '',
# 'creator': '',
# 'last_set': 0
# },
# 'purpose': {
# 'value': '',
# 'creator': '',
# 'last_set': 0
# },
# 'previous_names': []
# },
# 'event_ts': '1721484974.006000'
# }
@catch_global_error()
def announce_new_channel_created(event, say, client):
AnnounceNewChannelCreated(event, SlackClient(say, client)).run()