mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
* #1520 Fixed event context resolving for the callback query that is coming from the business account * Simplify some conditions * Added changelog * Fixed AttributeError
This commit is contained in:
parent
46e033e6da
commit
7f47609585
10 changed files with 24 additions and 17 deletions
1
CHANGES/1520.bugfix.rst
Normal file
1
CHANGES/1520.bugfix.rst
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
Fixed event context resolving for the callback query that is coming from the business account
|
||||||
|
|
@ -80,14 +80,20 @@ class UserContextMiddleware(BaseMiddleware):
|
||||||
if event.chosen_inline_result:
|
if event.chosen_inline_result:
|
||||||
return EventContext(user=event.chosen_inline_result.from_user)
|
return EventContext(user=event.chosen_inline_result.from_user)
|
||||||
if event.callback_query:
|
if event.callback_query:
|
||||||
if event.callback_query.message:
|
callback_query_message = event.callback_query.message
|
||||||
|
if callback_query_message:
|
||||||
return EventContext(
|
return EventContext(
|
||||||
chat=event.callback_query.message.chat,
|
chat=callback_query_message.chat,
|
||||||
user=event.callback_query.from_user,
|
user=event.callback_query.from_user,
|
||||||
thread_id=(
|
thread_id=(
|
||||||
event.callback_query.message.message_thread_id
|
callback_query_message.message_thread_id
|
||||||
if not isinstance(event.callback_query.message, InaccessibleMessage)
|
if not isinstance(callback_query_message, InaccessibleMessage)
|
||||||
and event.callback_query.message.is_topic_message
|
and callback_query_message.is_topic_message
|
||||||
|
else None
|
||||||
|
),
|
||||||
|
business_connection_id=(
|
||||||
|
callback_query_message.business_connection_id
|
||||||
|
if not isinstance(callback_query_message, InaccessibleMessage)
|
||||||
else None
|
else None
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ from __future__ import annotations
|
||||||
from typing import TYPE_CHECKING, Any, Literal, Union
|
from typing import TYPE_CHECKING, Any, Literal, Union
|
||||||
|
|
||||||
from ..enums import InputPaidMediaType
|
from ..enums import InputPaidMediaType
|
||||||
from .input_paid_media import InputPaidMedia
|
|
||||||
from .input_file import InputFile
|
from .input_file import InputFile
|
||||||
|
from .input_paid_media import InputPaidMedia
|
||||||
|
|
||||||
|
|
||||||
class InputPaidMediaPhoto(InputPaidMedia):
|
class InputPaidMediaPhoto(InputPaidMedia):
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,10 @@ from aiogram.utils.text_decorations import (
|
||||||
html_decoration,
|
html_decoration,
|
||||||
markdown_decoration,
|
markdown_decoration,
|
||||||
)
|
)
|
||||||
from . import InputPaidMediaPhoto, InputPaidMediaVideo
|
|
||||||
|
|
||||||
from ..client.default import Default
|
from ..client.default import Default
|
||||||
from ..enums import ContentType
|
from ..enums import ContentType
|
||||||
|
from . import InputPaidMediaPhoto, InputPaidMediaVideo
|
||||||
from .custom import DateTime
|
from .custom import DateTime
|
||||||
from .maybe_inaccessible_message import MaybeInaccessibleMessage
|
from .maybe_inaccessible_message import MaybeInaccessibleMessage
|
||||||
|
|
||||||
|
|
@ -38,6 +38,7 @@ if TYPE_CHECKING:
|
||||||
SendLocation,
|
SendLocation,
|
||||||
SendMediaGroup,
|
SendMediaGroup,
|
||||||
SendMessage,
|
SendMessage,
|
||||||
|
SendPaidMedia,
|
||||||
SendPhoto,
|
SendPhoto,
|
||||||
SendPoll,
|
SendPoll,
|
||||||
SendSticker,
|
SendSticker,
|
||||||
|
|
@ -48,7 +49,6 @@ if TYPE_CHECKING:
|
||||||
SetMessageReaction,
|
SetMessageReaction,
|
||||||
StopMessageLiveLocation,
|
StopMessageLiveLocation,
|
||||||
UnpinChatMessage,
|
UnpinChatMessage,
|
||||||
SendPaidMedia,
|
|
||||||
)
|
)
|
||||||
from .animation import Animation
|
from .animation import Animation
|
||||||
from .audio import Audio
|
from .audio import Audio
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@ from __future__ import annotations
|
||||||
|
|
||||||
from typing import TYPE_CHECKING, Any, List, Literal
|
from typing import TYPE_CHECKING, Any, List, Literal
|
||||||
|
|
||||||
from .paid_media import PaidMedia
|
|
||||||
from ..enums import PaidMediaType
|
from ..enums import PaidMediaType
|
||||||
|
from .paid_media import PaidMedia
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from .photo_size import PhotoSize
|
from .photo_size import PhotoSize
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@ from __future__ import annotations
|
||||||
|
|
||||||
from typing import TYPE_CHECKING, Any, Literal, Optional
|
from typing import TYPE_CHECKING, Any, Literal, Optional
|
||||||
|
|
||||||
from .paid_media import PaidMedia
|
|
||||||
from ..enums import PaidMediaType
|
from ..enums import PaidMediaType
|
||||||
|
from .paid_media import PaidMedia
|
||||||
|
|
||||||
|
|
||||||
class PaidMediaPreview(PaidMedia):
|
class PaidMediaPreview(PaidMedia):
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@ from __future__ import annotations
|
||||||
|
|
||||||
from typing import TYPE_CHECKING, Any, Literal
|
from typing import TYPE_CHECKING, Any, Literal
|
||||||
|
|
||||||
from .paid_media import PaidMedia
|
|
||||||
from ..enums import PaidMediaType
|
from ..enums import PaidMediaType
|
||||||
|
from .paid_media import PaidMedia
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from .video import Video
|
from .video import Video
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ from os import getenv
|
||||||
from typing import Any, Dict, Union
|
from typing import Any, Dict, Union
|
||||||
|
|
||||||
from aiohttp import web
|
from aiohttp import web
|
||||||
|
from finite_state_machine import form_router
|
||||||
|
|
||||||
from aiogram import Bot, Dispatcher, F, Router
|
from aiogram import Bot, Dispatcher, F, Router
|
||||||
from aiogram.client.session.aiohttp import AiohttpSession
|
from aiogram.client.session.aiohttp import AiohttpSession
|
||||||
|
|
@ -18,7 +19,6 @@ from aiogram.webhook.aiohttp_server import (
|
||||||
TokenBasedRequestHandler,
|
TokenBasedRequestHandler,
|
||||||
setup_application,
|
setup_application,
|
||||||
)
|
)
|
||||||
from finite_state_machine import form_router
|
|
||||||
|
|
||||||
main_router = Router()
|
main_router = Router()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,12 @@ import datetime
|
||||||
|
|
||||||
from aiogram.methods import SendPaidMedia
|
from aiogram.methods import SendPaidMedia
|
||||||
from aiogram.types import (
|
from aiogram.types import (
|
||||||
Message,
|
|
||||||
Chat,
|
Chat,
|
||||||
PaidMediaPhoto,
|
|
||||||
PaidMediaInfo,
|
|
||||||
PhotoSize,
|
|
||||||
InputPaidMediaPhoto,
|
InputPaidMediaPhoto,
|
||||||
|
Message,
|
||||||
|
PaidMediaInfo,
|
||||||
|
PaidMediaPhoto,
|
||||||
|
PhotoSize,
|
||||||
)
|
)
|
||||||
from tests.mocked_bot import MockedBot
|
from tests.mocked_bot import MockedBot
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ from aiogram.methods import (
|
||||||
SendLocation,
|
SendLocation,
|
||||||
SendMediaGroup,
|
SendMediaGroup,
|
||||||
SendMessage,
|
SendMessage,
|
||||||
|
SendPaidMedia,
|
||||||
SendPhoto,
|
SendPhoto,
|
||||||
SendPoll,
|
SendPoll,
|
||||||
SendSticker,
|
SendSticker,
|
||||||
|
|
@ -35,7 +36,6 @@ from aiogram.methods import (
|
||||||
StopMessageLiveLocation,
|
StopMessageLiveLocation,
|
||||||
TelegramMethod,
|
TelegramMethod,
|
||||||
UnpinChatMessage,
|
UnpinChatMessage,
|
||||||
SendPaidMedia,
|
|
||||||
)
|
)
|
||||||
from aiogram.types import (
|
from aiogram.types import (
|
||||||
UNSET_PARSE_MODE,
|
UNSET_PARSE_MODE,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue