mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-17 20:43:25 +00:00
Remove bot entity from types.
This commit is contained in:
parent
4fce1cefe6
commit
4f7bdfa885
3 changed files with 11 additions and 18 deletions
|
|
@ -18,16 +18,6 @@ class Deserializable:
|
||||||
All subclasses of this class must override de_json.
|
All subclasses of this class must override de_json.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@property
|
|
||||||
def bot(self):
|
|
||||||
if not hasattr(self, '_bot'):
|
|
||||||
raise AttributeError('object is not configured for bot.')
|
|
||||||
return getattr(self, '_bot')
|
|
||||||
|
|
||||||
@bot.setter
|
|
||||||
def bot(self, bot):
|
|
||||||
setattr(self, '_bot', bot)
|
|
||||||
|
|
||||||
def to_json(self):
|
def to_json(self):
|
||||||
return getattr(self, 'data', {})
|
return getattr(self, 'data', {})
|
||||||
|
|
||||||
|
|
@ -42,7 +32,7 @@ class Deserializable:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def check_json(data):
|
def check_json(data) -> dict:
|
||||||
"""
|
"""
|
||||||
Checks whether json_type is a dict or a string. If it is already a dict, it is returned as-is.
|
Checks whether json_type is a dict or a string. If it is already a dict, it is returned as-is.
|
||||||
If it is not, it is converted to a dict by means of json.loads(json_type)
|
If it is not, it is converted to a dict by means of json.loads(json_type)
|
||||||
|
|
@ -59,3 +49,6 @@ class Deserializable:
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return json.dumps(self.to_json())
|
return json.dumps(self.to_json())
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return str(self)
|
||||||
|
|
|
||||||
|
|
@ -40,9 +40,6 @@ class Chat(Deserializable):
|
||||||
|
|
||||||
return Chat(data, id, type, title, username, first_name, last_name, all_members_are_administrators)
|
return Chat(data, id, type, title, username, first_name, last_name, all_members_are_administrators)
|
||||||
|
|
||||||
async def send_message(self, text):
|
|
||||||
self.bot.send_message(self.id, text)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def full_name(self):
|
def full_name(self):
|
||||||
if self.type == ChatType.PRIVATE:
|
if self.type == ChatType.PRIVATE:
|
||||||
|
|
|
||||||
|
|
@ -3,15 +3,18 @@ from aiogram.types.message import Message
|
||||||
|
|
||||||
|
|
||||||
class Update(Deserializable):
|
class Update(Deserializable):
|
||||||
|
__slots__ = ('update_id', 'message', 'edited_message', 'channel_post', 'edited_channel_post', 'inline_query',
|
||||||
|
'chosen_inline_result', 'callback_query', 'shipping_query', 'pre_checkout_query')
|
||||||
|
|
||||||
def __init__(self, data, update_id, message, edited_message, channel_post, edited_channel_post, inline_query,
|
def __init__(self, data, update_id, message, edited_message, channel_post, edited_channel_post, inline_query,
|
||||||
chosen_inline_result, callback_query, shipping_query, pre_checkout_query):
|
chosen_inline_result, callback_query, shipping_query, pre_checkout_query):
|
||||||
self.data = data
|
self.data = data
|
||||||
|
|
||||||
self.update_id = update_id
|
self.update_id = update_id
|
||||||
self.message = message
|
self.message: Message = message
|
||||||
self.edited_message = edited_message
|
self.edited_message: Message = edited_message
|
||||||
self.channel_post = channel_post
|
self.channel_post: Message = channel_post
|
||||||
self.edited_channel_post = edited_channel_post
|
self.edited_channel_post: Message = edited_channel_post
|
||||||
self.inline_query = inline_query
|
self.inline_query = inline_query
|
||||||
self.chosen_inline_result = chosen_inline_result
|
self.chosen_inline_result = chosen_inline_result
|
||||||
self.callback_query = callback_query
|
self.callback_query = callback_query
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue