File tree Expand file tree Collapse file tree 4 files changed +23
-9
lines changed Expand file tree Collapse file tree 4 files changed +23
-9
lines changed Original file line number Diff line number Diff line change 6
6
class AirtableManager :
7
7
def __init__ (self , api_key : str , base_id : str , production : bool = False ):
8
8
api = Api (api_key )
9
- self .events_table = api .table (base_id , "Events" ) if production else api .table (base_id , "Test Events" )
10
- self .users_table = api .table (base_id , "Users" ) if production else api .table (base_id , "Test Users" )
9
+ self .events_table = (
10
+ api .table (base_id , "Events" )
11
+ if production
12
+ else api .table (base_id , "Test Events" )
13
+ )
14
+ self .users_table = (
15
+ api .table (base_id , "Users" )
16
+ if production
17
+ else api .table (base_id , "Test Users" )
18
+ )
11
19
print ("Connected to Airtable" )
12
20
13
21
def create_event (
Original file line number Diff line number Diff line change @@ -41,7 +41,9 @@ def __init__(self):
41
41
raise Exception ("SENTRY_DSN is not set" )
42
42
43
43
self .airtable = AirtableManager (
44
- api_key = self .airtable_api_key , base_id = self .airtable_base_id , production = self .environemnt == "production"
44
+ api_key = self .airtable_api_key ,
45
+ base_id = self .airtable_base_id ,
46
+ production = self .environemnt == "production" ,
45
47
)
46
48
47
49
self .mailer = Email (sender = google_username , password = google_password )
@@ -50,7 +52,7 @@ def __init__(self):
50
52
"U054VC2KM9P" , # Amber
51
53
"U0409FSKU82" , # Arpan
52
54
"U01MPHKFZ7S" , # Aarya
53
- "UDK5M9Y13" , # Chris
55
+ "UDK5M9Y13" , # Chris
54
56
"U06QST7V0J2" , # Eesha
55
57
]
56
58
Original file line number Diff line number Diff line change 5
5
import re
6
6
7
7
client = WebClient (token = env .slack_bot_token )
8
- ZWSP = '\u200B '
8
+ ZWSP = "\u200B "
9
+
9
10
10
11
def user_in_safehouse (user_id : str ):
11
12
sad_members = client .conversations_members (channel = env .slack_sad_channel )["members" ]
@@ -85,7 +86,9 @@ def parse_elements_to_mrkdwn(elements):
85
86
text = element ["text" ]
86
87
if "style" in element :
87
88
styles = element ["style" ]
88
- words = re .split (r'(\s+)' , text ) # Split by whitespace but keep the whitespace
89
+ words = re .split (
90
+ r"(\s+)" , text
91
+ ) # Split by whitespace but keep the whitespace
89
92
formatted_words = []
90
93
for word in words :
91
94
if word .strip (): # Only apply formatting to non-whitespace words
@@ -122,6 +125,7 @@ def parse_elements_to_mrkdwn(elements):
122
125
mrkdwn += f"<!subteam^{ element ['usergroup_id' ]} >"
123
126
return mrkdwn
124
127
128
+
125
129
def rich_text_to_mrkdwn (data ):
126
130
mrkdwn = ""
127
131
for block in data :
@@ -139,4 +143,4 @@ def rich_text_to_mrkdwn(data):
139
143
# Recursively parse nested lists
140
144
if "elements" in item :
141
145
mrkdwn += rich_text_to_mrkdwn (item ["elements" ])
142
- return mrkdwn
146
+ return mrkdwn
Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ def get_home(user_id: str, client: WebClient):
49
49
)
50
50
formatted_time = f"<!date^{ int (datetime .fromisoformat (event ['fields' ]['End Time' ]).timestamp ())} ^Ends at {{time}}|{ fallback_time } >"
51
51
rich_text = json .loads (event ["fields" ]["Raw Description" ])
52
- mrkdwn = rich_text_to_mrkdwn (rich_text [' elements' ])
52
+ mrkdwn = rich_text_to_mrkdwn (rich_text [" elements" ])
53
53
current_events_blocks .append (
54
54
{
55
55
"type" : "section" ,
@@ -120,7 +120,7 @@ def get_home(user_id: str, client: WebClient):
120
120
)
121
121
formatted_time = f"<!date^{ int (datetime .fromisoformat (event ['fields' ]['Start Time' ]).timestamp ())} ^{{date_long_pretty}} at {{time}}|{ fallback_time } >"
122
122
rich_text = json .loads (event ["fields" ]["Raw Description" ])
123
- mrkdwn = rich_text_to_mrkdwn (rich_text [' elements' ])
123
+ mrkdwn = rich_text_to_mrkdwn (rich_text [" elements" ])
124
124
upcoming_events_blocks .append (
125
125
{
126
126
"type" : "section" ,
You can’t perform that action at this time.
0 commit comments