@@ -339,7 +339,7 @@ async def maybe_update_meetup_message(self):
339339 message_id = msg .message_id , chat_id = msg .chat_id
340340 )
341341
342- def maybe_update_wiki (self ):
342+ async def maybe_update_wiki (self ):
343343 """Check if anybody wrote anything on our wiki."""
344344 now = time .time ()
345345 if now - self .wiki_last_check < 60 :
@@ -352,11 +352,11 @@ def maybe_update_wiki(self):
352352 for chat_id in self .chat_db .list ():
353353 if chat_id == MAIN_CHAT_ID :
354354 continue # don't spam our main group
355- self .try_send_message (text = msg , chat_id = chat_id )
355+ await self .try_send_message (text = msg , chat_id = chat_id )
356356 self .wiki_msg = msg
357357 self .wiki_last_update = now
358358
359- def maybe_update_mumble (self ):
359+ async def maybe_update_mumble (self ):
360360 """Check if Mumble state changed: we either transitioned from 0 to
361361 nonzero or the other way around."""
362362 return
@@ -373,7 +373,7 @@ def maybe_update_mumble(self):
373373 for chat_id in self .chat_db .list ():
374374 if chat_id > 0 :
375375 continue # skip if it's a private chat instead of a group
376- self .try_send_message (text = msg , chat_id = chat_id )
376+ await self .try_send_message (text = msg , chat_id = chat_id )
377377 self .mumble_state = cnt
378378 self .mumble_last_update = now
379379
@@ -391,10 +391,12 @@ async def run(self):
391391
392392 while True :
393393 try :
394- await self .maybe_update_meetup_message ()
395- self .maybe_update_mumble ()
396- self .maybe_update_wiki ()
397- await self .handle_messages ()
394+ await asyncio .gather (
395+ self .maybe_update_meetup_message (),
396+ self .maybe_update_mumble (),
397+ self .maybe_update_wiki (),
398+ self .handle_messages (),
399+ )
398400 except NetworkError :
399401 await asyncio .sleep (1 )
400402 except Exception :
0 commit comments