@@ -249,21 +249,6 @@ async def on_connect(self):
249
249
print (Fore .CYAN + 'Connected to gateway.' )
250
250
251
251
await self .config .refresh ()
252
-
253
- activity_type = self .config .get ('activity_type' )
254
- message = self .config .get ('activity_message' )
255
-
256
- if activity_type is not None and message :
257
- if activity_type == ActivityType .streaming :
258
-
259
- url = self .config .get ('twitch_url' ,
260
- 'https://www.twitch.tv/discord-modmail/' )
261
- else :
262
- url = None
263
-
264
- activity = discord .Activity (type = activity_type , name = message ,
265
- url = url )
266
- await self .change_presence (activity = activity )
267
252
self ._connected .set ()
268
253
269
254
async def on_ready (self ):
@@ -284,10 +269,48 @@ async def on_ready(self):
284
269
else :
285
270
await self .threads .populate_cache ()
286
271
287
- # Wait until config cache is popluated with stuff from db
272
+ # Wait until config cache is populated with stuff from db
288
273
await self .config .wait_until_ready ()
289
274
275
+ # activities
276
+ activity_type = self .config .get ('activity_type' , - 1 )
277
+ message = self .config .get ('activity_message' , '' )
278
+
279
+ normalized_message = ''
280
+ try :
281
+ activity_type = ActivityType (activity_type )
282
+ except ValueError :
283
+ activity_type = - 1
284
+
285
+ if activity_type >= 0 and message :
286
+ if activity_type == ActivityType .listening :
287
+ if message .lower ().startswith ('to ' ):
288
+ # Must be listening to...
289
+ normalized_message = message [3 :].strip ()
290
+ else :
291
+ normalized_message = message .strip ()
292
+
293
+ if normalized_message :
294
+ if activity_type == ActivityType .streaming :
295
+ url = self .config .get ('twitch_url' ,
296
+ 'https://www.twitch.tv/discord-modmail/' )
297
+ else :
298
+ url = None
299
+
300
+ activity = discord .Activity (type = activity_type ,
301
+ name = normalized_message ,
302
+ url = url )
303
+ await self .change_presence (activity = activity )
304
+ # TODO: Trim message
305
+ print (f'{ Fore .CYAN } Activity set to: '
306
+ f'{ activity_type .name } { message } .' )
307
+ else :
308
+ print (f'{ Fore .CYAN } No activity message set.' )
309
+
310
+ # closures
290
311
closures = self .config .closures .copy ()
312
+ print (f'{ Fore .CYAN } There are { len (closures )} thread(s) pending '
313
+ 'to be closed.' )
291
314
292
315
for recipient_id , items in closures .items ():
293
316
after = (datetime .fromisoformat (items ['time' ]) -
@@ -313,6 +336,7 @@ async def on_ready(self):
313
336
delete_channel = items ['delete_channel' ],
314
337
message = items ['message' ]
315
338
)
339
+ print (LINE )
316
340
317
341
async def process_modmail (self , message ):
318
342
"""Processes messages sent to the bot."""
0 commit comments