Reformat code.

This commit is contained in:
Alex Root Junior 2017-08-14 22:34:13 +03:00
parent b7bf22bb77
commit 92d3d86a18
42 changed files with 73 additions and 10 deletions

View file

@ -1,6 +1,5 @@
from .utils.versions import Version, Stage
from .bot import Bot from .bot import Bot
from .utils.versions import Version, Stage
VERSION = Version(0, 3, 5, stage=Stage.DEV, build=0) VERSION = Version(0, 3, 5, stage=Stage.DEV, build=0)

View file

@ -1,6 +1,6 @@
import typing import typing
from aiogram.dispatcher import BaseStorage from ...dispatcher import BaseStorage
class MemoryStorage(BaseStorage): class MemoryStorage(BaseStorage):

View file

@ -7,8 +7,8 @@ import typing
import aioredis import aioredis
from aiogram.utils import json
from ...dispatcher.storage import BaseStorage from ...dispatcher.storage import BaseStorage
from ...utils import json
class RedisStorage(BaseStorage): class RedisStorage(BaseStorage):

View file

@ -27,7 +27,7 @@ class Dispatcher:
if storage is None: if storage is None:
storage = DisabledStorage() storage = DisabledStorage()
self.bot: 'Bot' = bot self.bot: Bot = bot
self.loop = loop self.loop = loop
self.storage = storage self.storage = storage

View file

@ -104,6 +104,7 @@ class BaseResponse:
""" """
Base class for webhook responses. Base class for webhook responses.
""" """
@property @property
def method(self) -> str: def method(self) -> str:
""" """

View file

@ -1,3 +1,4 @@
from . import base
from .animation import Animation from .animation import Animation
from .audio import Audio from .audio import Audio
from .callback_query import CallbackQuery from .callback_query import CallbackQuery
@ -48,8 +49,6 @@ from .video_note import VideoNote
from .voice import Voice from .voice import Voice
from .webhook_info import WebhookInfo from .webhook_info import WebhookInfo
from . import base
__all__ = [ __all__ = [
'base', 'base',
'Animation', 'Animation',

View file

@ -9,6 +9,7 @@ class Animation(Deserializable):
https://core.telegram.org/bots/api#animation https://core.telegram.org/bots/api#animation
""" """
def __init__(self, file_id, thumb, file_name, mime_type, file_size): def __init__(self, file_id, thumb, file_name, mime_type, file_size):
self.file_id: str = file_id self.file_id: str = file_id
self.thumb: PhotoSize = thumb self.thumb: PhotoSize = thumb

View file

@ -7,6 +7,7 @@ class Audio(Deserializable):
https://core.telegram.org/bots/api#audio https://core.telegram.org/bots/api#audio
""" """
def __init__(self, file_id, duration, performer, title, mime_type, file_size): def __init__(self, file_id, duration, performer, title, mime_type, file_size):
self.file_id: str = file_id self.file_id: str = file_id
self.duration: int = duration self.duration: int = duration

View file

@ -17,6 +17,7 @@ class CallbackQuery(Deserializable):
https://core.telegram.org/bots/api#callbackquery https://core.telegram.org/bots/api#callbackquery
""" """
def __init__(self, id, from_user, message, inline_message_id, chat_instance, data, game_short_name): def __init__(self, id, from_user, message, inline_message_id, chat_instance, data, game_short_name):
self.id: int = id self.id: int = id
self.from_user: User = from_user self.from_user: User = from_user

View file

@ -9,6 +9,7 @@ class ChosenInlineResult(Deserializable):
https://core.telegram.org/bots/api#choseninlineresult https://core.telegram.org/bots/api#choseninlineresult
""" """
def __init__(self, result_id, from_user, location, inline_message_id, query): def __init__(self, result_id, from_user, location, inline_message_id, query):
self.result_id: str = result_id self.result_id: str = result_id
self.from_user: User = from_user self.from_user: User = from_user

View file

@ -7,6 +7,7 @@ class Contact(Deserializable):
https://core.telegram.org/bots/api#contact https://core.telegram.org/bots/api#contact
""" """
def __init__(self, phone_number, first_name, last_name, user_id): def __init__(self, phone_number, first_name, last_name, user_id):
self.phone_number: str = phone_number self.phone_number: str = phone_number
self.first_name: str = first_name self.first_name: str = first_name

View file

@ -8,6 +8,7 @@ class Document(Deserializable):
https://core.telegram.org/bots/api#document https://core.telegram.org/bots/api#document
""" """
def __init__(self, file_id, thumb, file_name, mime_type, file_size): def __init__(self, file_id, thumb, file_name, mime_type, file_size):
self.file_id: str = file_id self.file_id: str = file_id
self.thumb: PhotoSize = thumb self.thumb: PhotoSize = thumb

View file

@ -12,6 +12,7 @@ class File(Deserializable):
https://core.telegram.org/bots/api#file https://core.telegram.org/bots/api#file
""" """
def __init__(self, file_id, file_size, file_path): def __init__(self, file_id, file_size, file_path):
self.file_id: str = file_id self.file_id: str = file_id
self.file_size: int = file_size self.file_size: int = file_size

View file

@ -12,6 +12,7 @@ class ForceReply(Serializable):
https://core.telegram.org/bots/api#forcereply https://core.telegram.org/bots/api#forcereply
""" """
def __init__(self, selective=None): def __init__(self, selective=None):
self.selective = selective self.selective = selective

View file

@ -12,6 +12,7 @@ class Game(Deserializable):
https://core.telegram.org/bots/api#game https://core.telegram.org/bots/api#game
""" """
def __init__(self, title, description, photo, text, text_entities, animation): def __init__(self, title, description, photo, text, text_entities, animation):
self.title = title self.title = title
self.description = description self.description = description

View file

@ -8,6 +8,7 @@ class GameHighScore(Deserializable):
https://core.telegram.org/bots/api#gamehighscore https://core.telegram.org/bots/api#gamehighscore
""" """
def __init__(self, position, user, score): def __init__(self, position, user, score):
self.position: int = position self.position: int = position
self.user: User = user self.user: User = user

View file

@ -7,6 +7,7 @@ class InlineKeyboardMarkup(Serializable):
https://core.telegram.org/bots/api#inlinekeyboardmarkup https://core.telegram.org/bots/api#inlinekeyboardmarkup
""" """
def __init__(self, row_width=3): def __init__(self, row_width=3):
self.row_width = row_width self.row_width = row_width
@ -41,6 +42,7 @@ class InlineKeyboardButton(Serializable):
https://core.telegram.org/bots/api#inlinekeyboardbutton https://core.telegram.org/bots/api#inlinekeyboardbutton
""" """
def __init__(self, text, url=None, callback_data=None, switch_inline_query=None, def __init__(self, text, url=None, callback_data=None, switch_inline_query=None,
switch_inline_query_current_chat=None, callback_game=None, pay=None): switch_inline_query_current_chat=None, callback_game=None, pay=None):
self.text = text self.text = text

View file

@ -11,6 +11,7 @@ class InlineQuery(Deserializable):
https://core.telegram.org/bots/api#inlinequery https://core.telegram.org/bots/api#inlinequery
""" """
def __init__(self, id, from_user, location, query, offset): def __init__(self, id, from_user, location, query, offset):
self.id: int = id self.id: int = id
self.from_user: User = from_user self.from_user: User = from_user

View file

@ -13,6 +13,7 @@ class InputMessageContent(Serializable):
:class:`aiogram.types.InputVenueMessageContent` :class:`aiogram.types.InputVenueMessageContent`
:class:`aiogram.types.InputContactMessageContent` :class:`aiogram.types.InputContactMessageContent`
""" """
def to_json(self): def to_json(self):
return {k: v.to_json() if hasattr(v, 'to_json') else v for k, v in self.__dict__.items() if return {k: v.to_json() if hasattr(v, 'to_json') else v for k, v in self.__dict__.items() if
v is not None and not k.startswith('_')} v is not None and not k.startswith('_')}
@ -74,6 +75,7 @@ class InlineQueryResultArticle(InlineQueryResult):
https://core.telegram.org/bots/api#inlinequeryresultarticle https://core.telegram.org/bots/api#inlinequeryresultarticle
""" """
def __init__(self, id: str, title: str, input_message_content: InputMessageContent, def __init__(self, id: str, title: str, input_message_content: InputMessageContent,
reply_markup: InlineKeyboardMarkup = None, url: str = None, hide_url: bool = None, reply_markup: InlineKeyboardMarkup = None, url: str = None, hide_url: bool = None,
description: str = None, thumb_url: str = None, thumb_width: int = None, thumb_height: int = None): description: str = None, thumb_url: str = None, thumb_width: int = None, thumb_height: int = None):
@ -99,6 +101,7 @@ class InlineQueryResultPhoto(InlineQueryResult):
https://core.telegram.org/bots/api#inlinequeryresultphoto https://core.telegram.org/bots/api#inlinequeryresultphoto
""" """
def __init__(self, id: str, photo_url: str, thumb_url: str, photo_width: int = None, def __init__(self, id: str, photo_url: str, thumb_url: str, photo_width: int = None,
photo_height: int = None, title: str = None, description: str = None, caption: str = None, photo_height: int = None, title: str = None, description: str = None, caption: str = None,
reply_markup: InlineKeyboardMarkup = None, input_message_content: InputMessageContent = None): reply_markup: InlineKeyboardMarkup = None, input_message_content: InputMessageContent = None):
@ -126,6 +129,7 @@ class InlineQueryResultGif(InlineQueryResult):
https://core.telegram.org/bots/api#inlinequeryresultgif https://core.telegram.org/bots/api#inlinequeryresultgif
""" """
def __init__(self, id: str, gif_url: str, thumb_url: str, gif_width: int = None, gif_height: int = None, def __init__(self, id: str, gif_url: str, thumb_url: str, gif_width: int = None, gif_height: int = None,
gif_duration: int = None, title: str = None, caption: str = None, gif_duration: int = None, title: str = None, caption: str = None,
reply_markup: InlineKeyboardMarkup = None, input_message_content: InputMessageContent = None): reply_markup: InlineKeyboardMarkup = None, input_message_content: InputMessageContent = None):
@ -153,6 +157,7 @@ class InlineQueryResultMpeg4Gif(InlineQueryResult):
https://core.telegram.org/bots/api#inlinequeryresultmpeg4gif https://core.telegram.org/bots/api#inlinequeryresultmpeg4gif
""" """
def __init__(self, id: str, mpeg4_url: str, thumb_url: str, mpeg4_width: int = None, def __init__(self, id: str, mpeg4_url: str, thumb_url: str, mpeg4_width: int = None,
mpeg4_height: int = None, mpeg4_duration: int = None, title: str = None, caption: str = None, mpeg4_height: int = None, mpeg4_duration: int = None, title: str = None, caption: str = None,
reply_markup: InlineKeyboardMarkup = None, input_message_content: InputMessageContent = None): reply_markup: InlineKeyboardMarkup = None, input_message_content: InputMessageContent = None):
@ -178,6 +183,7 @@ class InlineQueryResultVideo(InlineQueryResult):
https://core.telegram.org/bots/api#inlinequeryresultvideo https://core.telegram.org/bots/api#inlinequeryresultvideo
""" """
def __init__(self, id: str, video_url: str, mime_type: str, thumb_url: str, title: str, def __init__(self, id: str, video_url: str, mime_type: str, thumb_url: str, title: str,
caption: str = None, video_width: int = None, video_height: int = None, video_duration: int = None, caption: str = None, video_width: int = None, video_height: int = None, video_duration: int = None,
description: str = None, reply_markup: InlineKeyboardMarkup = None, description: str = None, reply_markup: InlineKeyboardMarkup = None,
@ -204,6 +210,7 @@ class InlineQueryResultAudio(InlineQueryResult):
https://core.telegram.org/bots/api#inlinequeryresultaudio https://core.telegram.org/bots/api#inlinequeryresultaudio
""" """
def __init__(self, id: str, audio_url: str, title: str, caption: str = None, performer: str = None, def __init__(self, id: str, audio_url: str, title: str, caption: str = None, performer: str = None,
audio_duration: int = None, reply_markup: InlineKeyboardMarkup = None, audio_duration: int = None, reply_markup: InlineKeyboardMarkup = None,
input_message_content: InputMessageContent = None): input_message_content: InputMessageContent = None):
@ -229,6 +236,7 @@ class InlineQueryResultVoice(InlineQueryResult):
https://core.telegram.org/bots/api#inlinequeryresultvoice https://core.telegram.org/bots/api#inlinequeryresultvoice
""" """
def __init__(self, id: str, voice_url: str, title: str, caption: str = None, voice_duration: int = None, def __init__(self, id: str, voice_url: str, title: str, caption: str = None, voice_duration: int = None,
reply_markup: InlineKeyboardMarkup = None, input_message_content: InputMessageContent = None): reply_markup: InlineKeyboardMarkup = None, input_message_content: InputMessageContent = None):
self.type = 'voice' self.type = 'voice'
@ -250,6 +258,7 @@ class InlineQueryResultDocument(InlineQueryResult):
https://core.telegram.org/bots/api#inlinequeryresultdocument https://core.telegram.org/bots/api#inlinequeryresultdocument
""" """
def __init__(self, id: str, title: str, document_url: str, mime_type: str, caption: str = None, def __init__(self, id: str, title: str, document_url: str, mime_type: str, caption: str = None,
description: str = None, reply_markup: InlineKeyboardMarkup = None, description: str = None, reply_markup: InlineKeyboardMarkup = None,
input_message_content: InputMessageContent = None, thumb_url: str = None, thumb_width: int = None, input_message_content: InputMessageContent = None, thumb_url: str = None, thumb_width: int = None,
@ -276,6 +285,7 @@ class InlineQueryResultLocation(InlineQueryResult):
https://core.telegram.org/bots/api#inlinequeryresultlocation https://core.telegram.org/bots/api#inlinequeryresultlocation
""" """
def __init__(self, id: str, latitude: float, longitude: float, title: str, def __init__(self, id: str, latitude: float, longitude: float, title: str,
reply_markup: InlineKeyboardMarkup = None, input_message_content: InputMessageContent = None, reply_markup: InlineKeyboardMarkup = None, input_message_content: InputMessageContent = None,
thumb_url: str = None, thumb_width: int = None, thumb_height: int = None): thumb_url: str = None, thumb_width: int = None, thumb_height: int = None):
@ -299,6 +309,7 @@ class InlineQueryResultVenue(InlineQueryResult):
https://core.telegram.org/bots/api#inlinequeryresultvenue https://core.telegram.org/bots/api#inlinequeryresultvenue
""" """
def __init__(self, id: str, latitude: float, longitude: float, title: str, address: str, def __init__(self, id: str, latitude: float, longitude: float, title: str, address: str,
foursquare_id: str = None, reply_markup: InlineKeyboardMarkup = None, foursquare_id: str = None, reply_markup: InlineKeyboardMarkup = None,
input_message_content: InputMessageContent = None, thumb_url: str = None, thumb_width: int = None, input_message_content: InputMessageContent = None, thumb_url: str = None, thumb_width: int = None,
@ -328,6 +339,7 @@ class InlineQueryResultContact(InlineQueryResult):
https://core.telegram.org/bots/api#inlinequeryresultcontact https://core.telegram.org/bots/api#inlinequeryresultcontact
""" """
def __init__(self, id: str, phone_number: str, first_name: str, last_name: str = None, def __init__(self, id: str, phone_number: str, first_name: str, last_name: str = None,
reply_markup: InlineKeyboardMarkup = None, input_message_content: InputMessageContent = None, reply_markup: InlineKeyboardMarkup = None, input_message_content: InputMessageContent = None,
thumb_url: str = None, thumb_width: int = None, thumb_height: int = None): thumb_url: str = None, thumb_width: int = None, thumb_height: int = None):
@ -349,6 +361,7 @@ class InlineQueryResultGame(InlineQueryResult):
https://core.telegram.org/bots/api#inlinequeryresultgame https://core.telegram.org/bots/api#inlinequeryresultgame
""" """
def __init__(self, id: str, game_short_name: str, reply_markup: InlineKeyboardMarkup = None): def __init__(self, id: str, game_short_name: str, reply_markup: InlineKeyboardMarkup = None):
self.type = 'game' self.type = 'game'
self.id: str = id self.id: str = id
@ -367,6 +380,7 @@ class InlineQueryResultCachedPhoto(InlineQueryResult):
https://core.telegram.org/bots/api#inlinequeryresultcachedphoto https://core.telegram.org/bots/api#inlinequeryresultcachedphoto
""" """
def __init__(self, id: str, photo_file_id: str, title: str = None, description: str = None, def __init__(self, id: str, photo_file_id: str, title: str = None, description: str = None,
caption: str = None, reply_markup: InlineKeyboardMarkup = None, caption: str = None, reply_markup: InlineKeyboardMarkup = None,
input_message_content: InputMessageContent = None): input_message_content: InputMessageContent = None):
@ -391,6 +405,7 @@ class InlineQueryResultCachedGif(InlineQueryResult):
https://core.telegram.org/bots/api#inlinequeryresultcachedgif https://core.telegram.org/bots/api#inlinequeryresultcachedgif
""" """
def __init__(self, id: str, gif_file_id: str, title: str = None, caption: str = None, def __init__(self, id: str, gif_file_id: str, title: str = None, caption: str = None,
reply_markup: InlineKeyboardMarkup = None, input_message_content: InputMessageContent = None): reply_markup: InlineKeyboardMarkup = None, input_message_content: InputMessageContent = None):
self.type = 'gif' self.type = 'gif'
@ -413,6 +428,7 @@ class InlineQueryResultCachedMpeg4Gif(InlineQueryResult):
https://core.telegram.org/bots/api#inlinequeryresultcachedmpeg4gif https://core.telegram.org/bots/api#inlinequeryresultcachedmpeg4gif
""" """
def __init__(self, id: str, mpeg4_file_id: str, title: str = None, caption: str = None, def __init__(self, id: str, mpeg4_file_id: str, title: str = None, caption: str = None,
reply_markup: InlineKeyboardMarkup = None, input_message_content: InputMessageContent = None): reply_markup: InlineKeyboardMarkup = None, input_message_content: InputMessageContent = None):
self.type = 'mpeg4_gif' self.type = 'mpeg4_gif'
@ -435,6 +451,7 @@ class InlineQueryResultCachedSticker(InlineQueryResult):
https://core.telegram.org/bots/api#inlinequeryresultcachedsticker https://core.telegram.org/bots/api#inlinequeryresultcachedsticker
""" """
def __init__(self, id: str, sticker_file_id: str, reply_markup: InlineKeyboardMarkup = None, def __init__(self, id: str, sticker_file_id: str, reply_markup: InlineKeyboardMarkup = None,
input_message_content: InputMessageContent = None): input_message_content: InputMessageContent = None):
self.type = 'sticker' self.type = 'sticker'
@ -455,6 +472,7 @@ class InlineQueryResultCachedDocument(InlineQueryResult):
https://core.telegram.org/bots/api#inlinequeryresultcacheddocument https://core.telegram.org/bots/api#inlinequeryresultcacheddocument
""" """
def __init__(self, id: str, title: str, document_file_id: str, description: str = None, def __init__(self, id: str, title: str, document_file_id: str, description: str = None,
caption: str = None, reply_markup: InlineKeyboardMarkup = None, caption: str = None, reply_markup: InlineKeyboardMarkup = None,
input_message_content: InputMessageContent = None): input_message_content: InputMessageContent = None):
@ -477,6 +495,7 @@ class InlineQueryResultCachedVideo(InlineQueryResult):
https://core.telegram.org/bots/api#inlinequeryresultcachedvideo https://core.telegram.org/bots/api#inlinequeryresultcachedvideo
""" """
def __init__(self, id: str, video_file_id: str, title: str, description: str = None, caption: str = None, def __init__(self, id: str, video_file_id: str, title: str, description: str = None, caption: str = None,
reply_markup: InlineKeyboardMarkup = None, input_message_content: InputMessageContent = None): reply_markup: InlineKeyboardMarkup = None, input_message_content: InputMessageContent = None):
self.type = 'video' self.type = 'video'
@ -500,6 +519,7 @@ class InlineQueryResultCachedVoice(InlineQueryResult):
https://core.telegram.org/bots/api#inlinequeryresultcachedvoice https://core.telegram.org/bots/api#inlinequeryresultcachedvoice
""" """
def __init__(self, id: str, voice_file_id: str, title: str, caption: str = None, def __init__(self, id: str, voice_file_id: str, title: str, caption: str = None,
reply_markup: InlineKeyboardMarkup = None, input_message_content: InputMessageContent = None): reply_markup: InlineKeyboardMarkup = None, input_message_content: InputMessageContent = None):
self.type = 'voice' self.type = 'voice'
@ -521,6 +541,7 @@ class InlineQueryResultCachedAudio(InlineQueryResult):
https://core.telegram.org/bots/api#inlinequeryresultcachedaudio https://core.telegram.org/bots/api#inlinequeryresultcachedaudio
""" """
def __init__(self, id: str, audio_file_id: str, caption: str = None, def __init__(self, id: str, audio_file_id: str, caption: str = None,
reply_markup: InlineKeyboardMarkup = None, input_message_content: InputMessageContent = None): reply_markup: InlineKeyboardMarkup = None, input_message_content: InputMessageContent = None):
self.type = 'audio' self.type = 'audio'
@ -537,6 +558,7 @@ class InputTextMessageContent(InputMessageContent):
https://core.telegram.org/bots/api#inputtextmessagecontent https://core.telegram.org/bots/api#inputtextmessagecontent
""" """
def __init__(self, message_text: str, parse_mode: str = None, disable_web_page_preview: bool = None): def __init__(self, message_text: str, parse_mode: str = None, disable_web_page_preview: bool = None):
self.message_text: str = message_text self.message_text: str = message_text
self.parse_mode: str = parse_mode self.parse_mode: str = parse_mode
@ -549,6 +571,7 @@ class InputLocationMessageContent(InputMessageContent):
https://core.telegram.org/bots/api#inputlocationmessagecontent https://core.telegram.org/bots/api#inputlocationmessagecontent
""" """
def __init__(self, latitude: float, longitude: float): def __init__(self, latitude: float, longitude: float):
self.latitude: float = latitude self.latitude: float = latitude
self.longitude: float = longitude self.longitude: float = longitude
@ -560,6 +583,7 @@ class InputVenueMessageContent(InputMessageContent):
https://core.telegram.org/bots/api#inputvenuemessagecontent https://core.telegram.org/bots/api#inputvenuemessagecontent
""" """
def __init__(self, latitude: float, longitude: float, title: str, address: str, foursquare_id: str = None): def __init__(self, latitude: float, longitude: float, title: str, address: str, foursquare_id: str = None):
self.latitude: float = latitude self.latitude: float = latitude
self.longitude: float = longitude self.longitude: float = longitude
@ -574,6 +598,7 @@ class InputContactMessageContent(InputMessageContent):
https://core.telegram.org/bots/api#inputcontactmessagecontent https://core.telegram.org/bots/api#inputcontactmessagecontent
""" """
def __init__(self, phone_number: str, first_name: str, last_name: str = None): def __init__(self, phone_number: str, first_name: str, last_name: str = None):
self.phone_number: str = phone_number self.phone_number: str = phone_number
self.first_name: str = first_name self.first_name: str = first_name

View file

@ -7,6 +7,7 @@ class Invoice(Deserializable):
https://core.telegram.org/bots/api#invoice https://core.telegram.org/bots/api#invoice
""" """
def __init__(self, title, description, start_parameter, currency, total_amount): def __init__(self, title, description, start_parameter, currency, total_amount):
self.title: str = title self.title: str = title
self.description: str = description self.description: str = description

View file

@ -7,6 +7,7 @@ class LabeledPrice(Serializable):
https://core.telegram.org/bots/api#labeledprice https://core.telegram.org/bots/api#labeledprice
""" """
def __init__(self, label, amount): def __init__(self, label, amount):
self.label = label self.label = label
self.amount = amount self.amount = amount

View file

@ -7,6 +7,7 @@ class Location(Deserializable):
https://core.telegram.org/bots/api#location https://core.telegram.org/bots/api#location
""" """
def __init__(self, longitude, latitude): def __init__(self, longitude, latitude):
self.longitude = longitude self.longitude = longitude
self.latitude = latitude self.latitude = latitude

View file

@ -8,6 +8,7 @@ class OrderInfo(Deserializable):
https://core.telegram.org/bots/api#orderinfo https://core.telegram.org/bots/api#orderinfo
""" """
def __init__(self, name, phone_number, email, shipping_address): def __init__(self, name, phone_number, email, shipping_address):
self.name: str = name self.name: str = name
self.phone_number: str = phone_number self.phone_number: str = phone_number

View file

@ -7,6 +7,7 @@ class PhotoSize(Deserializable):
https://core.telegram.org/bots/api#photosize https://core.telegram.org/bots/api#photosize
""" """
def __init__(self, file_id, width, height, file_size): def __init__(self, file_id, width, height, file_size):
self.file_id: str = file_id self.file_id: str = file_id
self.width: int = width self.width: int = width

View file

@ -9,6 +9,7 @@ class PreCheckoutQuery(Deserializable):
https://core.telegram.org/bots/api#precheckoutquery https://core.telegram.org/bots/api#precheckoutquery
""" """
def __init__(self, id, from_user, currency, total_amount, invoice_payload, shipping_option_id, order_info): def __init__(self, id, from_user, currency, total_amount, invoice_payload, shipping_option_id, order_info):
self.id: str = id self.id: str = id
self.from_user: User = from_user self.from_user: User = from_user

View file

@ -7,6 +7,7 @@ class ReplyKeyboardMarkup(Serializable):
https://core.telegram.org/bots/api#replykeyboardmarkup https://core.telegram.org/bots/api#replykeyboardmarkup
""" """
def __init__(self, resize_keyboard=None, one_time_keyboard=None, selective=None, row_width=3): def __init__(self, resize_keyboard=None, one_time_keyboard=None, selective=None, row_width=3):
self.resize_keyboard = resize_keyboard self.resize_keyboard = resize_keyboard
self.one_time_keyboard = one_time_keyboard self.one_time_keyboard = one_time_keyboard
@ -56,6 +57,7 @@ class KeyboardButton(Serializable):
https://core.telegram.org/bots/api#keyboardbutton https://core.telegram.org/bots/api#keyboardbutton
""" """
def __init__(self, text, request_contact=None, request_location=None): def __init__(self, text, request_contact=None, request_location=None):
self.text = text self.text = text
self.request_contact = request_contact self.request_contact = request_contact
@ -77,6 +79,7 @@ class ReplyKeyboardRemove(Serializable):
https://core.telegram.org/bots/api#replykeyboardremove https://core.telegram.org/bots/api#replykeyboardremove
""" """
def __init__(self, selective=None): def __init__(self, selective=None):
self.selective = selective self.selective = selective

View file

@ -7,6 +7,7 @@ class ResponseParameters(Deserializable):
https://core.telegram.org/bots/api#responseparameters https://core.telegram.org/bots/api#responseparameters
""" """
def __init__(self, migrate_to_chat_id, retry_after): def __init__(self, migrate_to_chat_id, retry_after):
self.migrate_to_chat_id = migrate_to_chat_id self.migrate_to_chat_id = migrate_to_chat_id
self.retry_after = retry_after self.retry_after = retry_after

View file

@ -7,6 +7,7 @@ class ShippingAddress(Deserializable):
https://core.telegram.org/bots/api#shippingaddress https://core.telegram.org/bots/api#shippingaddress
""" """
def __init__(self, country_code, state, city, street_line1, street_line2, post_code): def __init__(self, country_code, state, city, street_line1, street_line2, post_code):
self.country_code: str = country_code self.country_code: str = country_code
self.state: str = state self.state: str = state

View file

@ -7,6 +7,7 @@ class ShippingOption(Serializable):
https://core.telegram.org/bots/api#shippingoption https://core.telegram.org/bots/api#shippingoption
""" """
def __init__(self, id, title, prices): def __init__(self, id, title, prices):
self.id = id self.id = id
self.title = title self.title = title

View file

@ -9,6 +9,7 @@ class ShippingQuery(Deserializable):
https://core.telegram.org/bots/api#shippingquery https://core.telegram.org/bots/api#shippingquery
""" """
def __init__(self, id, from_user, invoice_payload, shipping_address): def __init__(self, id, from_user, invoice_payload, shipping_address):
self.id: str = id self.id: str = id
self.from_user: User = from_user self.from_user: User = from_user

View file

@ -1,6 +1,6 @@
from .base import Deserializable from .base import Deserializable
from .photo_size import PhotoSize
from .mask_position import MaskPosition from .mask_position import MaskPosition
from .photo_size import PhotoSize
class Sticker(Deserializable): class Sticker(Deserializable):

View file

@ -8,6 +8,7 @@ class SuccessfulPayment(Deserializable):
https://core.telegram.org/bots/api#successfulpayment https://core.telegram.org/bots/api#successfulpayment
""" """
def __init__(self, currency, total_amount, invoice_payload, shipping_option_id, order_info, def __init__(self, currency, total_amount, invoice_payload, shipping_option_id, order_info,
telegram_payment_charge_id, provider_payment_charge_id): telegram_payment_charge_id, provider_payment_charge_id):
self.currency: str = currency self.currency: str = currency

View file

@ -12,6 +12,7 @@ class User(Deserializable):
https://core.telegram.org/bots/api#user https://core.telegram.org/bots/api#user
""" """
def __init__(self, id, first_name, last_name, username, language_code): def __init__(self, id, first_name, last_name, username, language_code):
self.id: int = id self.id: int = id
self.first_name: str = first_name self.first_name: str = first_name

View file

@ -8,6 +8,7 @@ class UserProfilePhotos(Deserializable):
https://core.telegram.org/bots/api#userprofilephotos https://core.telegram.org/bots/api#userprofilephotos
""" """
def __init__(self, total_count, photos): def __init__(self, total_count, photos):
self.total_count: int = total_count self.total_count: int = total_count
self.photos: [PhotoSize] = photos self.photos: [PhotoSize] = photos

View file

@ -8,6 +8,7 @@ class Venue(Deserializable):
https://core.telegram.org/bots/api#venue https://core.telegram.org/bots/api#venue
""" """
def __init__(self, location, title, address, foursquare_id): def __init__(self, location, title, address, foursquare_id):
self.location: Location = location self.location: Location = location
self.title: str = title self.title: str = title

View file

@ -8,6 +8,7 @@ class Video(Deserializable):
https://core.telegram.org/bots/api#video https://core.telegram.org/bots/api#video
""" """
def __init__(self, file_id, width, height, duration, thumb, mime_type, file_size): def __init__(self, file_id, width, height, duration, thumb, mime_type, file_size):
self.file_id: str = file_id self.file_id: str = file_id
self.width: int = width self.width: int = width

View file

@ -8,6 +8,7 @@ class VideoNote(Deserializable):
https://core.telegram.org/bots/api#videonote https://core.telegram.org/bots/api#videonote
""" """
def __init__(self, file_id, length, duration, thumb, file_size): def __init__(self, file_id, length, duration, thumb, file_size):
self.file_id: str = file_id self.file_id: str = file_id
self.length: int = length self.length: int = length

View file

@ -7,6 +7,7 @@ class Voice(Deserializable):
https://core.telegram.org/bots/api#voice https://core.telegram.org/bots/api#voice
""" """
def __init__(self, file_id, duration, mime_type, file_size): def __init__(self, file_id, duration, mime_type, file_size):
self.file_id: str = file_id self.file_id: str = file_id
self.duration: int = duration self.duration: int = duration

View file

@ -1,5 +1,3 @@
import datetime
from .base import Deserializable from .base import Deserializable
@ -9,6 +7,7 @@ class WebhookInfo(Deserializable):
https://core.telegram.org/bots/api#webhookinfo https://core.telegram.org/bots/api#webhookinfo
""" """
def __init__(self, url, has_custom_certificate, pending_update_count, last_error_date, last_error_message, def __init__(self, url, has_custom_certificate, pending_update_count, last_error_date, last_error_message,
max_connections, allowed_updates): max_connections, allowed_updates):
self.url: str = url self.url: str = url

View file

@ -1,5 +1,9 @@
from .deprecated import warn_deprecated
try: try:
import emoji import emoji
warn_deprecated('Use emoji module instead that util')
except ImportError: except ImportError:
raise ImportError('Need install "emoji" module.') raise ImportError('Need install "emoji" module.')

View file

@ -1,8 +1,10 @@
try: try:
import ujson as json import ujson as json
IS_UJSON = True IS_UJSON = True
except ImportError: except ImportError:
import json import json
IS_UJSON = False IS_UJSON = False

View file

@ -4,6 +4,7 @@ import subprocess
from .helper import Helper, HelperMode, Item from .helper import Helper, HelperMode, Item
# Based on https://github.com/django/django/blob/master/django/utils/version.py # Based on https://github.com/django/django/blob/master/django/utils/version.py