mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-09 17:33:44 +00:00
Rewrite Bot classes. Add moooooore pydocs.
This commit is contained in:
parent
a6e90655bc
commit
ffbb89100c
5 changed files with 2030 additions and 967 deletions
|
|
@ -86,12 +86,7 @@ def _compose_data(params=None, files=None):
|
|||
|
||||
if params:
|
||||
for key, value in params.items():
|
||||
# TODO: Normalize data in other place.
|
||||
if value.__class__ is dict:
|
||||
value = json.dumps(value)
|
||||
elif hasattr(value, 'to_json'):
|
||||
value = json.dumps(value.to_json())
|
||||
data.add_field(key, value)
|
||||
data.add_field(key, str(value))
|
||||
|
||||
if files:
|
||||
for key, f in files.items():
|
||||
|
|
|
|||
1550
aiogram/bot/base.py
1550
aiogram/bot/base.py
File diff suppressed because it is too large
Load diff
1405
aiogram/bot/bot.py
1405
aiogram/bot/bot.py
File diff suppressed because it is too large
Load diff
|
|
@ -47,7 +47,10 @@ from .video_note import VideoNote
|
|||
from .voice import Voice
|
||||
from .webhook_info import WebhookInfo
|
||||
|
||||
from . import base
|
||||
|
||||
__all__ = [
|
||||
'base',
|
||||
'Animation',
|
||||
'Audio',
|
||||
'CallbackQuery',
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
from aiogram.utils import json
|
||||
|
||||
DEFAULT_FILTER = ['self']
|
||||
|
||||
|
||||
|
|
@ -8,3 +10,11 @@ def generate_payload(exclude=None, **kwargs):
|
|||
key not in exclude + DEFAULT_FILTER
|
||||
and value
|
||||
and not key.startswith('_')}
|
||||
|
||||
|
||||
def prepare_arg(value):
|
||||
if isinstance(value, (list, dict)):
|
||||
return json.dumps(value)
|
||||
elif hasattr(value, 'to_json'):
|
||||
return json.dumps(value.to_json())
|
||||
return value
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue