diff --git a/tgram/bound/__init__.py b/tgram/bound/__init__.py index a6dcb25..a378105 100644 --- a/tgram/bound/__init__.py +++ b/tgram/bound/__init__.py @@ -1,9 +1,14 @@ -from .message import MessageB from .callback_query import CallbackB -from .user import UserB +from .chat_join_request import ChatJoinRequestB +from .chat_member_updated import ChatMemberUpdatedB from .chat import ChatB +from .chosen_inline_result import ChosenInlineResultB from .inline_query import InlineQueryB +from .message import MessageB +from .paid_media_purchased import PaidMediaPurchasedB from .pre_checkout_query import PreCheckoutQueryB +from .shipping_query import ShippingQueryB +from .user import UserB from tgram import sync @@ -15,10 +20,15 @@ sync.wrap(obj) __all__ = [ - "MessageB", "CallbackB", - "UserB", + "ChatJoinRequestB", + "ChatMemberUpdatedB", "ChatB", + "ChosenInlineResultB", "InlineQueryB", + "MessageB", + "PaidMediaPurchasedB", "PreCheckoutQueryB", + "ShippingQueryB", + "UserB", ] diff --git a/tgram/bound/callback_query.py b/tgram/bound/callback_query.py index 9b6921d..efebe65 100644 --- a/tgram/bound/callback_query.py +++ b/tgram/bound/callback_query.py @@ -1,6 +1,6 @@ import tgram -from typing import List, Union +from typing import List, Union, Optional class CallbackB: @@ -113,3 +113,9 @@ async def edit_message_live_location( proximity_alert_radius=proximity_alert_radius, reply_markup=reply_markup, ) + + @property + def user(self: "tgram.types.CallbackQuery") -> Optional["tgram.types.User"]: + return self.from_user + + sender_user = user diff --git a/tgram/bound/chat_join_request.py b/tgram/bound/chat_join_request.py new file mode 100644 index 0000000..1f187f8 --- /dev/null +++ b/tgram/bound/chat_join_request.py @@ -0,0 +1,11 @@ +import tgram + +from typing import Optional + + +class ChatJoinRequestB: + @property + def user(self: "tgram.types.ChatJoinRequest") -> Optional["tgram.types.User"]: + return self.from_user + + sender_user = user diff --git a/tgram/bound/chat_member_updated.py b/tgram/bound/chat_member_updated.py new file mode 100644 index 0000000..50ac415 --- /dev/null +++ b/tgram/bound/chat_member_updated.py @@ -0,0 +1,11 @@ +import tgram + +from typing import Optional + + +class ChatMemberUpdatedB: + @property + def user(self: "tgram.types.ChatMemberUpdated") -> Optional["tgram.types.User"]: + return self.from_user + + sender_user = user diff --git a/tgram/bound/chosen_inline_result.py b/tgram/bound/chosen_inline_result.py new file mode 100644 index 0000000..1b3ec58 --- /dev/null +++ b/tgram/bound/chosen_inline_result.py @@ -0,0 +1,11 @@ +import tgram + +from typing import Optional + + +class ChosenInlineResultB: + @property + def user(self: "tgram.types.ChosenInlineResult") -> Optional["tgram.types.User"]: + return self.from_user + + sender_user = user diff --git a/tgram/bound/inline_query.py b/tgram/bound/inline_query.py index de63cc2..1529c50 100644 --- a/tgram/bound/inline_query.py +++ b/tgram/bound/inline_query.py @@ -1,6 +1,6 @@ import tgram -from typing import List +from typing import List, Optional class InlineQueryB: @@ -20,3 +20,9 @@ async def answer( next_offset=next_offset, button=button, ) + + @property + def user(self: "tgram.types.InlineQuery") -> Optional["tgram.types.User"]: + return self.from_user + + sender_user = user diff --git a/tgram/bound/message.py b/tgram/bound/message.py index 3032111..3aab6af 100644 --- a/tgram/bound/message.py +++ b/tgram/bound/message.py @@ -927,6 +927,12 @@ def link(self: "tgram.types.Message") -> Optional[str]: else None ) + @property + def user(self: "tgram.types.Message") -> Optional["tgram.types.User"]: + return self.from_user + + sender_user = user + @property def __reply_param(self) -> "tgram.types.ReplyParameters": return tgram.types.ReplyParameters(self.id, allow_sending_without_reply=True) diff --git a/tgram/bound/paid_media_purchased.py b/tgram/bound/paid_media_purchased.py new file mode 100644 index 0000000..3a3ea79 --- /dev/null +++ b/tgram/bound/paid_media_purchased.py @@ -0,0 +1,11 @@ +import tgram + +from typing import Optional + + +class PaidMediaPurchasedB: + @property + def user(self: "tgram.types.PaidMediaPurchased") -> Optional["tgram.types.User"]: + return self.from_user + + sender_user = user diff --git a/tgram/bound/pre_checkout_query.py b/tgram/bound/pre_checkout_query.py index e5a557b..1815e5f 100644 --- a/tgram/bound/pre_checkout_query.py +++ b/tgram/bound/pre_checkout_query.py @@ -1,5 +1,7 @@ import tgram +from typing import Optional + class PreCheckoutQueryB: async def answer( @@ -10,3 +12,9 @@ async def answer( return await self._me.answer_pre_checkout_query( pre_checkout_query_id=self.id, ok=ok, error_message=error_message ) + + @property + def user(self: "tgram.types.PreCheckoutQuery") -> Optional["tgram.types.User"]: + return self.from_user + + sender_user = user diff --git a/tgram/bound/shipping_query.py b/tgram/bound/shipping_query.py new file mode 100644 index 0000000..8835246 --- /dev/null +++ b/tgram/bound/shipping_query.py @@ -0,0 +1,11 @@ +import tgram + +from typing import Optional + + +class ShippingQueryB: + @property + def user(self: "tgram.types.ShippingQuery") -> Optional["tgram.types.User"]: + return self.from_user + + sender_user = user diff --git a/tgram/types/_chat_join_request.py b/tgram/types/_chat_join_request.py index e589982..c16c073 100644 --- a/tgram/types/_chat_join_request.py +++ b/tgram/types/_chat_join_request.py @@ -2,9 +2,10 @@ from .type_ import Type_ from typing import Optional +from tgram import bound -class ChatJoinRequest(Type_): +class ChatJoinRequest(Type_, bound.ChatJoinRequestB): """ Represents a join request sent to a chat. diff --git a/tgram/types/_chat_member_updated.py b/tgram/types/_chat_member_updated.py index 1246ddc..0114a56 100644 --- a/tgram/types/_chat_member_updated.py +++ b/tgram/types/_chat_member_updated.py @@ -3,8 +3,10 @@ from typing import Union, Optional +from tgram import bound -class ChatMemberUpdated(Type_): + +class ChatMemberUpdated(Type_, bound.ChatMemberUpdatedB): """ This object represents changes in the status of a chat member. diff --git a/tgram/types/_chosen_inline_result.py b/tgram/types/_chosen_inline_result.py index 34fd09b..00c0af9 100644 --- a/tgram/types/_chosen_inline_result.py +++ b/tgram/types/_chosen_inline_result.py @@ -3,8 +3,10 @@ from typing import Optional +from tgram import bound -class ChosenInlineResult(Type_): + +class ChosenInlineResult(Type_, bound.ChosenInlineResultB): """ Represents a result of an inline query that was chosen by the user and sent to their chat partner. diff --git a/tgram/types/_paid_media_purchased.py b/tgram/types/_paid_media_purchased.py index 82c46ba..82b6070 100644 --- a/tgram/types/_paid_media_purchased.py +++ b/tgram/types/_paid_media_purchased.py @@ -4,8 +4,10 @@ from typing import Optional +from tgram import bound -class PaidMediaPurchased(Type_): + +class PaidMediaPurchased(Type_, bound.PaidMediaPurchasedB): """ This object contains information about a paid media purchase. diff --git a/tgram/types/_shipping_query.py b/tgram/types/_shipping_query.py index 593f1b3..20cb70f 100644 --- a/tgram/types/_shipping_query.py +++ b/tgram/types/_shipping_query.py @@ -2,9 +2,10 @@ from .type_ import Type_ from typing import Optional +from tgram import bound -class ShippingQuery(Type_): +class ShippingQuery(Type_, bound.ShippingQueryB): """ This object contains information about an incoming shipping query.