classaiogram.types.sticker_set.StickerSet(conf: Optional[Dict[str, Any]] = None, **kwargs: Any)[source] Bases: TelegramObject This object represents a sticker set. Deserialize objectParameters conf – kwargs –
Mixins Downloadable classaiogram.types.mixins.Downloadable[source] Bases: object Mixin for filesasyncdownload(destination=None, timeout=30, chunk_size=65536, seek=True, make_dirs=True, *, destination_dir: Optional[Union[str, Path]] = None, destination_file: Optional[Union[str, Path, IOBase]] = None)[source] Download file At most one of these parameters can be used: :param destination_dir:, :param destination_file:Parameters destination – deprecated, use :param destination_dir: or :param destination_file: instead timeout – Integer chunk_size – Integer seek – Boolean – go to start of file when downloading is finished. make_dirs – Make dirs if not exist destination_dir – directory […]
Fields BaseField classaiogram.types.fields.BaseField(*, base=None, default=None, alias=None, on_change=None)[source] Bases: object Base field (prop) Init propParameters base – class for child element default – default value alias – alias name (for e.g. field ‘from’ has to be named ‘from_user’ as ‘from’ is a builtin Python keyword on_change – callback will be called when value is changed get_value(instance)[source] Get value for the current object instanceParameters instance –Returnsset_value(instance, value, parent=None)[source] Set […]
MetaTelegramObject classaiogram.types.base.MetaTelegramObject(name: str, bases: Tuple[Type], namespace: Dict[str, Any], **kwargs: Any)[source] Bases: type Metaclass for telegram objects TelegramObject classaiogram.types.base.TelegramObject(conf: Optional[Dict[str, Any]] = None, **kwargs: Any)[source] Bases: ContextInstanceMixin Abstract class for telegram objects Deserialize objectParameters conf – kwargs – propertyprops: Dict[str, BaseField] Get propsReturns dict with propspropertyprops_aliases: Dict[str, str] Get aliases for propsReturnspropertyvalues: Dict[str, Any] Get valuesReturnsclassmethodto_object(data: Dict[str, Any], conf: Optional[Dict[str, Any]] = None)→ T[source] Deserialize objectParameters data – conf – Returnsto_python()→ Dict[str, Any][source] Get object as JSON serializableReturnsclean()→ None[source] Remove empty valuesas_json()→ str[source] Get object as JSON stringReturns JSONReturn type striter_keys()→ Generator[Any, None, None][source] Iterate over keysReturnsiter_values()→ Generator[Any, None, None][source] […]
Bot object Low level API Subclass of this class used only for splitting network interface from all of API methods.classaiogram.bot.base.BaseBot(token: String, loop: Optional[Union[BaseEventLoop, AbstractEventLoop]] = None, connections_limit: Optional[Integer] = None, proxy: Optional[String] = None, proxy_auth: Optional[BasicAuth] = None, validate_token: Optional[Boolean] = True, parse_mode: Optional[String] = None, disable_web_page_preview: Optional[Boolean] = None, protect_content: Optional[Boolean] = None, timeout: Optional[Union[Integer, Float, ClientTimeout]] = None, server: TelegramAPIServer = TelegramAPIServer(base=’https://api.telegram.org/bot{token}/{method}’, file=’https://api.telegram.org/file/bot{token}/{path}’))[source] Bases: object Base class for bot. It’s raw bot. Instructions how to get Bot token is found here: https://core.telegram.org/bots#3-how-do-i-create-a-botParameters token (str) – token from @BotFather loop (Optional Union asyncio.BaseEventLoop, asyncio.AbstractEventLoop) – event loop connections_limit (int) – connections limit for aiohttp.ClientSession proxy (str) – […]
This update make breaking changes in aiogram API and drop backward capability with previous versions of framework. From this point aiogram supports only Python 3.7 and newer. Changelog Used contextvars instead of aiogram.utils.context; Implemented filters factory; Implemented new filters mechanism; Allowed to customize command prefix in CommandsFilter; Implemented mechanism of passing results from filters (as dicts) […]
Quick start Simple template At first you have to import all necessary modules import logging from aiogram import Bot, Dispatcher, executor, types Then you have to initialize bot and dispatcher instances. Bot token you can get from @BotFather API_TOKEN = 'BOT TOKEN HERE' # Configure logging logging.basicConfig(level=logging.INFO) # Initialize bot and dispatcher bot = Bot(token=API_TOKEN) dp […]
Using PIP $ pip install -U aiogram Using Pipenv $ pipenv install aiogram Using Pacman aiogram is also available in Arch Linux Repository, so you can install this framework on any Arch-based distribution like Arch Linux, Antergos, Manjaro, etc. To do this, just use pacman to install the python-aiogram package: $ pacman -S python-aiogram From sources Development versions: […]