Skip to content

Add setting current context of types #369

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 1 commit into from
Jun 27, 2020
Merged

Add setting current context of types #369

merged 1 commit into from
Jun 27, 2020

Conversation

Abstract-X
Copy link

@Abstract-X Abstract-X commented Jun 25, 2020

Description

If we try to get the current update from context, we get None:

from aiogram import Bot, Dispatcher, executor
from aiogram.types import Message

bot = Bot("...")
dispatcher = Dispatcher(bot)

@dispatcher.message_handler()
async def handle_message(message):
    current_message = Message.get_current()
    print(current_message)  # None

executor.start_polling(dispatcher)

After the changes presented in PR, we get the current update without errors:

@dispatcher.message_handler()
async def handle_message(message):
    current_message = Message.get_current()
    print(current_message)  # {"message_id": 1206, "from": {"id": 650535775, ...
    print(message is current_message)  # True

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code

@uwinx uwinx added the enhancement Make it better! label Jun 26, 2020
@JrooTJunior JrooTJunior merged commit c9cbde4 into aiogram:dev-2.x Jun 27, 2020
@Abstract-X Abstract-X deleted the fix-context-types branch June 27, 2020 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Make it better!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants