Conversation
leddcode
commented
Jan 31, 2021
- Updated getting current events
- Added creating new events
…into telegram-v2
Codecov Report
@@ Coverage Diff @@
## develop #168 +/- ##
===========================================
+ Coverage 99.39% 99.43% +0.04%
===========================================
Files 38 38
Lines 1489 1603 +114
===========================================
+ Hits 1480 1594 +114
Misses 9 9
Continue to review full report at Codecov.
|
yammesicka
left a comment
There was a problem hiding this comment.
Awesome job! Looks really cool. I left you with 1 major architecture change to do, and 2 SRP issues :)
|
|
||
|
|
||
| class Bot: | ||
| MEMORY = {} |
There was a problem hiding this comment.
This is problematic. It's equivalent to a global variable and might create problems when working asynchronously.
| await telegram_bot.send_message(chat_id=self.chat.user_id, text=answer) | ||
| return answer | ||
|
|
||
| async def process_new_event(self, memo_dict): |
|
|
||
| telegram_bot = Bot(BOT_API, WEBHOOK_URL) | ||
|
|
||
| loop = asyncio.get_event_loop() |
There was a problem hiding this comment.
I think you can just asyncio.run the set_webhook
There was a problem hiding this comment.
It's impossible - asyncio.run() cannot be called from a running event loop (which started by FastAPI).
It seems "ensure_future" is the best way of executing code in asyncio without awaiting and closing the current loop.