mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-13 02:19:54 +00:00
Fixed poll answer FSM context (#1436)
* Add voter_chat to poll_answer event handling The change ensures that when a poll_answer event is processed, the user context middleware now also returns the chat where the vote took place. Previously, only the user who cast the vote was returned. * Added changelog * Fixed tests * Bump Python version in test
This commit is contained in:
parent
30cee817f4
commit
0c9eeda8a7
4 changed files with 7 additions and 6 deletions
1
CHANGES/1436.bugfix.rst
Normal file
1
CHANGES/1436.bugfix.rst
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
Fixed poll answer FSM context by handling :code:`voter_chat` for :code:`poll_answer` event
|
||||||
|
|
@ -71,7 +71,7 @@ class UserContextMiddleware(BaseMiddleware):
|
||||||
if event.pre_checkout_query:
|
if event.pre_checkout_query:
|
||||||
return None, event.pre_checkout_query.from_user, None
|
return None, event.pre_checkout_query.from_user, None
|
||||||
if event.poll_answer:
|
if event.poll_answer:
|
||||||
return None, event.poll_answer.user, None
|
return event.poll_answer.voter_chat, event.poll_answer.user, None
|
||||||
if event.my_chat_member:
|
if event.my_chat_member:
|
||||||
return event.my_chat_member.chat, event.my_chat_member.from_user, None
|
return event.my_chat_member.chat, event.my_chat_member.from_user, None
|
||||||
if event.chat_member:
|
if event.chat_member:
|
||||||
|
|
|
||||||
|
|
@ -44,14 +44,14 @@ class TestBot:
|
||||||
|
|
||||||
def test_init_default(self):
|
def test_init_default(self):
|
||||||
with check_deprecated(
|
with check_deprecated(
|
||||||
max_version="3.5.0",
|
max_version="3.7.0",
|
||||||
exception=TypeError,
|
exception=TypeError,
|
||||||
):
|
):
|
||||||
bot = Bot(token="42:Test", parse_mode="HTML")
|
bot = Bot(token="42:Test", parse_mode="HTML")
|
||||||
|
|
||||||
def test_deprecated_parse_mode(self):
|
def test_deprecated_parse_mode(self):
|
||||||
with check_deprecated(
|
with check_deprecated(
|
||||||
max_version="3.5.0",
|
max_version="3.7.0",
|
||||||
exception=AttributeError,
|
exception=AttributeError,
|
||||||
):
|
):
|
||||||
bot = Bot(token="42:Test", parse_mode="HTML")
|
bot = Bot(token="42:Test", parse_mode="HTML")
|
||||||
|
|
@ -59,7 +59,7 @@ class TestBot:
|
||||||
|
|
||||||
def test_disable_web_page_preview(self):
|
def test_disable_web_page_preview(self):
|
||||||
with check_deprecated(
|
with check_deprecated(
|
||||||
max_version="3.5.0",
|
max_version="3.7.0",
|
||||||
exception=TypeError,
|
exception=TypeError,
|
||||||
):
|
):
|
||||||
bot = Bot(token="42:Test", disable_web_page_preview=True)
|
bot = Bot(token="42:Test", disable_web_page_preview=True)
|
||||||
|
|
@ -67,7 +67,7 @@ class TestBot:
|
||||||
|
|
||||||
def test_deprecated_protect_content(self):
|
def test_deprecated_protect_content(self):
|
||||||
with check_deprecated(
|
with check_deprecated(
|
||||||
max_version="3.5.0",
|
max_version="3.7.0",
|
||||||
exception=AttributeError,
|
exception=AttributeError,
|
||||||
):
|
):
|
||||||
bot = Bot(token="42:Test", protect_content=True)
|
bot = Bot(token="42:Test", protect_content=True)
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ class TestDefaultBotProperties:
|
||||||
assert default_bot_properties["link_preview_prefer_large_media"] is True
|
assert default_bot_properties["link_preview_prefer_large_media"] is True
|
||||||
assert default_bot_properties["link_preview_show_above_text"] is True
|
assert default_bot_properties["link_preview_show_above_text"] is True
|
||||||
|
|
||||||
@pytest.mark.skipif(sys.version_info < (3, 10), reason="requires python3.10 or higher")
|
@pytest.mark.skipif(sys.version_info < (3, 12), reason="requires python3.11 or higher")
|
||||||
def test_dataclass_creation_3_10_plus(self):
|
def test_dataclass_creation_3_10_plus(self):
|
||||||
params = DefaultBotProperties.__dataclass_params__
|
params = DefaultBotProperties.__dataclass_params__
|
||||||
assert params.slots is True
|
assert params.slots is True
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue