Skip to content

Telegram v2 #168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 37 commits into from
Feb 7, 2021
Merged

Telegram v2 #168

merged 37 commits into from
Feb 7, 2021

Conversation

leddcode
Copy link
Contributor

  • Updated getting current events
  • Added creating new events

@codecov-io
Copy link

codecov-io commented Jan 31, 2021

Codecov Report

Merging #168 (498ef67) into develop (fdb5d87) will increase coverage by 0.04%.
The diff coverage is 100.00%.

Impacted file tree graph

@@             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              
Impacted Files Coverage Δ
app/main.py 96.29% <ø> (-0.26%) ⬇️
app/routers/telegram.py 100.00% <100.00%> (ø)
app/telegram/bot.py 100.00% <100.00%> (ø)
app/telegram/handlers.py 100.00% <100.00%> (ø)
app/telegram/keyboards.py 100.00% <100.00%> (ø)
app/telegram/models.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fdb5d87...498ef67. Read the comment docs.

@leddcode leddcode changed the base branch from main to develop February 1, 2021 04:20
Copy link
Member

@yammesicka yammesicka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome job! Looks really cool. I left you with 1 major architecture change to do, and 2 SRP issues :)

@@ -27,6 +27,8 @@ def _get_first_name(self, data: Dict) -> str:


class Bot:
MEMORY = {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split to functions

@leddcode leddcode requested a review from yammesicka February 1, 2021 10:23
@@ -9,3 +11,7 @@
WEBHOOK_URL = settings.webhook_url

telegram_bot = Bot(BOT_API, WEBHOOK_URL)

loop = asyncio.get_event_loop()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can just asyncio.run the set_webhook

Copy link
Contributor Author

@leddcode leddcode Feb 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@leddcode leddcode requested a review from yammesicka February 7, 2021 09:29
@yammesicka yammesicka merged commit 27a6cf7 into PythonFreeCourse:develop Feb 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants