repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
aiogram/aiogram | aiogram/dispatcher/storage.py | BaseStorage.get_bucket | async def get_bucket(self, *,
chat: typing.Union[str, int, None] = None,
user: typing.Union[str, int, None] = None,
default: typing.Optional[dict] = None) -> typing.Dict:
"""
Get bucket for user in chat. Return `default` if no da... | python | async def get_bucket(self, *,
chat: typing.Union[str, int, None] = None,
user: typing.Union[str, int, None] = None,
default: typing.Optional[dict] = None) -> typing.Dict:
"""
Get bucket for user in chat. Return `default` if no da... | [
"async",
"def",
"get_bucket",
"(",
"self",
",",
"*",
",",
"chat",
":",
"typing",
".",
"Union",
"[",
"str",
",",
"int",
",",
"None",
"]",
"=",
"None",
",",
"user",
":",
"typing",
".",
"Union",
"[",
"str",
",",
"int",
",",
"None",
"]",
"=",
"None... | Get bucket for user in chat. Return `default` if no data is provided in storage.
Chat or user is always required. If one of them is not provided,
you have to set missing value based on the provided one.
:param chat:
:param user:
:param default:
:return: | [
"Get",
"bucket",
"for",
"user",
"in",
"chat",
".",
"Return",
"default",
"if",
"no",
"data",
"is",
"provided",
"in",
"storage",
"."
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/dispatcher/storage.py#L204-L219 | train |
aiogram/aiogram | aiogram/dispatcher/storage.py | BaseStorage.set_bucket | async def set_bucket(self, *,
chat: typing.Union[str, int, None] = None,
user: typing.Union[str, int, None] = None,
bucket: typing.Dict = None):
"""
Set bucket for user in chat
Chat or user is always required. If one of ... | python | async def set_bucket(self, *,
chat: typing.Union[str, int, None] = None,
user: typing.Union[str, int, None] = None,
bucket: typing.Dict = None):
"""
Set bucket for user in chat
Chat or user is always required. If one of ... | [
"async",
"def",
"set_bucket",
"(",
"self",
",",
"*",
",",
"chat",
":",
"typing",
".",
"Union",
"[",
"str",
",",
"int",
",",
"None",
"]",
"=",
"None",
",",
"user",
":",
"typing",
".",
"Union",
"[",
"str",
",",
"int",
",",
"None",
"]",
"=",
"None... | Set bucket for user in chat
Chat or user is always required. If one of them is not provided,
you have to set missing value based on the provided one.
:param chat:
:param user:
:param bucket: | [
"Set",
"bucket",
"for",
"user",
"in",
"chat"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/dispatcher/storage.py#L221-L235 | train |
aiogram/aiogram | aiogram/dispatcher/storage.py | BaseStorage.update_bucket | async def update_bucket(self, *,
chat: typing.Union[str, int, None] = None,
user: typing.Union[str, int, None] = None,
bucket: typing.Dict = None,
**kwargs):
"""
Update bucket for user in chat... | python | async def update_bucket(self, *,
chat: typing.Union[str, int, None] = None,
user: typing.Union[str, int, None] = None,
bucket: typing.Dict = None,
**kwargs):
"""
Update bucket for user in chat... | [
"async",
"def",
"update_bucket",
"(",
"self",
",",
"*",
",",
"chat",
":",
"typing",
".",
"Union",
"[",
"str",
",",
"int",
",",
"None",
"]",
"=",
"None",
",",
"user",
":",
"typing",
".",
"Union",
"[",
"str",
",",
"int",
",",
"None",
"]",
"=",
"N... | Update bucket for user in chat
You can use bucket parameter or|and kwargs.
Chat or user is always required. If one of them is not provided,
you have to set missing value based on the provided one.
:param bucket:
:param chat:
:param user:
:param kwargs:
... | [
"Update",
"bucket",
"for",
"user",
"in",
"chat"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/dispatcher/storage.py#L237-L256 | train |
aiogram/aiogram | aiogram/dispatcher/storage.py | BaseStorage.reset_bucket | async def reset_bucket(self, *,
chat: typing.Union[str, int, None] = None,
user: typing.Union[str, int, None] = None):
"""
Reset bucket dor user in chat.
Chat or user is always required. If one of them is not provided,
you have to se... | python | async def reset_bucket(self, *,
chat: typing.Union[str, int, None] = None,
user: typing.Union[str, int, None] = None):
"""
Reset bucket dor user in chat.
Chat or user is always required. If one of them is not provided,
you have to se... | [
"async",
"def",
"reset_bucket",
"(",
"self",
",",
"*",
",",
"chat",
":",
"typing",
".",
"Union",
"[",
"str",
",",
"int",
",",
"None",
"]",
"=",
"None",
",",
"user",
":",
"typing",
".",
"Union",
"[",
"str",
",",
"int",
",",
"None",
"]",
"=",
"No... | Reset bucket dor user in chat.
Chat or user is always required. If one of them is not provided,
you have to set missing value based on the provided one.
:param chat:
:param user:
:return: | [
"Reset",
"bucket",
"dor",
"user",
"in",
"chat",
"."
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/dispatcher/storage.py#L258-L271 | train |
aiogram/aiogram | aiogram/contrib/fsm_storage/rethinkdb.py | RethinkDBStorage.connect | async def connect(self) -> Connection:
"""
Get or create a connection.
"""
if self._conn is None:
self._conn = await r.connect(host=self._host,
port=self._port,
db=self._db,
... | python | async def connect(self) -> Connection:
"""
Get or create a connection.
"""
if self._conn is None:
self._conn = await r.connect(host=self._host,
port=self._port,
db=self._db,
... | [
"async",
"def",
"connect",
"(",
"self",
")",
"->",
"Connection",
":",
"if",
"self",
".",
"_conn",
"is",
"None",
":",
"self",
".",
"_conn",
"=",
"await",
"r",
".",
"connect",
"(",
"host",
"=",
"self",
".",
"_host",
",",
"port",
"=",
"self",
".",
"... | Get or create a connection. | [
"Get",
"or",
"create",
"a",
"connection",
"."
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/contrib/fsm_storage/rethinkdb.py#L59-L73 | train |
aiogram/aiogram | aiogram/types/input_media.py | MediaGroup.attach_many | def attach_many(self, *medias: typing.Union[InputMedia, typing.Dict]):
"""
Attach list of media
:param medias:
"""
for media in medias:
self.attach(media) | python | def attach_many(self, *medias: typing.Union[InputMedia, typing.Dict]):
"""
Attach list of media
:param medias:
"""
for media in medias:
self.attach(media) | [
"def",
"attach_many",
"(",
"self",
",",
"*",
"medias",
":",
"typing",
".",
"Union",
"[",
"InputMedia",
",",
"typing",
".",
"Dict",
"]",
")",
":",
"for",
"media",
"in",
"medias",
":",
"self",
".",
"attach",
"(",
"media",
")"
] | Attach list of media
:param medias: | [
"Attach",
"list",
"of",
"media"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/types/input_media.py#L209-L216 | train |
aiogram/aiogram | aiogram/dispatcher/filters/builtin.py | Command.validate | def validate(cls, full_config: Dict[str, Any]) -> Optional[Dict[str, Any]]:
"""
Validator for filters factory
From filters factory this filter can be registered with arguments:
- ``command``
- ``commands_prefix`` (will be passed as ``prefixes``)
- ``commands_ignore_m... | python | def validate(cls, full_config: Dict[str, Any]) -> Optional[Dict[str, Any]]:
"""
Validator for filters factory
From filters factory this filter can be registered with arguments:
- ``command``
- ``commands_prefix`` (will be passed as ``prefixes``)
- ``commands_ignore_m... | [
"def",
"validate",
"(",
"cls",
",",
"full_config",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
":",
"config",
"=",
"{",
"}",
"if",
"'commands'",
"in",
"full_config",
":",
"config",... | Validator for filters factory
From filters factory this filter can be registered with arguments:
- ``command``
- ``commands_prefix`` (will be passed as ``prefixes``)
- ``commands_ignore_mention`` (will be passed as ``ignore_mention``
:param full_config:
:return: con... | [
"Validator",
"for",
"filters",
"factory"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/dispatcher/filters/builtin.py#L55-L75 | train |
aiogram/aiogram | aiogram/dispatcher/filters/builtin.py | CommandStart.check | async def check(self, message: types.Message):
"""
If deep-linking is passed to the filter result of the matching will be passed as ``deep_link`` to the handler
:param message:
:return:
"""
check = await super(CommandStart, self).check(message)
if check and self... | python | async def check(self, message: types.Message):
"""
If deep-linking is passed to the filter result of the matching will be passed as ``deep_link`` to the handler
:param message:
:return:
"""
check = await super(CommandStart, self).check(message)
if check and self... | [
"async",
"def",
"check",
"(",
"self",
",",
"message",
":",
"types",
".",
"Message",
")",
":",
"check",
"=",
"await",
"super",
"(",
"CommandStart",
",",
"self",
")",
".",
"check",
"(",
"message",
")",
"if",
"check",
"and",
"self",
".",
"deep_link",
"i... | If deep-linking is passed to the filter result of the matching will be passed as ``deep_link`` to the handler
:param message:
:return: | [
"If",
"deep",
"-",
"linking",
"is",
"passed",
"to",
"the",
"filter",
"result",
"of",
"the",
"matching",
"will",
"be",
"passed",
"as",
"deep_link",
"to",
"the",
"handler"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/dispatcher/filters/builtin.py#L155-L173 | train |
aiogram/aiogram | aiogram/utils/parts.py | paginate | def paginate(data: typing.Iterable, page: int = 0, limit: int = 10) -> typing.Iterable:
"""
Slice data over pages
:param data: any iterable object
:type data: :obj:`typing.Iterable`
:param page: number of page
:type page: :obj:`int`
:param limit: items per page
:type limit: :obj:`int`
... | python | def paginate(data: typing.Iterable, page: int = 0, limit: int = 10) -> typing.Iterable:
"""
Slice data over pages
:param data: any iterable object
:type data: :obj:`typing.Iterable`
:param page: number of page
:type page: :obj:`int`
:param limit: items per page
:type limit: :obj:`int`
... | [
"def",
"paginate",
"(",
"data",
":",
"typing",
".",
"Iterable",
",",
"page",
":",
"int",
"=",
"0",
",",
"limit",
":",
"int",
"=",
"10",
")",
"->",
"typing",
".",
"Iterable",
":",
"return",
"data",
"[",
"page",
"*",
"limit",
":",
"page",
"*",
"lim... | Slice data over pages
:param data: any iterable object
:type data: :obj:`typing.Iterable`
:param page: number of page
:type page: :obj:`int`
:param limit: items per page
:type limit: :obj:`int`
:return: sliced object
:rtype: :obj:`typing.Iterable` | [
"Slice",
"data",
"over",
"pages"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/utils/parts.py#L46-L59 | train |
aiogram/aiogram | aiogram/bot/bot.py | Bot.download_file_by_id | async def download_file_by_id(self, file_id: base.String, destination=None,
timeout: base.Integer = 30, chunk_size: base.Integer = 65536,
seek: base.Boolean = True):
"""
Download file by file_id to destination
if You want to au... | python | async def download_file_by_id(self, file_id: base.String, destination=None,
timeout: base.Integer = 30, chunk_size: base.Integer = 65536,
seek: base.Boolean = True):
"""
Download file by file_id to destination
if You want to au... | [
"async",
"def",
"download_file_by_id",
"(",
"self",
",",
"file_id",
":",
"base",
".",
"String",
",",
"destination",
"=",
"None",
",",
"timeout",
":",
"base",
".",
"Integer",
"=",
"30",
",",
"chunk_size",
":",
"base",
".",
"Integer",
"=",
"65536",
",",
... | Download file by file_id to destination
if You want to automatically create destination (:class:`io.BytesIO`) use default
value of destination and handle result of this method.
:param file_id: str
:param destination: filename or instance of :class:`io.IOBase`. For e. g. :class:`io.Byte... | [
"Download",
"file",
"by",
"file_id",
"to",
"destination"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/bot/bot.py#L42-L60 | train |
aiogram/aiogram | aiogram/bot/bot.py | Bot.get_webhook_info | async def get_webhook_info(self) -> types.WebhookInfo:
"""
Use this method to get current webhook status. Requires no parameters.
If the bot is using getUpdates, will return an object with the url field empty.
Source: https://core.telegram.org/bots/api#getwebhookinfo
:return: ... | python | async def get_webhook_info(self) -> types.WebhookInfo:
"""
Use this method to get current webhook status. Requires no parameters.
If the bot is using getUpdates, will return an object with the url field empty.
Source: https://core.telegram.org/bots/api#getwebhookinfo
:return: ... | [
"async",
"def",
"get_webhook_info",
"(",
"self",
")",
"->",
"types",
".",
"WebhookInfo",
":",
"payload",
"=",
"generate_payload",
"(",
"*",
"*",
"locals",
"(",
")",
")",
"result",
"=",
"await",
"self",
".",
"request",
"(",
"api",
".",
"Methods",
".",
"... | Use this method to get current webhook status. Requires no parameters.
If the bot is using getUpdates, will return an object with the url field empty.
Source: https://core.telegram.org/bots/api#getwebhookinfo
:return: On success, returns a WebhookInfo object
:rtype: :obj:`types.Webhoo... | [
"Use",
"this",
"method",
"to",
"get",
"current",
"webhook",
"status",
".",
"Requires",
"no",
"parameters",
"."
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/bot/bot.py#L144-L158 | train |
aiogram/aiogram | aiogram/bot/bot.py | Bot.get_me | async def get_me(self) -> types.User:
"""
A simple method for testing your bot's auth token. Requires no parameters.
Source: https://core.telegram.org/bots/api#getme
:return: Returns basic information about the bot in form of a User object
:rtype: :obj:`types.User`
"""
... | python | async def get_me(self) -> types.User:
"""
A simple method for testing your bot's auth token. Requires no parameters.
Source: https://core.telegram.org/bots/api#getme
:return: Returns basic information about the bot in form of a User object
:rtype: :obj:`types.User`
"""
... | [
"async",
"def",
"get_me",
"(",
"self",
")",
"->",
"types",
".",
"User",
":",
"payload",
"=",
"generate_payload",
"(",
"*",
"*",
"locals",
"(",
")",
")",
"result",
"=",
"await",
"self",
".",
"request",
"(",
"api",
".",
"Methods",
".",
"GET_ME",
",",
... | A simple method for testing your bot's auth token. Requires no parameters.
Source: https://core.telegram.org/bots/api#getme
:return: Returns basic information about the bot in form of a User object
:rtype: :obj:`types.User` | [
"A",
"simple",
"method",
"for",
"testing",
"your",
"bot",
"s",
"auth",
"token",
".",
"Requires",
"no",
"parameters",
"."
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/bot/bot.py#L163-L175 | train |
aiogram/aiogram | aiogram/bot/bot.py | Bot.send_poll | async def send_poll(self, chat_id: typing.Union[base.Integer, base.String],
question: base.String,
options: typing.List[base.String],
disable_notification: typing.Optional[base.Boolean],
reply_to_message_id: typing.Union[bas... | python | async def send_poll(self, chat_id: typing.Union[base.Integer, base.String],
question: base.String,
options: typing.List[base.String],
disable_notification: typing.Optional[base.Boolean],
reply_to_message_id: typing.Union[bas... | [
"async",
"def",
"send_poll",
"(",
"self",
",",
"chat_id",
":",
"typing",
".",
"Union",
"[",
"base",
".",
"Integer",
",",
"base",
".",
"String",
"]",
",",
"question",
":",
"base",
".",
"String",
",",
"options",
":",
"typing",
".",
"List",
"[",
"base",... | Use this method to send a native poll. A native poll can't be sent to a private chat.
On success, the sent Message is returned.
:param chat_id: Unique identifier for the target chat
or username of the target channel (in the format @channelusername).
A native poll can't be sent t... | [
"Use",
"this",
"method",
"to",
"send",
"a",
"native",
"poll",
".",
"A",
"native",
"poll",
"can",
"t",
"be",
"sent",
"to",
"a",
"private",
"chat",
".",
"On",
"success",
"the",
"sent",
"Message",
"is",
"returned",
"."
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/bot/bot.py#L850-L885 | train |
aiogram/aiogram | aiogram/bot/bot.py | Bot.get_file | async def get_file(self, file_id: base.String) -> types.File:
"""
Use this method to get basic info about a file and prepare it for downloading.
For the moment, bots can download files of up to 20MB in size.
Note: This function may not preserve the original file name and MIME type.
... | python | async def get_file(self, file_id: base.String) -> types.File:
"""
Use this method to get basic info about a file and prepare it for downloading.
For the moment, bots can download files of up to 20MB in size.
Note: This function may not preserve the original file name and MIME type.
... | [
"async",
"def",
"get_file",
"(",
"self",
",",
"file_id",
":",
"base",
".",
"String",
")",
"->",
"types",
".",
"File",
":",
"payload",
"=",
"generate_payload",
"(",
"*",
"*",
"locals",
"(",
")",
")",
"result",
"=",
"await",
"self",
".",
"request",
"("... | Use this method to get basic info about a file and prepare it for downloading.
For the moment, bots can download files of up to 20MB in size.
Note: This function may not preserve the original file name and MIME type.
You should save the file's MIME type and name (if available) when the File obj... | [
"Use",
"this",
"method",
"to",
"get",
"basic",
"info",
"about",
"a",
"file",
"and",
"prepare",
"it",
"for",
"downloading",
".",
"For",
"the",
"moment",
"bots",
"can",
"download",
"files",
"of",
"up",
"to",
"20MB",
"in",
"size",
"."
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/bot/bot.py#L932-L950 | train |
aiogram/aiogram | aiogram/bot/bot.py | Bot.export_chat_invite_link | async def export_chat_invite_link(self, chat_id: typing.Union[base.Integer, base.String]) -> base.String:
"""
Use this method to generate a new invite link for a chat; any previously generated link is revoked.
The bot must be an administrator in the chat for this to work and must have the approp... | python | async def export_chat_invite_link(self, chat_id: typing.Union[base.Integer, base.String]) -> base.String:
"""
Use this method to generate a new invite link for a chat; any previously generated link is revoked.
The bot must be an administrator in the chat for this to work and must have the approp... | [
"async",
"def",
"export_chat_invite_link",
"(",
"self",
",",
"chat_id",
":",
"typing",
".",
"Union",
"[",
"base",
".",
"Integer",
",",
"base",
".",
"String",
"]",
")",
"->",
"base",
".",
"String",
":",
"payload",
"=",
"generate_payload",
"(",
"*",
"*",
... | Use this method to generate a new invite link for a chat; any previously generated link is revoked.
The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
Source: https://core.telegram.org/bots/api#exportchatinvitelink
:param chat_id: Unique i... | [
"Use",
"this",
"method",
"to",
"generate",
"a",
"new",
"invite",
"link",
"for",
"a",
"chat",
";",
"any",
"previously",
"generated",
"link",
"is",
"revoked",
".",
"The",
"bot",
"must",
"be",
"an",
"administrator",
"in",
"the",
"chat",
"for",
"this",
"to",... | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/bot/bot.py#L1091-L1106 | train |
aiogram/aiogram | aiogram/bot/bot.py | Bot.set_chat_photo | async def set_chat_photo(self, chat_id: typing.Union[base.Integer, base.String],
photo: base.InputFile) -> base.Boolean:
"""
Use this method to set a new profile photo for the chat. Photos can't be changed for private chats.
The bot must be an administrator in the ch... | python | async def set_chat_photo(self, chat_id: typing.Union[base.Integer, base.String],
photo: base.InputFile) -> base.Boolean:
"""
Use this method to set a new profile photo for the chat. Photos can't be changed for private chats.
The bot must be an administrator in the ch... | [
"async",
"def",
"set_chat_photo",
"(",
"self",
",",
"chat_id",
":",
"typing",
".",
"Union",
"[",
"base",
".",
"Integer",
",",
"base",
".",
"String",
"]",
",",
"photo",
":",
"base",
".",
"InputFile",
")",
"->",
"base",
".",
"Boolean",
":",
"payload",
... | Use this method to set a new profile photo for the chat. Photos can't be changed for private chats.
The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
Note: In regular groups (non-supergroups), this method will only work if the ‘All Members Are Adm... | [
"Use",
"this",
"method",
"to",
"set",
"a",
"new",
"profile",
"photo",
"for",
"the",
"chat",
".",
"Photos",
"can",
"t",
"be",
"changed",
"for",
"private",
"chats",
".",
"The",
"bot",
"must",
"be",
"an",
"administrator",
"in",
"the",
"chat",
"for",
"this... | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/bot/bot.py#L1108-L1132 | train |
aiogram/aiogram | aiogram/bot/bot.py | Bot.set_chat_description | async def set_chat_description(self, chat_id: typing.Union[base.Integer, base.String],
description: typing.Union[base.String, None] = None) -> base.Boolean:
"""
Use this method to change the description of a supergroup or a channel.
The bot must be an administr... | python | async def set_chat_description(self, chat_id: typing.Union[base.Integer, base.String],
description: typing.Union[base.String, None] = None) -> base.Boolean:
"""
Use this method to change the description of a supergroup or a channel.
The bot must be an administr... | [
"async",
"def",
"set_chat_description",
"(",
"self",
",",
"chat_id",
":",
"typing",
".",
"Union",
"[",
"base",
".",
"Integer",
",",
"base",
".",
"String",
"]",
",",
"description",
":",
"typing",
".",
"Union",
"[",
"base",
".",
"String",
",",
"None",
"]... | Use this method to change the description of a supergroup or a channel.
The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
Source: https://core.telegram.org/bots/api#setchatdescription
:param chat_id: Unique identifier for the target chat ... | [
"Use",
"this",
"method",
"to",
"change",
"the",
"description",
"of",
"a",
"supergroup",
"or",
"a",
"channel",
".",
"The",
"bot",
"must",
"be",
"an",
"administrator",
"in",
"the",
"chat",
"for",
"this",
"to",
"work",
"and",
"must",
"have",
"the",
"appropr... | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/bot/bot.py#L1177-L1195 | train |
aiogram/aiogram | aiogram/bot/bot.py | Bot.unpin_chat_message | async def unpin_chat_message(self, chat_id: typing.Union[base.Integer, base.String]) -> base.Boolean:
"""
Use this method to unpin a message in a supergroup chat.
The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
Source: https://co... | python | async def unpin_chat_message(self, chat_id: typing.Union[base.Integer, base.String]) -> base.Boolean:
"""
Use this method to unpin a message in a supergroup chat.
The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
Source: https://co... | [
"async",
"def",
"unpin_chat_message",
"(",
"self",
",",
"chat_id",
":",
"typing",
".",
"Union",
"[",
"base",
".",
"Integer",
",",
"base",
".",
"String",
"]",
")",
"->",
"base",
".",
"Boolean",
":",
"payload",
"=",
"generate_payload",
"(",
"*",
"*",
"lo... | Use this method to unpin a message in a supergroup chat.
The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
Source: https://core.telegram.org/bots/api#unpinchatmessage
:param chat_id: Unique identifier for the target chat or username of th... | [
"Use",
"this",
"method",
"to",
"unpin",
"a",
"message",
"in",
"a",
"supergroup",
"chat",
".",
"The",
"bot",
"must",
"be",
"an",
"administrator",
"in",
"the",
"chat",
"for",
"this",
"to",
"work",
"and",
"must",
"have",
"the",
"appropriate",
"admin",
"righ... | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/bot/bot.py#L1220-L1235 | train |
aiogram/aiogram | aiogram/bot/bot.py | Bot.get_chat_administrators | async def get_chat_administrators(self, chat_id: typing.Union[base.Integer, base.String]
) -> typing.List[types.ChatMember]:
"""
Use this method to get a list of administrators in a chat.
Source: https://core.telegram.org/bots/api#getchatadministrators
... | python | async def get_chat_administrators(self, chat_id: typing.Union[base.Integer, base.String]
) -> typing.List[types.ChatMember]:
"""
Use this method to get a list of administrators in a chat.
Source: https://core.telegram.org/bots/api#getchatadministrators
... | [
"async",
"def",
"get_chat_administrators",
"(",
"self",
",",
"chat_id",
":",
"typing",
".",
"Union",
"[",
"base",
".",
"Integer",
",",
"base",
".",
"String",
"]",
")",
"->",
"typing",
".",
"List",
"[",
"types",
".",
"ChatMember",
"]",
":",
"payload",
"... | Use this method to get a list of administrators in a chat.
Source: https://core.telegram.org/bots/api#getchatadministrators
:param chat_id: Unique identifier for the target chat or username of the target supergroup or channel
:type chat_id: :obj:`typing.Union[base.Integer, base.String]`
... | [
"Use",
"this",
"method",
"to",
"get",
"a",
"list",
"of",
"administrators",
"in",
"a",
"chat",
"."
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/bot/bot.py#L1270-L1288 | train |
aiogram/aiogram | aiogram/bot/bot.py | Bot.get_chat_member | async def get_chat_member(self, chat_id: typing.Union[base.Integer, base.String],
user_id: base.Integer) -> types.ChatMember:
"""
Use this method to get information about a member of a chat.
Source: https://core.telegram.org/bots/api#getchatmember
:param c... | python | async def get_chat_member(self, chat_id: typing.Union[base.Integer, base.String],
user_id: base.Integer) -> types.ChatMember:
"""
Use this method to get information about a member of a chat.
Source: https://core.telegram.org/bots/api#getchatmember
:param c... | [
"async",
"def",
"get_chat_member",
"(",
"self",
",",
"chat_id",
":",
"typing",
".",
"Union",
"[",
"base",
".",
"Integer",
",",
"base",
".",
"String",
"]",
",",
"user_id",
":",
"base",
".",
"Integer",
")",
"->",
"types",
".",
"ChatMember",
":",
"payload... | Use this method to get information about a member of a chat.
Source: https://core.telegram.org/bots/api#getchatmember
:param chat_id: Unique identifier for the target chat or username of the target supergroup or channel
:type chat_id: :obj:`typing.Union[base.Integer, base.String]`
:par... | [
"Use",
"this",
"method",
"to",
"get",
"information",
"about",
"a",
"member",
"of",
"a",
"chat",
"."
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/bot/bot.py#L1306-L1323 | train |
aiogram/aiogram | aiogram/bot/bot.py | Bot.set_chat_sticker_set | async def set_chat_sticker_set(self, chat_id: typing.Union[base.Integer, base.String],
sticker_set_name: base.String) -> base.Boolean:
"""
Use this method to set a new group sticker set for a supergroup.
The bot must be an administrator in the chat for this to ... | python | async def set_chat_sticker_set(self, chat_id: typing.Union[base.Integer, base.String],
sticker_set_name: base.String) -> base.Boolean:
"""
Use this method to set a new group sticker set for a supergroup.
The bot must be an administrator in the chat for this to ... | [
"async",
"def",
"set_chat_sticker_set",
"(",
"self",
",",
"chat_id",
":",
"typing",
".",
"Union",
"[",
"base",
".",
"Integer",
",",
"base",
".",
"String",
"]",
",",
"sticker_set_name",
":",
"base",
".",
"String",
")",
"->",
"base",
".",
"Boolean",
":",
... | Use this method to set a new group sticker set for a supergroup.
The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
Use the field can_set_sticker_set optionally returned in getChat requests to check
if the bot can use this method.
... | [
"Use",
"this",
"method",
"to",
"set",
"a",
"new",
"group",
"sticker",
"set",
"for",
"a",
"supergroup",
".",
"The",
"bot",
"must",
"be",
"an",
"administrator",
"in",
"the",
"chat",
"for",
"this",
"to",
"work",
"and",
"must",
"have",
"the",
"appropriate",
... | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/bot/bot.py#L1325-L1346 | train |
aiogram/aiogram | aiogram/bot/bot.py | Bot.delete_chat_sticker_set | async def delete_chat_sticker_set(self, chat_id: typing.Union[base.Integer, base.String]) -> base.Boolean:
"""
Use this method to delete a group sticker set from a supergroup.
The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
Use t... | python | async def delete_chat_sticker_set(self, chat_id: typing.Union[base.Integer, base.String]) -> base.Boolean:
"""
Use this method to delete a group sticker set from a supergroup.
The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
Use t... | [
"async",
"def",
"delete_chat_sticker_set",
"(",
"self",
",",
"chat_id",
":",
"typing",
".",
"Union",
"[",
"base",
".",
"Integer",
",",
"base",
".",
"String",
"]",
")",
"->",
"base",
".",
"Boolean",
":",
"payload",
"=",
"generate_payload",
"(",
"*",
"*",
... | Use this method to delete a group sticker set from a supergroup.
The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
Use the field can_set_sticker_set optionally returned in getChat requests
to check if the bot can use this method.
... | [
"Use",
"this",
"method",
"to",
"delete",
"a",
"group",
"sticker",
"set",
"from",
"a",
"supergroup",
".",
"The",
"bot",
"must",
"be",
"an",
"administrator",
"in",
"the",
"chat",
"for",
"this",
"to",
"work",
"and",
"must",
"have",
"the",
"appropriate",
"ad... | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/bot/bot.py#L1348-L1366 | train |
aiogram/aiogram | aiogram/bot/bot.py | Bot.stop_poll | async def stop_poll(self, chat_id: typing.Union[base.String, base.Integer],
message_id: base.Integer,
reply_markup: typing.Union[types.InlineKeyboardMarkup, None] = None) -> types.Poll:
"""
Use this method to stop a poll which was sent by the bot.
... | python | async def stop_poll(self, chat_id: typing.Union[base.String, base.Integer],
message_id: base.Integer,
reply_markup: typing.Union[types.InlineKeyboardMarkup, None] = None) -> types.Poll:
"""
Use this method to stop a poll which was sent by the bot.
... | [
"async",
"def",
"stop_poll",
"(",
"self",
",",
"chat_id",
":",
"typing",
".",
"Union",
"[",
"base",
".",
"String",
",",
"base",
".",
"Integer",
"]",
",",
"message_id",
":",
"base",
".",
"Integer",
",",
"reply_markup",
":",
"typing",
".",
"Union",
"[",
... | Use this method to stop a poll which was sent by the bot.
On success, the stopped Poll with the final results is returned.
:param chat_id: Unique identifier for the target chat or username of the target channel
:type chat_id: :obj:`typing.Union[base.String, base.Integer]`
:param message... | [
"Use",
"this",
"method",
"to",
"stop",
"a",
"poll",
"which",
"was",
"sent",
"by",
"the",
"bot",
".",
"On",
"success",
"the",
"stopped",
"Poll",
"with",
"the",
"final",
"results",
"is",
"returned",
"."
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/bot/bot.py#L1564-L1583 | train |
aiogram/aiogram | aiogram/bot/bot.py | Bot.get_sticker_set | async def get_sticker_set(self, name: base.String) -> types.StickerSet:
"""
Use this method to get a sticker set.
Source: https://core.telegram.org/bots/api#getstickerset
:param name: Name of the sticker set
:type name: :obj:`base.String`
:return: On success, a StickerS... | python | async def get_sticker_set(self, name: base.String) -> types.StickerSet:
"""
Use this method to get a sticker set.
Source: https://core.telegram.org/bots/api#getstickerset
:param name: Name of the sticker set
:type name: :obj:`base.String`
:return: On success, a StickerS... | [
"async",
"def",
"get_sticker_set",
"(",
"self",
",",
"name",
":",
"base",
".",
"String",
")",
"->",
"types",
".",
"StickerSet",
":",
"payload",
"=",
"generate_payload",
"(",
"*",
"*",
"locals",
"(",
")",
")",
"result",
"=",
"await",
"self",
".",
"reque... | Use this method to get a sticker set.
Source: https://core.telegram.org/bots/api#getstickerset
:param name: Name of the sticker set
:type name: :obj:`base.String`
:return: On success, a StickerSet object is returned
:rtype: :obj:`types.StickerSet` | [
"Use",
"this",
"method",
"to",
"get",
"a",
"sticker",
"set",
"."
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/bot/bot.py#L1649-L1663 | train |
aiogram/aiogram | aiogram/bot/bot.py | Bot.create_new_sticker_set | async def create_new_sticker_set(self, user_id: base.Integer, name: base.String, title: base.String,
png_sticker: typing.Union[base.InputFile, base.String], emojis: base.String,
contains_masks: typing.Union[base.Boolean, None] = None,
... | python | async def create_new_sticker_set(self, user_id: base.Integer, name: base.String, title: base.String,
png_sticker: typing.Union[base.InputFile, base.String], emojis: base.String,
contains_masks: typing.Union[base.Boolean, None] = None,
... | [
"async",
"def",
"create_new_sticker_set",
"(",
"self",
",",
"user_id",
":",
"base",
".",
"Integer",
",",
"name",
":",
"base",
".",
"String",
",",
"title",
":",
"base",
".",
"String",
",",
"png_sticker",
":",
"typing",
".",
"Union",
"[",
"base",
".",
"I... | Use this method to create new sticker set owned by a user. The bot will be able to edit the created sticker set.
Source: https://core.telegram.org/bots/api#createnewstickerset
:param user_id: User identifier of created sticker set owner
:type user_id: :obj:`base.Integer`
:param name: S... | [
"Use",
"this",
"method",
"to",
"create",
"new",
"sticker",
"set",
"owned",
"by",
"a",
"user",
".",
"The",
"bot",
"will",
"be",
"able",
"to",
"edit",
"the",
"created",
"sticker",
"set",
"."
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/bot/bot.py#L1688-L1722 | train |
aiogram/aiogram | aiogram/bot/bot.py | Bot.set_sticker_position_in_set | async def set_sticker_position_in_set(self, sticker: base.String, position: base.Integer) -> base.Boolean:
"""
Use this method to move a sticker in a set created by the bot to a specific position.
Source: https://core.telegram.org/bots/api#setstickerpositioninset
:param sticker: File i... | python | async def set_sticker_position_in_set(self, sticker: base.String, position: base.Integer) -> base.Boolean:
"""
Use this method to move a sticker in a set created by the bot to a specific position.
Source: https://core.telegram.org/bots/api#setstickerpositioninset
:param sticker: File i... | [
"async",
"def",
"set_sticker_position_in_set",
"(",
"self",
",",
"sticker",
":",
"base",
".",
"String",
",",
"position",
":",
"base",
".",
"Integer",
")",
"->",
"base",
".",
"Boolean",
":",
"payload",
"=",
"generate_payload",
"(",
"*",
"*",
"locals",
"(",
... | Use this method to move a sticker in a set created by the bot to a specific position.
Source: https://core.telegram.org/bots/api#setstickerpositioninset
:param sticker: File identifier of the sticker
:type sticker: :obj:`base.String`
:param position: New sticker position in the set, ze... | [
"Use",
"this",
"method",
"to",
"move",
"a",
"sticker",
"in",
"a",
"set",
"created",
"by",
"the",
"bot",
"to",
"a",
"specific",
"position",
"."
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/bot/bot.py#L1755-L1771 | train |
aiogram/aiogram | aiogram/bot/bot.py | Bot.delete_sticker_from_set | async def delete_sticker_from_set(self, sticker: base.String) -> base.Boolean:
"""
Use this method to delete a sticker from a set created by the bot.
The following methods and objects allow your bot to work in inline mode.
Source: https://core.telegram.org/bots/api#deletestickerfromset... | python | async def delete_sticker_from_set(self, sticker: base.String) -> base.Boolean:
"""
Use this method to delete a sticker from a set created by the bot.
The following methods and objects allow your bot to work in inline mode.
Source: https://core.telegram.org/bots/api#deletestickerfromset... | [
"async",
"def",
"delete_sticker_from_set",
"(",
"self",
",",
"sticker",
":",
"base",
".",
"String",
")",
"->",
"base",
".",
"Boolean",
":",
"payload",
"=",
"generate_payload",
"(",
"*",
"*",
"locals",
"(",
")",
")",
"result",
"=",
"await",
"self",
".",
... | Use this method to delete a sticker from a set created by the bot.
The following methods and objects allow your bot to work in inline mode.
Source: https://core.telegram.org/bots/api#deletestickerfromset
:param sticker: File identifier of the sticker
:type sticker: :obj:`base.String`
... | [
"Use",
"this",
"method",
"to",
"delete",
"a",
"sticker",
"from",
"a",
"set",
"created",
"by",
"the",
"bot",
"."
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/bot/bot.py#L1773-L1789 | train |
aiogram/aiogram | aiogram/bot/bot.py | Bot.send_invoice | async def send_invoice(self, chat_id: base.Integer, title: base.String,
description: base.String, payload: base.String,
provider_token: base.String, start_parameter: base.String,
currency: base.String, prices: typing.List[types.LabeledPric... | python | async def send_invoice(self, chat_id: base.Integer, title: base.String,
description: base.String, payload: base.String,
provider_token: base.String, start_parameter: base.String,
currency: base.String, prices: typing.List[types.LabeledPric... | [
"async",
"def",
"send_invoice",
"(",
"self",
",",
"chat_id",
":",
"base",
".",
"Integer",
",",
"title",
":",
"base",
".",
"String",
",",
"description",
":",
"base",
".",
"String",
",",
"payload",
":",
"base",
".",
"String",
",",
"provider_token",
":",
... | Use this method to send invoices.
Source: https://core.telegram.org/bots/api#sendinvoice
:param chat_id: Unique identifier for the target private chat
:type chat_id: :obj:`base.Integer`
:param title: Product name, 1-32 characters
:type title: :obj:`base.String`
:param d... | [
"Use",
"this",
"method",
"to",
"send",
"invoices",
"."
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/bot/bot.py#L1838-L1914 | train |
aiogram/aiogram | aiogram/bot/bot.py | Bot.answer_shipping_query | async def answer_shipping_query(self, shipping_query_id: base.String, ok: base.Boolean,
shipping_options: typing.Union[typing.List[types.ShippingOption], None] = None,
error_message: typing.Union[base.String, None] = None) -> base.Boolean:
... | python | async def answer_shipping_query(self, shipping_query_id: base.String, ok: base.Boolean,
shipping_options: typing.Union[typing.List[types.ShippingOption], None] = None,
error_message: typing.Union[base.String, None] = None) -> base.Boolean:
... | [
"async",
"def",
"answer_shipping_query",
"(",
"self",
",",
"shipping_query_id",
":",
"base",
".",
"String",
",",
"ok",
":",
"base",
".",
"Boolean",
",",
"shipping_options",
":",
"typing",
".",
"Union",
"[",
"typing",
".",
"List",
"[",
"types",
".",
"Shippi... | If you sent an invoice requesting a shipping address and the parameter is_flexible was specified,
the Bot API will send an Update with a shipping_query field to the bot.
Source: https://core.telegram.org/bots/api#answershippingquery
:param shipping_query_id: Unique identifier for the query to ... | [
"If",
"you",
"sent",
"an",
"invoice",
"requesting",
"a",
"shipping",
"address",
"and",
"the",
"parameter",
"is_flexible",
"was",
"specified",
"the",
"Bot",
"API",
"will",
"send",
"an",
"Update",
"with",
"a",
"shipping_query",
"field",
"to",
"the",
"bot",
"."... | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/bot/bot.py#L1916-L1948 | train |
aiogram/aiogram | aiogram/bot/bot.py | Bot.answer_pre_checkout_query | async def answer_pre_checkout_query(self, pre_checkout_query_id: base.String, ok: base.Boolean,
error_message: typing.Union[base.String, None] = None) -> base.Boolean:
"""
Once the user has confirmed their payment and shipping details,
the Bot API sends th... | python | async def answer_pre_checkout_query(self, pre_checkout_query_id: base.String, ok: base.Boolean,
error_message: typing.Union[base.String, None] = None) -> base.Boolean:
"""
Once the user has confirmed their payment and shipping details,
the Bot API sends th... | [
"async",
"def",
"answer_pre_checkout_query",
"(",
"self",
",",
"pre_checkout_query_id",
":",
"base",
".",
"String",
",",
"ok",
":",
"base",
".",
"Boolean",
",",
"error_message",
":",
"typing",
".",
"Union",
"[",
"base",
".",
"String",
",",
"None",
"]",
"="... | Once the user has confirmed their payment and shipping details,
the Bot API sends the final confirmation in the form of an Update with the field pre_checkout_query.
Use this method to respond to such pre-checkout queries.
Source: https://core.telegram.org/bots/api#answerprecheckoutquery
... | [
"Once",
"the",
"user",
"has",
"confirmed",
"their",
"payment",
"and",
"shipping",
"details",
"the",
"Bot",
"API",
"sends",
"the",
"final",
"confirmation",
"in",
"the",
"form",
"of",
"an",
"Update",
"with",
"the",
"field",
"pre_checkout_query",
".",
"Use",
"t... | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/bot/bot.py#L1950-L1976 | train |
aiogram/aiogram | examples/callback_data_factory.py | get_keyboard | def get_keyboard() -> types.InlineKeyboardMarkup:
"""
Generate keyboard with list of posts
"""
markup = types.InlineKeyboardMarkup()
for post_id, post in POSTS.items():
markup.add(
types.InlineKeyboardButton(
post['title'],
callback_data=posts_cb.n... | python | def get_keyboard() -> types.InlineKeyboardMarkup:
"""
Generate keyboard with list of posts
"""
markup = types.InlineKeyboardMarkup()
for post_id, post in POSTS.items():
markup.add(
types.InlineKeyboardButton(
post['title'],
callback_data=posts_cb.n... | [
"def",
"get_keyboard",
"(",
")",
"->",
"types",
".",
"InlineKeyboardMarkup",
":",
"markup",
"=",
"types",
".",
"InlineKeyboardMarkup",
"(",
")",
"for",
"post_id",
",",
"post",
"in",
"POSTS",
".",
"items",
"(",
")",
":",
"markup",
".",
"add",
"(",
"types"... | Generate keyboard with list of posts | [
"Generate",
"keyboard",
"with",
"list",
"of",
"posts"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/examples/callback_data_factory.py#L36-L47 | train |
aiogram/aiogram | aiogram/contrib/middlewares/i18n.py | I18nMiddleware.find_locales | def find_locales(self) -> Dict[str, gettext.GNUTranslations]:
"""
Load all compiled locales from path
:return: dict with locales
"""
translations = {}
for name in os.listdir(self.path):
if not os.path.isdir(os.path.join(self.path, name)):
con... | python | def find_locales(self) -> Dict[str, gettext.GNUTranslations]:
"""
Load all compiled locales from path
:return: dict with locales
"""
translations = {}
for name in os.listdir(self.path):
if not os.path.isdir(os.path.join(self.path, name)):
con... | [
"def",
"find_locales",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"gettext",
".",
"GNUTranslations",
"]",
":",
"translations",
"=",
"{",
"}",
"for",
"name",
"in",
"os",
".",
"listdir",
"(",
"self",
".",
"path",
")",
":",
"if",
"not",
"os",
".... | Load all compiled locales from path
:return: dict with locales | [
"Load",
"all",
"compiled",
"locales",
"from",
"path"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/contrib/middlewares/i18n.py#L45-L64 | train |
aiogram/aiogram | aiogram/contrib/middlewares/i18n.py | I18nMiddleware.lazy_gettext | def lazy_gettext(self, singular, plural=None, n=1, locale=None) -> LazyProxy:
"""
Lazy get text
:param singular:
:param plural:
:param n:
:param locale:
:return:
"""
return LazyProxy(self.gettext, singular, plural, n, locale) | python | def lazy_gettext(self, singular, plural=None, n=1, locale=None) -> LazyProxy:
"""
Lazy get text
:param singular:
:param plural:
:param n:
:param locale:
:return:
"""
return LazyProxy(self.gettext, singular, plural, n, locale) | [
"def",
"lazy_gettext",
"(",
"self",
",",
"singular",
",",
"plural",
"=",
"None",
",",
"n",
"=",
"1",
",",
"locale",
"=",
"None",
")",
"->",
"LazyProxy",
":",
"return",
"LazyProxy",
"(",
"self",
".",
"gettext",
",",
"singular",
",",
"plural",
",",
"n"... | Lazy get text
:param singular:
:param plural:
:param n:
:param locale:
:return: | [
"Lazy",
"get",
"text"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/contrib/middlewares/i18n.py#L110-L120 | train |
aiogram/aiogram | aiogram/utils/executor.py | Executor.on_startup | def on_startup(self, callback: callable, polling=True, webhook=True):
"""
Register a callback for the startup process
:param callback:
:param polling: use with polling
:param webhook: use with webhook
"""
self._check_frozen()
if not webhook and not pollin... | python | def on_startup(self, callback: callable, polling=True, webhook=True):
"""
Register a callback for the startup process
:param callback:
:param polling: use with polling
:param webhook: use with webhook
"""
self._check_frozen()
if not webhook and not pollin... | [
"def",
"on_startup",
"(",
"self",
",",
"callback",
":",
"callable",
",",
"polling",
"=",
"True",
",",
"webhook",
"=",
"True",
")",
":",
"self",
".",
"_check_frozen",
"(",
")",
"if",
"not",
"webhook",
"and",
"not",
"polling",
":",
"warn",
"(",
"'This ac... | Register a callback for the startup process
:param callback:
:param polling: use with polling
:param webhook: use with webhook | [
"Register",
"a",
"callback",
"for",
"the",
"startup",
"process"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/utils/executor.py#L166-L187 | train |
aiogram/aiogram | aiogram/utils/executor.py | Executor.on_shutdown | def on_shutdown(self, callback: callable, polling=True, webhook=True):
"""
Register a callback for the shutdown process
:param callback:
:param polling: use with polling
:param webhook: use with webhook
"""
self._check_frozen()
if not webhook and not poll... | python | def on_shutdown(self, callback: callable, polling=True, webhook=True):
"""
Register a callback for the shutdown process
:param callback:
:param polling: use with polling
:param webhook: use with webhook
"""
self._check_frozen()
if not webhook and not poll... | [
"def",
"on_shutdown",
"(",
"self",
",",
"callback",
":",
"callable",
",",
"polling",
"=",
"True",
",",
"webhook",
"=",
"True",
")",
":",
"self",
".",
"_check_frozen",
"(",
")",
"if",
"not",
"webhook",
"and",
"not",
"polling",
":",
"warn",
"(",
"'This a... | Register a callback for the shutdown process
:param callback:
:param polling: use with polling
:param webhook: use with webhook | [
"Register",
"a",
"callback",
"for",
"the",
"shutdown",
"process"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/utils/executor.py#L189-L210 | train |
aiogram/aiogram | setup.py | get_requirements | def get_requirements(filename=None):
"""
Read requirements from 'requirements txt'
:return: requirements
:rtype: list
"""
if filename is None:
filename = 'requirements.txt'
file = WORK_DIR / filename
install_reqs = parse_requirements(str(file), session='hack')
return [str(... | python | def get_requirements(filename=None):
"""
Read requirements from 'requirements txt'
:return: requirements
:rtype: list
"""
if filename is None:
filename = 'requirements.txt'
file = WORK_DIR / filename
install_reqs = parse_requirements(str(file), session='hack')
return [str(... | [
"def",
"get_requirements",
"(",
"filename",
"=",
"None",
")",
":",
"if",
"filename",
"is",
"None",
":",
"filename",
"=",
"'requirements.txt'",
"file",
"=",
"WORK_DIR",
"/",
"filename",
"install_reqs",
"=",
"parse_requirements",
"(",
"str",
"(",
"file",
")",
... | Read requirements from 'requirements txt'
:return: requirements
:rtype: list | [
"Read",
"requirements",
"from",
"requirements",
"txt"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/setup.py#L45-L58 | train |
aiogram/aiogram | aiogram/bot/base.py | BaseBot.request_timeout | def request_timeout(self, timeout):
"""
Context manager implements opportunity to change request timeout in current context
:param timeout:
:return:
"""
timeout = self._prepare_timeout(timeout)
token = self._ctx_timeout.set(timeout)
try:
yield... | python | def request_timeout(self, timeout):
"""
Context manager implements opportunity to change request timeout in current context
:param timeout:
:return:
"""
timeout = self._prepare_timeout(timeout)
token = self._ctx_timeout.set(timeout)
try:
yield... | [
"def",
"request_timeout",
"(",
"self",
",",
"timeout",
")",
":",
"timeout",
"=",
"self",
".",
"_prepare_timeout",
"(",
"timeout",
")",
"token",
"=",
"self",
".",
"_ctx_timeout",
".",
"set",
"(",
"timeout",
")",
"try",
":",
"yield",
"finally",
":",
"self"... | Context manager implements opportunity to change request timeout in current context
:param timeout:
:return: | [
"Context",
"manager",
"implements",
"opportunity",
"to",
"change",
"request",
"timeout",
"in",
"current",
"context"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/bot/base.py#L124-L136 | train |
aiogram/aiogram | aiogram/bot/base.py | BaseBot.request | async def request(self, method: base.String,
data: Optional[Dict] = None,
files: Optional[Dict] = None, **kwargs) -> Union[List, Dict, base.Boolean]:
"""
Make an request to Telegram Bot API
https://core.telegram.org/bots/api#making-requests
:... | python | async def request(self, method: base.String,
data: Optional[Dict] = None,
files: Optional[Dict] = None, **kwargs) -> Union[List, Dict, base.Boolean]:
"""
Make an request to Telegram Bot API
https://core.telegram.org/bots/api#making-requests
:... | [
"async",
"def",
"request",
"(",
"self",
",",
"method",
":",
"base",
".",
"String",
",",
"data",
":",
"Optional",
"[",
"Dict",
"]",
"=",
"None",
",",
"files",
":",
"Optional",
"[",
"Dict",
"]",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
"->",
"Uni... | Make an request to Telegram Bot API
https://core.telegram.org/bots/api#making-requests
:param method: API method
:type method: :obj:`str`
:param data: request parameters
:type data: :obj:`dict`
:param files: files
:type files: :obj:`dict`
:return: result... | [
"Make",
"an",
"request",
"to",
"Telegram",
"Bot",
"API"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/bot/base.py#L144-L163 | train |
aiogram/aiogram | aiogram/bot/base.py | BaseBot.download_file | async def download_file(self, file_path: base.String,
destination: Optional[base.InputFile] = None,
timeout: Optional[base.Integer] = sentinel,
chunk_size: Optional[base.Integer] = 65536,
seek: Optional[base.... | python | async def download_file(self, file_path: base.String,
destination: Optional[base.InputFile] = None,
timeout: Optional[base.Integer] = sentinel,
chunk_size: Optional[base.Integer] = 65536,
seek: Optional[base.... | [
"async",
"def",
"download_file",
"(",
"self",
",",
"file_path",
":",
"base",
".",
"String",
",",
"destination",
":",
"Optional",
"[",
"base",
".",
"InputFile",
"]",
"=",
"None",
",",
"timeout",
":",
"Optional",
"[",
"base",
".",
"Integer",
"]",
"=",
"s... | Download file by file_path to destination
if You want to automatically create destination (:class:`io.BytesIO`) use default
value of destination and handle result of this method.
:param file_path: file path on telegram server (You can get it from :obj:`aiogram.types.File`)
:type file_p... | [
"Download",
"file",
"by",
"file_path",
"to",
"destination"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/bot/base.py#L165-L199 | train |
aiogram/aiogram | aiogram/types/fields.py | BaseField.get_value | def get_value(self, instance):
"""
Get value for the current object instance
:param instance:
:return:
"""
return instance.values.get(self.alias, self.default) | python | def get_value(self, instance):
"""
Get value for the current object instance
:param instance:
:return:
"""
return instance.values.get(self.alias, self.default) | [
"def",
"get_value",
"(",
"self",
",",
"instance",
")",
":",
"return",
"instance",
".",
"values",
".",
"get",
"(",
"self",
".",
"alias",
",",
"self",
".",
"default",
")"
] | Get value for the current object instance
:param instance:
:return: | [
"Get",
"value",
"for",
"the",
"current",
"object",
"instance"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/types/fields.py#L37-L44 | train |
aiogram/aiogram | aiogram/types/fields.py | BaseField.set_value | def set_value(self, instance, value, parent=None):
"""
Set prop value
:param instance:
:param value:
:param parent:
:return:
"""
self.resolve_base(instance)
value = self.deserialize(value, parent)
instance.values[self.alias] = value
... | python | def set_value(self, instance, value, parent=None):
"""
Set prop value
:param instance:
:param value:
:param parent:
:return:
"""
self.resolve_base(instance)
value = self.deserialize(value, parent)
instance.values[self.alias] = value
... | [
"def",
"set_value",
"(",
"self",
",",
"instance",
",",
"value",
",",
"parent",
"=",
"None",
")",
":",
"self",
".",
"resolve_base",
"(",
"instance",
")",
"value",
"=",
"self",
".",
"deserialize",
"(",
"value",
",",
"parent",
")",
"instance",
".",
"value... | Set prop value
:param instance:
:param value:
:param parent:
:return: | [
"Set",
"prop",
"value"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/types/fields.py#L46-L58 | train |
aiogram/aiogram | aiogram/types/base.py | TelegramObject.clean | def clean(self):
"""
Remove empty values
"""
for key, value in self.values.copy().items():
if value is None:
del self.values[key] | python | def clean(self):
"""
Remove empty values
"""
for key, value in self.values.copy().items():
if value is None:
del self.values[key] | [
"def",
"clean",
"(",
"self",
")",
":",
"for",
"key",
",",
"value",
"in",
"self",
".",
"values",
".",
"copy",
"(",
")",
".",
"items",
"(",
")",
":",
"if",
"value",
"is",
"None",
":",
"del",
"self",
".",
"values",
"[",
"key",
"]"
] | Remove empty values | [
"Remove",
"empty",
"values"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/types/base.py#L173-L179 | train |
aiogram/aiogram | aiogram/types/chat.py | Chat.mention | def mention(self):
"""
Get mention if a Chat has a username, or get full name if this is a Private Chat, otherwise None is returned
"""
if self.username:
return '@' + self.username
if self.type == ChatType.PRIVATE:
return self.full_name
return None | python | def mention(self):
"""
Get mention if a Chat has a username, or get full name if this is a Private Chat, otherwise None is returned
"""
if self.username:
return '@' + self.username
if self.type == ChatType.PRIVATE:
return self.full_name
return None | [
"def",
"mention",
"(",
"self",
")",
":",
"if",
"self",
".",
"username",
":",
"return",
"'@'",
"+",
"self",
".",
"username",
"if",
"self",
".",
"type",
"==",
"ChatType",
".",
"PRIVATE",
":",
"return",
"self",
".",
"full_name",
"return",
"None"
] | Get mention if a Chat has a username, or get full name if this is a Private Chat, otherwise None is returned | [
"Get",
"mention",
"if",
"a",
"Chat",
"has",
"a",
"username",
"or",
"get",
"full",
"name",
"if",
"this",
"is",
"a",
"Private",
"Chat",
"otherwise",
"None",
"is",
"returned"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/types/chat.py#L46-L54 | train |
aiogram/aiogram | aiogram/types/chat.py | Chat.update_chat | async def update_chat(self):
"""
User this method to update Chat data
:return: None
"""
other = await self.bot.get_chat(self.id)
for key, value in other:
self[key] = value | python | async def update_chat(self):
"""
User this method to update Chat data
:return: None
"""
other = await self.bot.get_chat(self.id)
for key, value in other:
self[key] = value | [
"async",
"def",
"update_chat",
"(",
"self",
")",
":",
"other",
"=",
"await",
"self",
".",
"bot",
".",
"get_chat",
"(",
"self",
".",
"id",
")",
"for",
"key",
",",
"value",
"in",
"other",
":",
"self",
"[",
"key",
"]",
"=",
"value"
] | User this method to update Chat data
:return: None | [
"User",
"this",
"method",
"to",
"update",
"Chat",
"data"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/types/chat.py#L90-L99 | train |
aiogram/aiogram | aiogram/types/chat.py | Chat.export_invite_link | async def export_invite_link(self):
"""
Use this method to export an invite link to a supergroup or a channel.
The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
Source: https://core.telegram.org/bots/api#exportchatinvitelink
... | python | async def export_invite_link(self):
"""
Use this method to export an invite link to a supergroup or a channel.
The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
Source: https://core.telegram.org/bots/api#exportchatinvitelink
... | [
"async",
"def",
"export_invite_link",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"invite_link",
":",
"self",
".",
"invite_link",
"=",
"await",
"self",
".",
"bot",
".",
"export_chat_invite_link",
"(",
"self",
".",
"id",
")",
"return",
"self",
".",
"... | Use this method to export an invite link to a supergroup or a channel.
The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
Source: https://core.telegram.org/bots/api#exportchatinvitelink
:return: Returns exported invite link as String on su... | [
"Use",
"this",
"method",
"to",
"export",
"an",
"invite",
"link",
"to",
"a",
"supergroup",
"or",
"a",
"channel",
".",
"The",
"bot",
"must",
"be",
"an",
"administrator",
"in",
"the",
"chat",
"for",
"this",
"to",
"work",
"and",
"must",
"have",
"the",
"app... | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/types/chat.py#L387-L400 | train |
aiogram/aiogram | aiogram/types/chat.py | ChatType.is_group_or_super_group | def is_group_or_super_group(cls, obj) -> bool:
"""
Check chat is group or super-group
:param obj:
:return:
"""
return cls._check(obj, [cls.GROUP, cls.SUPER_GROUP]) | python | def is_group_or_super_group(cls, obj) -> bool:
"""
Check chat is group or super-group
:param obj:
:return:
"""
return cls._check(obj, [cls.GROUP, cls.SUPER_GROUP]) | [
"def",
"is_group_or_super_group",
"(",
"cls",
",",
"obj",
")",
"->",
"bool",
":",
"return",
"cls",
".",
"_check",
"(",
"obj",
",",
"[",
"cls",
".",
"GROUP",
",",
"cls",
".",
"SUPER_GROUP",
"]",
")"
] | Check chat is group or super-group
:param obj:
:return: | [
"Check",
"chat",
"is",
"group",
"or",
"super",
"-",
"group"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/types/chat.py#L462-L469 | train |
aiogram/aiogram | aiogram/types/message_entity.py | MessageEntity.get_text | def get_text(self, text):
"""
Get value of entity
:param text: full text
:return: part of text
"""
if sys.maxunicode == 0xffff:
return text[self.offset:self.offset + self.length]
if not isinstance(text, bytes):
entity_text = text.encode('... | python | def get_text(self, text):
"""
Get value of entity
:param text: full text
:return: part of text
"""
if sys.maxunicode == 0xffff:
return text[self.offset:self.offset + self.length]
if not isinstance(text, bytes):
entity_text = text.encode('... | [
"def",
"get_text",
"(",
"self",
",",
"text",
")",
":",
"if",
"sys",
".",
"maxunicode",
"==",
"0xffff",
":",
"return",
"text",
"[",
"self",
".",
"offset",
":",
"self",
".",
"offset",
"+",
"self",
".",
"length",
"]",
"if",
"not",
"isinstance",
"(",
"... | Get value of entity
:param text: full text
:return: part of text | [
"Get",
"value",
"of",
"entity"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/types/message_entity.py#L21-L37 | train |
aiogram/aiogram | aiogram/types/message_entity.py | MessageEntity.parse | def parse(self, text, as_html=True):
"""
Get entity value with markup
:param text: original text
:param as_html: as html?
:return: entity text with markup
"""
if not text:
return text
entity_text = self.get_text(text)
if self.type == ... | python | def parse(self, text, as_html=True):
"""
Get entity value with markup
:param text: original text
:param as_html: as html?
:return: entity text with markup
"""
if not text:
return text
entity_text = self.get_text(text)
if self.type == ... | [
"def",
"parse",
"(",
"self",
",",
"text",
",",
"as_html",
"=",
"True",
")",
":",
"if",
"not",
"text",
":",
"return",
"text",
"entity_text",
"=",
"self",
".",
"get_text",
"(",
"text",
")",
"if",
"self",
".",
"type",
"==",
"MessageEntityType",
".",
"BO... | Get entity value with markup
:param text: original text
:param as_html: as html?
:return: entity text with markup | [
"Get",
"entity",
"value",
"with",
"markup"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/types/message_entity.py#L39-L77 | train |
aiogram/aiogram | aiogram/utils/payload.py | _normalize | def _normalize(obj):
"""
Normalize dicts and lists
:param obj:
:return: normalized object
"""
if isinstance(obj, list):
return [_normalize(item) for item in obj]
elif isinstance(obj, dict):
return {k: _normalize(v) for k, v in obj.items() if v is not None}
elif hasattr(o... | python | def _normalize(obj):
"""
Normalize dicts and lists
:param obj:
:return: normalized object
"""
if isinstance(obj, list):
return [_normalize(item) for item in obj]
elif isinstance(obj, dict):
return {k: _normalize(v) for k, v in obj.items() if v is not None}
elif hasattr(o... | [
"def",
"_normalize",
"(",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"list",
")",
":",
"return",
"[",
"_normalize",
"(",
"item",
")",
"for",
"item",
"in",
"obj",
"]",
"elif",
"isinstance",
"(",
"obj",
",",
"dict",
")",
":",
"return",
"{"... | Normalize dicts and lists
:param obj:
:return: normalized object | [
"Normalize",
"dicts",
"and",
"lists"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/utils/payload.py#L30-L43 | train |
aiogram/aiogram | aiogram/utils/helper.py | HelperMode._screaming_snake_case | def _screaming_snake_case(cls, text):
"""
Transform text to SCREAMING_SNAKE_CASE
:param text:
:return:
"""
if text.isupper():
return text
result = ''
for pos, symbol in enumerate(text):
if symbol.isupper() and pos > 0:
... | python | def _screaming_snake_case(cls, text):
"""
Transform text to SCREAMING_SNAKE_CASE
:param text:
:return:
"""
if text.isupper():
return text
result = ''
for pos, symbol in enumerate(text):
if symbol.isupper() and pos > 0:
... | [
"def",
"_screaming_snake_case",
"(",
"cls",
",",
"text",
")",
":",
"if",
"text",
".",
"isupper",
"(",
")",
":",
"return",
"text",
"result",
"=",
"''",
"for",
"pos",
",",
"symbol",
"in",
"enumerate",
"(",
"text",
")",
":",
"if",
"symbol",
".",
"isuppe... | Transform text to SCREAMING_SNAKE_CASE
:param text:
:return: | [
"Transform",
"text",
"to",
"SCREAMING_SNAKE_CASE"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/utils/helper.py#L59-L74 | train |
aiogram/aiogram | aiogram/utils/helper.py | HelperMode._camel_case | def _camel_case(cls, text, first_upper=False):
"""
Transform text to camelCase or CamelCase
:param text:
:param first_upper: first symbol must be upper?
:return:
"""
result = ''
need_upper = False
for pos, symbol in enumerate(text):
if... | python | def _camel_case(cls, text, first_upper=False):
"""
Transform text to camelCase or CamelCase
:param text:
:param first_upper: first symbol must be upper?
:return:
"""
result = ''
need_upper = False
for pos, symbol in enumerate(text):
if... | [
"def",
"_camel_case",
"(",
"cls",
",",
"text",
",",
"first_upper",
"=",
"False",
")",
":",
"result",
"=",
"''",
"need_upper",
"=",
"False",
"for",
"pos",
",",
"symbol",
"in",
"enumerate",
"(",
"text",
")",
":",
"if",
"symbol",
"==",
"'_'",
"and",
"po... | Transform text to camelCase or CamelCase
:param text:
:param first_upper: first symbol must be upper?
:return: | [
"Transform",
"text",
"to",
"camelCase",
"or",
"CamelCase"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/utils/helper.py#L89-L110 | train |
aiogram/aiogram | aiogram/utils/helper.py | HelperMode.apply | def apply(cls, text, mode):
"""
Apply mode for text
:param text:
:param mode:
:return:
"""
if mode == cls.SCREAMING_SNAKE_CASE:
return cls._screaming_snake_case(text)
elif mode == cls.snake_case:
return cls._snake_case(text)
... | python | def apply(cls, text, mode):
"""
Apply mode for text
:param text:
:param mode:
:return:
"""
if mode == cls.SCREAMING_SNAKE_CASE:
return cls._screaming_snake_case(text)
elif mode == cls.snake_case:
return cls._snake_case(text)
... | [
"def",
"apply",
"(",
"cls",
",",
"text",
",",
"mode",
")",
":",
"if",
"mode",
"==",
"cls",
".",
"SCREAMING_SNAKE_CASE",
":",
"return",
"cls",
".",
"_screaming_snake_case",
"(",
"text",
")",
"elif",
"mode",
"==",
"cls",
".",
"snake_case",
":",
"return",
... | Apply mode for text
:param text:
:param mode:
:return: | [
"Apply",
"mode",
"for",
"text"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/utils/helper.py#L113-L133 | train |
aiogram/aiogram | aiogram/contrib/middlewares/logging.py | LoggingFilter.filter | def filter(self, record: logging.LogRecord):
"""
Extend LogRecord by data from Telegram Update object.
:param record:
:return:
"""
update = types.Update.get_current(True)
if update:
for key, value in self.make_prefix(self.prefix, self.process_update(u... | python | def filter(self, record: logging.LogRecord):
"""
Extend LogRecord by data from Telegram Update object.
:param record:
:return:
"""
update = types.Update.get_current(True)
if update:
for key, value in self.make_prefix(self.prefix, self.process_update(u... | [
"def",
"filter",
"(",
"self",
",",
"record",
":",
"logging",
".",
"LogRecord",
")",
":",
"update",
"=",
"types",
".",
"Update",
".",
"get_current",
"(",
"True",
")",
"if",
"update",
":",
"for",
"key",
",",
"value",
"in",
"self",
".",
"make_prefix",
"... | Extend LogRecord by data from Telegram Update object.
:param record:
:return: | [
"Extend",
"LogRecord",
"by",
"data",
"from",
"Telegram",
"Update",
"object",
"."
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/contrib/middlewares/logging.py#L182-L194 | train |
aiogram/aiogram | aiogram/contrib/middlewares/logging.py | LoggingFilter.process_update | def process_update(self, update: types.Update):
"""
Parse Update object
:param update:
:return:
"""
yield 'update_id', update.update_id
if update.message:
yield 'update_type', 'message'
yield from self.process_message(update.message)
... | python | def process_update(self, update: types.Update):
"""
Parse Update object
:param update:
:return:
"""
yield 'update_id', update.update_id
if update.message:
yield 'update_type', 'message'
yield from self.process_message(update.message)
... | [
"def",
"process_update",
"(",
"self",
",",
"update",
":",
"types",
".",
"Update",
")",
":",
"yield",
"'update_id'",
",",
"update",
".",
"update_id",
"if",
"update",
".",
"message",
":",
"yield",
"'update_type'",
",",
"'message'",
"yield",
"from",
"self",
"... | Parse Update object
:param update:
:return: | [
"Parse",
"Update",
"object"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/contrib/middlewares/logging.py#L196-L231 | train |
aiogram/aiogram | aiogram/contrib/middlewares/logging.py | LoggingFilter.make_prefix | def make_prefix(self, prefix, iterable):
"""
Add prefix to the label
:param prefix:
:param iterable:
:return:
"""
if not prefix:
yield from iterable
for key, value in iterable:
yield f"{prefix}_{key}", value | python | def make_prefix(self, prefix, iterable):
"""
Add prefix to the label
:param prefix:
:param iterable:
:return:
"""
if not prefix:
yield from iterable
for key, value in iterable:
yield f"{prefix}_{key}", value | [
"def",
"make_prefix",
"(",
"self",
",",
"prefix",
",",
"iterable",
")",
":",
"if",
"not",
"prefix",
":",
"yield",
"from",
"iterable",
"for",
"key",
",",
"value",
"in",
"iterable",
":",
"yield",
"f\"{prefix}_{key}\"",
",",
"value"
] | Add prefix to the label
:param prefix:
:param iterable:
:return: | [
"Add",
"prefix",
"to",
"the",
"label"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/contrib/middlewares/logging.py#L233-L245 | train |
aiogram/aiogram | aiogram/contrib/middlewares/logging.py | LoggingFilter.process_user | def process_user(self, user: types.User):
"""
Generate user data
:param user:
:return:
"""
if not user:
return
yield 'user_id', user.id
if self.include_content:
yield 'user_full_name', user.full_name
if user.username:
... | python | def process_user(self, user: types.User):
"""
Generate user data
:param user:
:return:
"""
if not user:
return
yield 'user_id', user.id
if self.include_content:
yield 'user_full_name', user.full_name
if user.username:
... | [
"def",
"process_user",
"(",
"self",
",",
"user",
":",
"types",
".",
"User",
")",
":",
"if",
"not",
"user",
":",
"return",
"yield",
"'user_id'",
",",
"user",
".",
"id",
"if",
"self",
".",
"include_content",
":",
"yield",
"'user_full_name'",
",",
"user",
... | Generate user data
:param user:
:return: | [
"Generate",
"user",
"data"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/contrib/middlewares/logging.py#L247-L261 | train |
aiogram/aiogram | aiogram/contrib/middlewares/logging.py | LoggingFilter.process_chat | def process_chat(self, chat: types.Chat):
"""
Generate chat data
:param chat:
:return:
"""
if not chat:
return
yield 'chat_id', chat.id
yield 'chat_type', chat.type
if self.include_content:
yield 'chat_title', chat.full_na... | python | def process_chat(self, chat: types.Chat):
"""
Generate chat data
:param chat:
:return:
"""
if not chat:
return
yield 'chat_id', chat.id
yield 'chat_type', chat.type
if self.include_content:
yield 'chat_title', chat.full_na... | [
"def",
"process_chat",
"(",
"self",
",",
"chat",
":",
"types",
".",
"Chat",
")",
":",
"if",
"not",
"chat",
":",
"return",
"yield",
"'chat_id'",
",",
"chat",
".",
"id",
"yield",
"'chat_type'",
",",
"chat",
".",
"type",
"if",
"self",
".",
"include_conten... | Generate chat data
:param chat:
:return: | [
"Generate",
"chat",
"data"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/contrib/middlewares/logging.py#L263-L278 | train |
aiogram/aiogram | aiogram/dispatcher/dispatcher.py | Dispatcher.process_updates | async def process_updates(self, updates, fast: typing.Optional[bool] = True):
"""
Process list of updates
:param updates:
:param fast:
:return:
"""
if fast:
tasks = []
for update in updates:
tasks.append(self.updates_handle... | python | async def process_updates(self, updates, fast: typing.Optional[bool] = True):
"""
Process list of updates
:param updates:
:param fast:
:return:
"""
if fast:
tasks = []
for update in updates:
tasks.append(self.updates_handle... | [
"async",
"def",
"process_updates",
"(",
"self",
",",
"updates",
",",
"fast",
":",
"typing",
".",
"Optional",
"[",
"bool",
"]",
"=",
"True",
")",
":",
"if",
"fast",
":",
"tasks",
"=",
"[",
"]",
"for",
"update",
"in",
"updates",
":",
"tasks",
".",
"a... | Process list of updates
:param updates:
:param fast:
:return: | [
"Process",
"list",
"of",
"updates"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/dispatcher/dispatcher.py#L130-L147 | train |
aiogram/aiogram | aiogram/dispatcher/dispatcher.py | Dispatcher.process_update | async def process_update(self, update: types.Update):
"""
Process single update object
:param update:
:return:
"""
types.Update.set_current(update)
try:
if update.message:
types.User.set_current(update.message.from_user)
... | python | async def process_update(self, update: types.Update):
"""
Process single update object
:param update:
:return:
"""
types.Update.set_current(update)
try:
if update.message:
types.User.set_current(update.message.from_user)
... | [
"async",
"def",
"process_update",
"(",
"self",
",",
"update",
":",
"types",
".",
"Update",
")",
":",
"types",
".",
"Update",
".",
"set_current",
"(",
"update",
")",
"try",
":",
"if",
"update",
".",
"message",
":",
"types",
".",
"User",
".",
"set_curren... | Process single update object
:param update:
:return: | [
"Process",
"single",
"update",
"object"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/dispatcher/dispatcher.py#L149-L196 | train |
aiogram/aiogram | aiogram/dispatcher/dispatcher.py | Dispatcher.start_polling | async def start_polling(self,
timeout=20,
relax=0.1,
limit=None,
reset_webhook=None,
fast: typing.Optional[bool] = True,
error_sleep: int = 5):
... | python | async def start_polling(self,
timeout=20,
relax=0.1,
limit=None,
reset_webhook=None,
fast: typing.Optional[bool] = True,
error_sleep: int = 5):
... | [
"async",
"def",
"start_polling",
"(",
"self",
",",
"timeout",
"=",
"20",
",",
"relax",
"=",
"0.1",
",",
"limit",
"=",
"None",
",",
"reset_webhook",
"=",
"None",
",",
"fast",
":",
"typing",
".",
"Optional",
"[",
"bool",
"]",
"=",
"True",
",",
"error_s... | Start long-polling
:param timeout:
:param relax:
:param limit:
:param reset_webhook:
:param fast:
:return: | [
"Start",
"long",
"-",
"polling"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/dispatcher/dispatcher.py#L212-L272 | train |
aiogram/aiogram | aiogram/dispatcher/dispatcher.py | Dispatcher._process_polling_updates | async def _process_polling_updates(self, updates, fast: typing.Optional[bool] = True):
"""
Process updates received from long-polling.
:param updates: list of updates.
:param fast:
"""
need_to_call = []
for responses in itertools.chain.from_iterable(await self.pr... | python | async def _process_polling_updates(self, updates, fast: typing.Optional[bool] = True):
"""
Process updates received from long-polling.
:param updates: list of updates.
:param fast:
"""
need_to_call = []
for responses in itertools.chain.from_iterable(await self.pr... | [
"async",
"def",
"_process_polling_updates",
"(",
"self",
",",
"updates",
",",
"fast",
":",
"typing",
".",
"Optional",
"[",
"bool",
"]",
"=",
"True",
")",
":",
"need_to_call",
"=",
"[",
"]",
"for",
"responses",
"in",
"itertools",
".",
"chain",
".",
"from_... | Process updates received from long-polling.
:param updates: list of updates.
:param fast: | [
"Process",
"updates",
"received",
"from",
"long",
"-",
"polling",
"."
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/dispatcher/dispatcher.py#L274-L291 | train |
aiogram/aiogram | aiogram/dispatcher/dispatcher.py | Dispatcher.stop_polling | def stop_polling(self):
"""
Break long-polling process.
:return:
"""
if hasattr(self, '_polling') and self._polling:
log.info('Stop polling...')
self._polling = False | python | def stop_polling(self):
"""
Break long-polling process.
:return:
"""
if hasattr(self, '_polling') and self._polling:
log.info('Stop polling...')
self._polling = False | [
"def",
"stop_polling",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'_polling'",
")",
"and",
"self",
".",
"_polling",
":",
"log",
".",
"info",
"(",
"'Stop polling...'",
")",
"self",
".",
"_polling",
"=",
"False"
] | Break long-polling process.
:return: | [
"Break",
"long",
"-",
"polling",
"process",
"."
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/dispatcher/dispatcher.py#L293-L301 | train |
aiogram/aiogram | aiogram/dispatcher/dispatcher.py | Dispatcher.register_message_handler | def register_message_handler(self, callback, *custom_filters, commands=None, regexp=None, content_types=None,
state=None, run_task=None, **kwargs):
"""
Register handler for message
.. code-block:: python3
# This handler works only if state is None (... | python | def register_message_handler(self, callback, *custom_filters, commands=None, regexp=None, content_types=None,
state=None, run_task=None, **kwargs):
"""
Register handler for message
.. code-block:: python3
# This handler works only if state is None (... | [
"def",
"register_message_handler",
"(",
"self",
",",
"callback",
",",
"*",
"custom_filters",
",",
"commands",
"=",
"None",
",",
"regexp",
"=",
"None",
",",
"content_types",
"=",
"None",
",",
"state",
"=",
"None",
",",
"run_task",
"=",
"None",
",",
"*",
"... | Register handler for message
.. code-block:: python3
# This handler works only if state is None (by default).
dp.register_message_handler(cmd_start, commands=['start', 'about'])
dp.register_message_handler(entry_point, commands=['setup'])
# This handler works o... | [
"Register",
"handler",
"for",
"message"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/dispatcher/dispatcher.py#L319-L353 | train |
aiogram/aiogram | aiogram/dispatcher/dispatcher.py | Dispatcher.message_handler | def message_handler(self, *custom_filters, commands=None, regexp=None, content_types=None, state=None,
run_task=None, **kwargs):
"""
Decorator for message handler
Examples:
Simple commands handler:
.. code-block:: python3
@dp.message_handle... | python | def message_handler(self, *custom_filters, commands=None, regexp=None, content_types=None, state=None,
run_task=None, **kwargs):
"""
Decorator for message handler
Examples:
Simple commands handler:
.. code-block:: python3
@dp.message_handle... | [
"def",
"message_handler",
"(",
"self",
",",
"*",
"custom_filters",
",",
"commands",
"=",
"None",
",",
"regexp",
"=",
"None",
",",
"content_types",
"=",
"None",
",",
"state",
"=",
"None",
",",
"run_task",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
... | Decorator for message handler
Examples:
Simple commands handler:
.. code-block:: python3
@dp.message_handler(commands=['start', 'welcome', 'about'])
async def cmd_handler(message: types.Message):
Filter messages by regular expression:
.. code-block::... | [
"Decorator",
"for",
"message",
"handler"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/dispatcher/dispatcher.py#L355-L432 | train |
aiogram/aiogram | aiogram/dispatcher/dispatcher.py | Dispatcher.edited_message_handler | def edited_message_handler(self, *custom_filters, commands=None, regexp=None, content_types=None,
state=None, run_task=None, **kwargs):
"""
Decorator for edited message handler
You can use combination of different handlers
.. code-block:: python3
... | python | def edited_message_handler(self, *custom_filters, commands=None, regexp=None, content_types=None,
state=None, run_task=None, **kwargs):
"""
Decorator for edited message handler
You can use combination of different handlers
.. code-block:: python3
... | [
"def",
"edited_message_handler",
"(",
"self",
",",
"*",
"custom_filters",
",",
"commands",
"=",
"None",
",",
"regexp",
"=",
"None",
",",
"content_types",
"=",
"None",
",",
"state",
"=",
"None",
",",
"run_task",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
... | Decorator for edited message handler
You can use combination of different handlers
.. code-block:: python3
@dp.message_handler()
@dp.edited_message_handler()
async def msg_handler(message: types.Message):
:param commands: list of commands
:param re... | [
"Decorator",
"for",
"edited",
"message",
"handler"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/dispatcher/dispatcher.py#L458-L486 | train |
aiogram/aiogram | aiogram/dispatcher/dispatcher.py | Dispatcher.register_channel_post_handler | def register_channel_post_handler(self, callback, *custom_filters, commands=None, regexp=None, content_types=None,
state=None, run_task=None, **kwargs):
"""
Register handler for channel post
:param callback:
:param commands: list of commands
... | python | def register_channel_post_handler(self, callback, *custom_filters, commands=None, regexp=None, content_types=None,
state=None, run_task=None, **kwargs):
"""
Register handler for channel post
:param callback:
:param commands: list of commands
... | [
"def",
"register_channel_post_handler",
"(",
"self",
",",
"callback",
",",
"*",
"custom_filters",
",",
"commands",
"=",
"None",
",",
"regexp",
"=",
"None",
",",
"content_types",
"=",
"None",
",",
"state",
"=",
"None",
",",
"run_task",
"=",
"None",
",",
"*"... | Register handler for channel post
:param callback:
:param commands: list of commands
:param regexp: REGEXP
:param content_types: List of content types.
:param state:
:param custom_filters: list of custom filters
:param run_task: run callback in task (no wait resu... | [
"Register",
"handler",
"for",
"channel",
"post"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/dispatcher/dispatcher.py#L488-L510 | train |
aiogram/aiogram | aiogram/dispatcher/dispatcher.py | Dispatcher.channel_post_handler | def channel_post_handler(self, *custom_filters, commands=None, regexp=None, content_types=None,
state=None, run_task=None, **kwargs):
"""
Decorator for channel post handler
:param commands: list of commands
:param regexp: REGEXP
:param content_types:... | python | def channel_post_handler(self, *custom_filters, commands=None, regexp=None, content_types=None,
state=None, run_task=None, **kwargs):
"""
Decorator for channel post handler
:param commands: list of commands
:param regexp: REGEXP
:param content_types:... | [
"def",
"channel_post_handler",
"(",
"self",
",",
"*",
"custom_filters",
",",
"commands",
"=",
"None",
",",
"regexp",
"=",
"None",
",",
"content_types",
"=",
"None",
",",
"state",
"=",
"None",
",",
"run_task",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
... | Decorator for channel post handler
:param commands: list of commands
:param regexp: REGEXP
:param content_types: List of content types.
:param state:
:param custom_filters: list of custom filters
:param run_task: run callback in task (no wait results)
:param kwar... | [
"Decorator",
"for",
"channel",
"post",
"handler"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/dispatcher/dispatcher.py#L512-L532 | train |
aiogram/aiogram | aiogram/dispatcher/dispatcher.py | Dispatcher.register_edited_channel_post_handler | def register_edited_channel_post_handler(self, callback, *custom_filters, commands=None, regexp=None,
content_types=None, state=None, run_task=None, **kwargs):
"""
Register handler for edited channel post
:param callback:
:param commands: lis... | python | def register_edited_channel_post_handler(self, callback, *custom_filters, commands=None, regexp=None,
content_types=None, state=None, run_task=None, **kwargs):
"""
Register handler for edited channel post
:param callback:
:param commands: lis... | [
"def",
"register_edited_channel_post_handler",
"(",
"self",
",",
"callback",
",",
"*",
"custom_filters",
",",
"commands",
"=",
"None",
",",
"regexp",
"=",
"None",
",",
"content_types",
"=",
"None",
",",
"state",
"=",
"None",
",",
"run_task",
"=",
"None",
","... | Register handler for edited channel post
:param callback:
:param commands: list of commands
:param regexp: REGEXP
:param content_types: List of content types.
:param state:
:param custom_filters: list of custom filters
:param run_task: run callback in task (no wa... | [
"Register",
"handler",
"for",
"edited",
"channel",
"post"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/dispatcher/dispatcher.py#L534-L556 | train |
aiogram/aiogram | aiogram/dispatcher/dispatcher.py | Dispatcher.edited_channel_post_handler | def edited_channel_post_handler(self, *custom_filters, commands=None, regexp=None, content_types=None,
state=None, run_task=None, **kwargs):
"""
Decorator for edited channel post handler
:param commands: list of commands
:param regexp: REGEXP
... | python | def edited_channel_post_handler(self, *custom_filters, commands=None, regexp=None, content_types=None,
state=None, run_task=None, **kwargs):
"""
Decorator for edited channel post handler
:param commands: list of commands
:param regexp: REGEXP
... | [
"def",
"edited_channel_post_handler",
"(",
"self",
",",
"*",
"custom_filters",
",",
"commands",
"=",
"None",
",",
"regexp",
"=",
"None",
",",
"content_types",
"=",
"None",
",",
"state",
"=",
"None",
",",
"run_task",
"=",
"None",
",",
"*",
"*",
"kwargs",
... | Decorator for edited channel post handler
:param commands: list of commands
:param regexp: REGEXP
:param content_types: List of content types.
:param custom_filters: list of custom filters
:param state:
:param run_task: run callback in task (no wait results)
:par... | [
"Decorator",
"for",
"edited",
"channel",
"post",
"handler"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/dispatcher/dispatcher.py#L558-L579 | train |
aiogram/aiogram | aiogram/dispatcher/dispatcher.py | Dispatcher.register_inline_handler | def register_inline_handler(self, callback, *custom_filters, state=None, run_task=None, **kwargs):
"""
Register handler for inline query
Example:
.. code-block:: python3
dp.register_inline_handler(some_inline_handler, lambda inline_query: True)
:param callback:
... | python | def register_inline_handler(self, callback, *custom_filters, state=None, run_task=None, **kwargs):
"""
Register handler for inline query
Example:
.. code-block:: python3
dp.register_inline_handler(some_inline_handler, lambda inline_query: True)
:param callback:
... | [
"def",
"register_inline_handler",
"(",
"self",
",",
"callback",
",",
"*",
"custom_filters",
",",
"state",
"=",
"None",
",",
"run_task",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"custom_filters",
"is",
"None",
":",
"custom_filters",
"=",
"[",
... | Register handler for inline query
Example:
.. code-block:: python3
dp.register_inline_handler(some_inline_handler, lambda inline_query: True)
:param callback:
:param custom_filters: list of custom filters
:param state:
:param run_task: run callback in task... | [
"Register",
"handler",
"for",
"inline",
"query"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/dispatcher/dispatcher.py#L581-L604 | train |
aiogram/aiogram | aiogram/dispatcher/dispatcher.py | Dispatcher.inline_handler | def inline_handler(self, *custom_filters, state=None, run_task=None, **kwargs):
"""
Decorator for inline query handler
Example:
.. code-block:: python3
@dp.inline_handler(lambda inline_query: True)
async def some_inline_handler(inline_query: types.InlineQuery)
... | python | def inline_handler(self, *custom_filters, state=None, run_task=None, **kwargs):
"""
Decorator for inline query handler
Example:
.. code-block:: python3
@dp.inline_handler(lambda inline_query: True)
async def some_inline_handler(inline_query: types.InlineQuery)
... | [
"def",
"inline_handler",
"(",
"self",
",",
"*",
"custom_filters",
",",
"state",
"=",
"None",
",",
"run_task",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"decorator",
"(",
"callback",
")",
":",
"self",
".",
"register_inline_handler",
"(",
"cal... | Decorator for inline query handler
Example:
.. code-block:: python3
@dp.inline_handler(lambda inline_query: True)
async def some_inline_handler(inline_query: types.InlineQuery)
:param state:
:param custom_filters: list of custom filters
:param run_task... | [
"Decorator",
"for",
"inline",
"query",
"handler"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/dispatcher/dispatcher.py#L606-L628 | train |
aiogram/aiogram | aiogram/dispatcher/dispatcher.py | Dispatcher.register_chosen_inline_handler | def register_chosen_inline_handler(self, callback, *custom_filters, state=None, run_task=None, **kwargs):
"""
Register handler for chosen inline query
Example:
.. code-block:: python3
dp.register_chosen_inline_handler(some_chosen_inline_handler, lambda chosen_inline_query:... | python | def register_chosen_inline_handler(self, callback, *custom_filters, state=None, run_task=None, **kwargs):
"""
Register handler for chosen inline query
Example:
.. code-block:: python3
dp.register_chosen_inline_handler(some_chosen_inline_handler, lambda chosen_inline_query:... | [
"def",
"register_chosen_inline_handler",
"(",
"self",
",",
"callback",
",",
"*",
"custom_filters",
",",
"state",
"=",
"None",
",",
"run_task",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"custom_filters",
"is",
"None",
":",
"custom_filters",
"=",
... | Register handler for chosen inline query
Example:
.. code-block:: python3
dp.register_chosen_inline_handler(some_chosen_inline_handler, lambda chosen_inline_query: True)
:param callback:
:param state:
:param custom_filters:
:param run_task: run callback in... | [
"Register",
"handler",
"for",
"chosen",
"inline",
"query"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/dispatcher/dispatcher.py#L630-L653 | train |
aiogram/aiogram | aiogram/dispatcher/dispatcher.py | Dispatcher.chosen_inline_handler | def chosen_inline_handler(self, *custom_filters, state=None, run_task=None, **kwargs):
"""
Decorator for chosen inline query handler
Example:
.. code-block:: python3
@dp.chosen_inline_handler(lambda chosen_inline_query: True)
async def some_chosen_inline_handle... | python | def chosen_inline_handler(self, *custom_filters, state=None, run_task=None, **kwargs):
"""
Decorator for chosen inline query handler
Example:
.. code-block:: python3
@dp.chosen_inline_handler(lambda chosen_inline_query: True)
async def some_chosen_inline_handle... | [
"def",
"chosen_inline_handler",
"(",
"self",
",",
"*",
"custom_filters",
",",
"state",
"=",
"None",
",",
"run_task",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"decorator",
"(",
"callback",
")",
":",
"self",
".",
"register_chosen_inline_handler",... | Decorator for chosen inline query handler
Example:
.. code-block:: python3
@dp.chosen_inline_handler(lambda chosen_inline_query: True)
async def some_chosen_inline_handler(chosen_inline_query: types.ChosenInlineResult)
:param state:
:param custom_filters:
... | [
"Decorator",
"for",
"chosen",
"inline",
"query",
"handler"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/dispatcher/dispatcher.py#L655-L677 | train |
aiogram/aiogram | aiogram/dispatcher/dispatcher.py | Dispatcher.register_callback_query_handler | def register_callback_query_handler(self, callback, *custom_filters, state=None, run_task=None, **kwargs):
"""
Register handler for callback query
Example:
.. code-block:: python3
dp.register_callback_query_handler(some_callback_handler, lambda callback_query: True)
... | python | def register_callback_query_handler(self, callback, *custom_filters, state=None, run_task=None, **kwargs):
"""
Register handler for callback query
Example:
.. code-block:: python3
dp.register_callback_query_handler(some_callback_handler, lambda callback_query: True)
... | [
"def",
"register_callback_query_handler",
"(",
"self",
",",
"callback",
",",
"*",
"custom_filters",
",",
"state",
"=",
"None",
",",
"run_task",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"filters_set",
"=",
"self",
".",
"filters_factory",
".",
"resolve"... | Register handler for callback query
Example:
.. code-block:: python3
dp.register_callback_query_handler(some_callback_handler, lambda callback_query: True)
:param callback:
:param state:
:param custom_filters:
:param run_task: run callback in task (no wait... | [
"Register",
"handler",
"for",
"callback",
"query"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/dispatcher/dispatcher.py#L679-L699 | train |
aiogram/aiogram | aiogram/dispatcher/dispatcher.py | Dispatcher.callback_query_handler | def callback_query_handler(self, *custom_filters, state=None, run_task=None, **kwargs):
"""
Decorator for callback query handler
Example:
.. code-block:: python3
@dp.callback_query_handler(lambda callback_query: True)
async def some_callback_handler(callback_qu... | python | def callback_query_handler(self, *custom_filters, state=None, run_task=None, **kwargs):
"""
Decorator for callback query handler
Example:
.. code-block:: python3
@dp.callback_query_handler(lambda callback_query: True)
async def some_callback_handler(callback_qu... | [
"def",
"callback_query_handler",
"(",
"self",
",",
"*",
"custom_filters",
",",
"state",
"=",
"None",
",",
"run_task",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"decorator",
"(",
"callback",
")",
":",
"self",
".",
"register_callback_query_handler... | Decorator for callback query handler
Example:
.. code-block:: python3
@dp.callback_query_handler(lambda callback_query: True)
async def some_callback_handler(callback_query: types.CallbackQuery)
:param state:
:param custom_filters:
:param run_task: run... | [
"Decorator",
"for",
"callback",
"query",
"handler"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/dispatcher/dispatcher.py#L701-L722 | train |
aiogram/aiogram | aiogram/dispatcher/dispatcher.py | Dispatcher.register_shipping_query_handler | def register_shipping_query_handler(self, callback, *custom_filters, state=None, run_task=None,
**kwargs):
"""
Register handler for shipping query
Example:
.. code-block:: python3
dp.register_shipping_query_handler(some_shipping_quer... | python | def register_shipping_query_handler(self, callback, *custom_filters, state=None, run_task=None,
**kwargs):
"""
Register handler for shipping query
Example:
.. code-block:: python3
dp.register_shipping_query_handler(some_shipping_quer... | [
"def",
"register_shipping_query_handler",
"(",
"self",
",",
"callback",
",",
"*",
"custom_filters",
",",
"state",
"=",
"None",
",",
"run_task",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"filters_set",
"=",
"self",
".",
"filters_factory",
".",
"resolve"... | Register handler for shipping query
Example:
.. code-block:: python3
dp.register_shipping_query_handler(some_shipping_query_handler, lambda shipping_query: True)
:param callback:
:param state:
:param custom_filters:
:param run_task: run callback in task (n... | [
"Register",
"handler",
"for",
"shipping",
"query"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/dispatcher/dispatcher.py#L724-L745 | train |
aiogram/aiogram | aiogram/dispatcher/dispatcher.py | Dispatcher.shipping_query_handler | def shipping_query_handler(self, *custom_filters, state=None, run_task=None, **kwargs):
"""
Decorator for shipping query handler
Example:
.. code-block:: python3
@dp.shipping_query_handler(lambda shipping_query: True)
async def some_shipping_query_handler(shipp... | python | def shipping_query_handler(self, *custom_filters, state=None, run_task=None, **kwargs):
"""
Decorator for shipping query handler
Example:
.. code-block:: python3
@dp.shipping_query_handler(lambda shipping_query: True)
async def some_shipping_query_handler(shipp... | [
"def",
"shipping_query_handler",
"(",
"self",
",",
"*",
"custom_filters",
",",
"state",
"=",
"None",
",",
"run_task",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"decorator",
"(",
"callback",
")",
":",
"self",
".",
"register_shipping_query_handler... | Decorator for shipping query handler
Example:
.. code-block:: python3
@dp.shipping_query_handler(lambda shipping_query: True)
async def some_shipping_query_handler(shipping_query: types.ShippingQuery)
:param state:
:param custom_filters:
:param run_tas... | [
"Decorator",
"for",
"shipping",
"query",
"handler"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/dispatcher/dispatcher.py#L747-L768 | train |
aiogram/aiogram | aiogram/dispatcher/dispatcher.py | Dispatcher.register_pre_checkout_query_handler | def register_pre_checkout_query_handler(self, callback, *custom_filters, state=None, run_task=None, **kwargs):
"""
Register handler for pre-checkout query
Example:
.. code-block:: python3
dp.register_pre_checkout_query_handler(some_pre_checkout_query_handler, lambda shippi... | python | def register_pre_checkout_query_handler(self, callback, *custom_filters, state=None, run_task=None, **kwargs):
"""
Register handler for pre-checkout query
Example:
.. code-block:: python3
dp.register_pre_checkout_query_handler(some_pre_checkout_query_handler, lambda shippi... | [
"def",
"register_pre_checkout_query_handler",
"(",
"self",
",",
"callback",
",",
"*",
"custom_filters",
",",
"state",
"=",
"None",
",",
"run_task",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"filters_set",
"=",
"self",
".",
"filters_factory",
".",
"reso... | Register handler for pre-checkout query
Example:
.. code-block:: python3
dp.register_pre_checkout_query_handler(some_pre_checkout_query_handler, lambda shipping_query: True)
:param callback:
:param state:
:param custom_filters:
:param run_task: run callbac... | [
"Register",
"handler",
"for",
"pre",
"-",
"checkout",
"query"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/dispatcher/dispatcher.py#L770-L790 | train |
aiogram/aiogram | aiogram/dispatcher/dispatcher.py | Dispatcher.pre_checkout_query_handler | def pre_checkout_query_handler(self, *custom_filters, state=None, run_task=None, **kwargs):
"""
Decorator for pre-checkout query handler
Example:
.. code-block:: python3
@dp.pre_checkout_query_handler(lambda shipping_query: True)
async def some_pre_checkout_que... | python | def pre_checkout_query_handler(self, *custom_filters, state=None, run_task=None, **kwargs):
"""
Decorator for pre-checkout query handler
Example:
.. code-block:: python3
@dp.pre_checkout_query_handler(lambda shipping_query: True)
async def some_pre_checkout_que... | [
"def",
"pre_checkout_query_handler",
"(",
"self",
",",
"*",
"custom_filters",
",",
"state",
"=",
"None",
",",
"run_task",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"decorator",
"(",
"callback",
")",
":",
"self",
".",
"register_pre_checkout_query... | Decorator for pre-checkout query handler
Example:
.. code-block:: python3
@dp.pre_checkout_query_handler(lambda shipping_query: True)
async def some_pre_checkout_query_handler(shipping_query: types.ShippingQuery)
:param state:
:param custom_filters:
:p... | [
"Decorator",
"for",
"pre",
"-",
"checkout",
"query",
"handler"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/dispatcher/dispatcher.py#L792-L814 | train |
aiogram/aiogram | aiogram/dispatcher/dispatcher.py | Dispatcher.register_errors_handler | def register_errors_handler(self, callback, *custom_filters, exception=None, run_task=None, **kwargs):
"""
Register handler for errors
:param callback:
:param exception: you can make handler for specific errors type
:param run_task: run callback in task (no wait results)
... | python | def register_errors_handler(self, callback, *custom_filters, exception=None, run_task=None, **kwargs):
"""
Register handler for errors
:param callback:
:param exception: you can make handler for specific errors type
:param run_task: run callback in task (no wait results)
... | [
"def",
"register_errors_handler",
"(",
"self",
",",
"callback",
",",
"*",
"custom_filters",
",",
"exception",
"=",
"None",
",",
"run_task",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"filters_set",
"=",
"self",
".",
"filters_factory",
".",
"resolve",
... | Register handler for errors
:param callback:
:param exception: you can make handler for specific errors type
:param run_task: run callback in task (no wait results) | [
"Register",
"handler",
"for",
"errors"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/dispatcher/dispatcher.py#L830-L842 | train |
aiogram/aiogram | aiogram/dispatcher/dispatcher.py | Dispatcher.errors_handler | def errors_handler(self, *custom_filters, exception=None, run_task=None, **kwargs):
"""
Decorator for errors handler
:param exception: you can make handler for specific errors type
:param run_task: run callback in task (no wait results)
:return:
"""
def decorato... | python | def errors_handler(self, *custom_filters, exception=None, run_task=None, **kwargs):
"""
Decorator for errors handler
:param exception: you can make handler for specific errors type
:param run_task: run callback in task (no wait results)
:return:
"""
def decorato... | [
"def",
"errors_handler",
"(",
"self",
",",
"*",
"custom_filters",
",",
"exception",
"=",
"None",
",",
"run_task",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"decorator",
"(",
"callback",
")",
":",
"self",
".",
"register_errors_handler",
"(",
... | Decorator for errors handler
:param exception: you can make handler for specific errors type
:param run_task: run callback in task (no wait results)
:return: | [
"Decorator",
"for",
"errors",
"handler"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/dispatcher/dispatcher.py#L844-L858 | train |
aiogram/aiogram | aiogram/dispatcher/dispatcher.py | Dispatcher.current_state | def current_state(self, *,
chat: typing.Union[str, int, None] = None,
user: typing.Union[str, int, None] = None) -> FSMContext:
"""
Get current state for user in chat as context
.. code-block:: python3
with dp.current_state(chat=message.c... | python | def current_state(self, *,
chat: typing.Union[str, int, None] = None,
user: typing.Union[str, int, None] = None) -> FSMContext:
"""
Get current state for user in chat as context
.. code-block:: python3
with dp.current_state(chat=message.c... | [
"def",
"current_state",
"(",
"self",
",",
"*",
",",
"chat",
":",
"typing",
".",
"Union",
"[",
"str",
",",
"int",
",",
"None",
"]",
"=",
"None",
",",
"user",
":",
"typing",
".",
"Union",
"[",
"str",
",",
"int",
",",
"None",
"]",
"=",
"None",
")"... | Get current state for user in chat as context
.. code-block:: python3
with dp.current_state(chat=message.chat.id, user=message.user.id) as state:
pass
state = dp.current_state()
state.set_state('my_state')
:param chat:
:param user:
... | [
"Get",
"current",
"state",
"for",
"user",
"in",
"chat",
"as",
"context"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/dispatcher/dispatcher.py#L860-L885 | train |
aiogram/aiogram | aiogram/dispatcher/dispatcher.py | Dispatcher.throttle | async def throttle(self, key, *, rate=None, user=None, chat=None, no_error=None) -> bool:
"""
Execute throttling manager.
Returns True if limit has not exceeded otherwise raises ThrottleError or returns False
:param key: key in storage
:param rate: limit (by default is equal to ... | python | async def throttle(self, key, *, rate=None, user=None, chat=None, no_error=None) -> bool:
"""
Execute throttling manager.
Returns True if limit has not exceeded otherwise raises ThrottleError or returns False
:param key: key in storage
:param rate: limit (by default is equal to ... | [
"async",
"def",
"throttle",
"(",
"self",
",",
"key",
",",
"*",
",",
"rate",
"=",
"None",
",",
"user",
"=",
"None",
",",
"chat",
"=",
"None",
",",
"no_error",
"=",
"None",
")",
"->",
"bool",
":",
"if",
"not",
"self",
".",
"storage",
".",
"has_buck... | Execute throttling manager.
Returns True if limit has not exceeded otherwise raises ThrottleError or returns False
:param key: key in storage
:param rate: limit (by default is equal to default rate limit)
:param user: user id
:param chat: chat id
:param no_error: return ... | [
"Execute",
"throttling",
"manager",
".",
"Returns",
"True",
"if",
"limit",
"has",
"not",
"exceeded",
"otherwise",
"raises",
"ThrottleError",
"or",
"returns",
"False"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/dispatcher/dispatcher.py#L887-L942 | train |
aiogram/aiogram | aiogram/dispatcher/dispatcher.py | Dispatcher.check_key | async def check_key(self, key, chat=None, user=None):
"""
Get information about key in bucket
:param key:
:param chat:
:param user:
:return:
"""
if not self.storage.has_bucket():
raise RuntimeError('This storage does not provide Leaky Bucket')... | python | async def check_key(self, key, chat=None, user=None):
"""
Get information about key in bucket
:param key:
:param chat:
:param user:
:return:
"""
if not self.storage.has_bucket():
raise RuntimeError('This storage does not provide Leaky Bucket')... | [
"async",
"def",
"check_key",
"(",
"self",
",",
"key",
",",
"chat",
"=",
"None",
",",
"user",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"storage",
".",
"has_bucket",
"(",
")",
":",
"raise",
"RuntimeError",
"(",
"'This storage does not provide Leaky B... | Get information about key in bucket
:param key:
:param chat:
:param user:
:return: | [
"Get",
"information",
"about",
"key",
"in",
"bucket"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/dispatcher/dispatcher.py#L944-L962 | train |
aiogram/aiogram | aiogram/dispatcher/dispatcher.py | Dispatcher.release_key | async def release_key(self, key, chat=None, user=None):
"""
Release blocked key
:param key:
:param chat:
:param user:
:return:
"""
if not self.storage.has_bucket():
raise RuntimeError('This storage does not provide Leaky Bucket')
if u... | python | async def release_key(self, key, chat=None, user=None):
"""
Release blocked key
:param key:
:param chat:
:param user:
:return:
"""
if not self.storage.has_bucket():
raise RuntimeError('This storage does not provide Leaky Bucket')
if u... | [
"async",
"def",
"release_key",
"(",
"self",
",",
"key",
",",
"chat",
"=",
"None",
",",
"user",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"storage",
".",
"has_bucket",
"(",
")",
":",
"raise",
"RuntimeError",
"(",
"'This storage does not provide Leaky... | Release blocked key
:param key:
:param chat:
:param user:
:return: | [
"Release",
"blocked",
"key"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/dispatcher/dispatcher.py#L964-L985 | train |
aiogram/aiogram | aiogram/bot/api.py | check_token | def check_token(token: str) -> bool:
"""
Validate BOT token
:param token:
:return:
"""
if any(x.isspace() for x in token):
raise exceptions.ValidationError('Token is invalid!')
left, sep, right = token.partition(':')
if (not sep) or (not left.isdigit()) or (len(left) < 3):
... | python | def check_token(token: str) -> bool:
"""
Validate BOT token
:param token:
:return:
"""
if any(x.isspace() for x in token):
raise exceptions.ValidationError('Token is invalid!')
left, sep, right = token.partition(':')
if (not sep) or (not left.isdigit()) or (len(left) < 3):
... | [
"def",
"check_token",
"(",
"token",
":",
"str",
")",
"->",
"bool",
":",
"if",
"any",
"(",
"x",
".",
"isspace",
"(",
")",
"for",
"x",
"in",
"token",
")",
":",
"raise",
"exceptions",
".",
"ValidationError",
"(",
"'Token is invalid!'",
")",
"left",
",",
... | Validate BOT token
:param token:
:return: | [
"Validate",
"BOT",
"token"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/bot/api.py#L20-L34 | train |
aiogram/aiogram | aiogram/bot/api.py | compose_data | def compose_data(params=None, files=None):
"""
Prepare request data
:param params:
:param files:
:return:
"""
data = aiohttp.formdata.FormData(quote_fields=False)
if params:
for key, value in params.items():
data.add_field(key, str(value))
if files:
for... | python | def compose_data(params=None, files=None):
"""
Prepare request data
:param params:
:param files:
:return:
"""
data = aiohttp.formdata.FormData(quote_fields=False)
if params:
for key, value in params.items():
data.add_field(key, str(value))
if files:
for... | [
"def",
"compose_data",
"(",
"params",
"=",
"None",
",",
"files",
"=",
"None",
")",
":",
"data",
"=",
"aiohttp",
".",
"formdata",
".",
"FormData",
"(",
"quote_fields",
"=",
"False",
")",
"if",
"params",
":",
"for",
"key",
",",
"value",
"in",
"params",
... | Prepare request data
:param params:
:param files:
:return: | [
"Prepare",
"request",
"data"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/bot/api.py#L115-L143 | train |
aiogram/aiogram | aiogram/types/user.py | User.full_name | def full_name(self):
"""
You can get full name of user.
:return: str
"""
full_name = self.first_name
if self.last_name:
full_name += ' ' + self.last_name
return full_name | python | def full_name(self):
"""
You can get full name of user.
:return: str
"""
full_name = self.first_name
if self.last_name:
full_name += ' ' + self.last_name
return full_name | [
"def",
"full_name",
"(",
"self",
")",
":",
"full_name",
"=",
"self",
".",
"first_name",
"if",
"self",
".",
"last_name",
":",
"full_name",
"+=",
"' '",
"+",
"self",
".",
"last_name",
"return",
"full_name"
] | You can get full name of user.
:return: str | [
"You",
"can",
"get",
"full",
"name",
"of",
"user",
"."
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/types/user.py#L24-L33 | train |
aiogram/aiogram | aiogram/types/user.py | User.locale | def locale(self) -> babel.core.Locale or None:
"""
Get user's locale
:return: :class:`babel.core.Locale`
"""
if not self.language_code:
return None
if not hasattr(self, '_locale'):
setattr(self, '_locale', babel.core.Locale.parse(self.language_cod... | python | def locale(self) -> babel.core.Locale or None:
"""
Get user's locale
:return: :class:`babel.core.Locale`
"""
if not self.language_code:
return None
if not hasattr(self, '_locale'):
setattr(self, '_locale', babel.core.Locale.parse(self.language_cod... | [
"def",
"locale",
"(",
"self",
")",
"->",
"babel",
".",
"core",
".",
"Locale",
"or",
"None",
":",
"if",
"not",
"self",
".",
"language_code",
":",
"return",
"None",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_locale'",
")",
":",
"setattr",
"(",
"self"... | Get user's locale
:return: :class:`babel.core.Locale` | [
"Get",
"user",
"s",
"locale"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/types/user.py#L48-L58 | train |
aiogram/aiogram | aiogram/types/mixins.py | Downloadable.get_file | async def get_file(self):
"""
Get file information
:return: :obj:`aiogram.types.File`
"""
if hasattr(self, 'file_path'):
return self
else:
return await self.bot.get_file(self.file_id) | python | async def get_file(self):
"""
Get file information
:return: :obj:`aiogram.types.File`
"""
if hasattr(self, 'file_path'):
return self
else:
return await self.bot.get_file(self.file_id) | [
"async",
"def",
"get_file",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'file_path'",
")",
":",
"return",
"self",
"else",
":",
"return",
"await",
"self",
".",
"bot",
".",
"get_file",
"(",
"self",
".",
"file_id",
")"
] | Get file information
:return: :obj:`aiogram.types.File` | [
"Get",
"file",
"information"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/types/mixins.py#L37-L46 | train |
aiogram/aiogram | aiogram/dispatcher/middlewares.py | MiddlewareManager.trigger | async def trigger(self, action: str, args: typing.Iterable):
"""
Call action to middlewares with args lilt.
:param action:
:param args:
:return:
"""
for app in self.applications:
await app.trigger(action, args) | python | async def trigger(self, action: str, args: typing.Iterable):
"""
Call action to middlewares with args lilt.
:param action:
:param args:
:return:
"""
for app in self.applications:
await app.trigger(action, args) | [
"async",
"def",
"trigger",
"(",
"self",
",",
"action",
":",
"str",
",",
"args",
":",
"typing",
".",
"Iterable",
")",
":",
"for",
"app",
"in",
"self",
".",
"applications",
":",
"await",
"app",
".",
"trigger",
"(",
"action",
",",
"args",
")"
] | Call action to middlewares with args lilt.
:param action:
:param args:
:return: | [
"Call",
"action",
"to",
"middlewares",
"with",
"args",
"lilt",
"."
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/dispatcher/middlewares.py#L41-L50 | train |
aiogram/aiogram | aiogram/dispatcher/middlewares.py | BaseMiddleware.trigger | async def trigger(self, action, args):
"""
Trigger action.
:param action:
:param args:
:return:
"""
handler_name = f"on_{action}"
handler = getattr(self, handler_name, None)
if not handler:
return None
await handler(*args) | python | async def trigger(self, action, args):
"""
Trigger action.
:param action:
:param args:
:return:
"""
handler_name = f"on_{action}"
handler = getattr(self, handler_name, None)
if not handler:
return None
await handler(*args) | [
"async",
"def",
"trigger",
"(",
"self",
",",
"action",
",",
"args",
")",
":",
"handler_name",
"=",
"f\"on_{action}\"",
"handler",
"=",
"getattr",
"(",
"self",
",",
"handler_name",
",",
"None",
")",
"if",
"not",
"handler",
":",
"return",
"None",
"await",
... | Trigger action.
:param action:
:param args:
:return: | [
"Trigger",
"action",
"."
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/dispatcher/middlewares.py#L91-L103 | train |
aiogram/aiogram | aiogram/utils/markdown.py | quote_html | def quote_html(content):
"""
Quote HTML symbols
All <, >, & and " symbols that are not a part of a tag or
an HTML entity must be replaced with the corresponding HTML entities
(< with < > with > & with & and " with ").
:param content: str
:return: str
"""
new_content = ... | python | def quote_html(content):
"""
Quote HTML symbols
All <, >, & and " symbols that are not a part of a tag or
an HTML entity must be replaced with the corresponding HTML entities
(< with < > with > & with & and " with ").
:param content: str
:return: str
"""
new_content = ... | [
"def",
"quote_html",
"(",
"content",
")",
":",
"new_content",
"=",
"''",
"for",
"symbol",
"in",
"content",
":",
"new_content",
"+=",
"HTML_QUOTES_MAP",
"[",
"symbol",
"]",
"if",
"symbol",
"in",
"_HQS",
"else",
"symbol",
"return",
"new_content"
] | Quote HTML symbols
All <, >, & and " symbols that are not a part of a tag or
an HTML entity must be replaced with the corresponding HTML entities
(< with < > with > & with & and " with ").
:param content: str
:return: str | [
"Quote",
"HTML",
"symbols"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/utils/markdown.py#L39-L53 | train |
aiogram/aiogram | aiogram/contrib/fsm_storage/redis.py | migrate_redis1_to_redis2 | async def migrate_redis1_to_redis2(storage1: RedisStorage, storage2: RedisStorage2):
"""
Helper for migrating from RedisStorage to RedisStorage2
:param storage1: instance of RedisStorage
:param storage2: instance of RedisStorage2
:return:
"""
if not isinstance(storage1, RedisStorage): # be... | python | async def migrate_redis1_to_redis2(storage1: RedisStorage, storage2: RedisStorage2):
"""
Helper for migrating from RedisStorage to RedisStorage2
:param storage1: instance of RedisStorage
:param storage2: instance of RedisStorage2
:return:
"""
if not isinstance(storage1, RedisStorage): # be... | [
"async",
"def",
"migrate_redis1_to_redis2",
"(",
"storage1",
":",
"RedisStorage",
",",
"storage2",
":",
"RedisStorage2",
")",
":",
"if",
"not",
"isinstance",
"(",
"storage1",
",",
"RedisStorage",
")",
":",
"# better than assertion",
"raise",
"TypeError",
"(",
"f\"... | Helper for migrating from RedisStorage to RedisStorage2
:param storage1: instance of RedisStorage
:param storage2: instance of RedisStorage2
:return: | [
"Helper",
"for",
"migrating",
"from",
"RedisStorage",
"to",
"RedisStorage2"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/contrib/fsm_storage/redis.py#L378-L403 | train |
aiogram/aiogram | aiogram/contrib/fsm_storage/redis.py | RedisStorage.get_record | async def get_record(self, *,
chat: typing.Union[str, int, None] = None,
user: typing.Union[str, int, None] = None) -> typing.Dict:
"""
Get record from storage
:param chat:
:param user:
:return:
"""
chat, user = s... | python | async def get_record(self, *,
chat: typing.Union[str, int, None] = None,
user: typing.Union[str, int, None] = None) -> typing.Dict:
"""
Get record from storage
:param chat:
:param user:
:return:
"""
chat, user = s... | [
"async",
"def",
"get_record",
"(",
"self",
",",
"*",
",",
"chat",
":",
"typing",
".",
"Union",
"[",
"str",
",",
"int",
",",
"None",
"]",
"=",
"None",
",",
"user",
":",
"typing",
".",
"Union",
"[",
"str",
",",
"int",
",",
"None",
"]",
"=",
"None... | Get record from storage
:param chat:
:param user:
:return: | [
"Get",
"record",
"from",
"storage"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/contrib/fsm_storage/redis.py#L77-L94 | train |
aiogram/aiogram | aiogram/contrib/fsm_storage/redis.py | RedisStorage.set_record | async def set_record(self, *, chat: typing.Union[str, int, None] = None, user: typing.Union[str, int, None] = None,
state=None, data=None, bucket=None):
"""
Write record to storage
:param bucket:
:param chat:
:param user:
:param state:
:p... | python | async def set_record(self, *, chat: typing.Union[str, int, None] = None, user: typing.Union[str, int, None] = None,
state=None, data=None, bucket=None):
"""
Write record to storage
:param bucket:
:param chat:
:param user:
:param state:
:p... | [
"async",
"def",
"set_record",
"(",
"self",
",",
"*",
",",
"chat",
":",
"typing",
".",
"Union",
"[",
"str",
",",
"int",
",",
"None",
"]",
"=",
"None",
",",
"user",
":",
"typing",
".",
"Union",
"[",
"str",
",",
"int",
",",
"None",
"]",
"=",
"None... | Write record to storage
:param bucket:
:param chat:
:param user:
:param state:
:param data:
:return: | [
"Write",
"record",
"to",
"storage"
] | 2af930149ce2482547721e2c8755c10307295e48 | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/contrib/fsm_storage/redis.py#L96-L119 | train |
niklasf/python-chess | chess/syzygy.py | Tablebase.add_directory | def add_directory(self, directory: PathLike, *, load_wdl: bool = True, load_dtz: bool = True) -> int:
"""
Adds tables from a directory.
By default all available tables with the correct file names
(e.g. WDL files like ``KQvKN.rtbw`` and DTZ files like ``KRBvK.rtbz``)
are added.
... | python | def add_directory(self, directory: PathLike, *, load_wdl: bool = True, load_dtz: bool = True) -> int:
"""
Adds tables from a directory.
By default all available tables with the correct file names
(e.g. WDL files like ``KQvKN.rtbw`` and DTZ files like ``KRBvK.rtbz``)
are added.
... | [
"def",
"add_directory",
"(",
"self",
",",
"directory",
":",
"PathLike",
",",
"*",
",",
"load_wdl",
":",
"bool",
"=",
"True",
",",
"load_dtz",
":",
"bool",
"=",
"True",
")",
"->",
"int",
":",
"num",
"=",
"0",
"directory",
"=",
"os",
".",
"path",
"."... | Adds tables from a directory.
By default all available tables with the correct file names
(e.g. WDL files like ``KQvKN.rtbw`` and DTZ files like ``KRBvK.rtbz``)
are added.
The relevant files are lazily opened when the tablebase is actually
probed.
Returns the number of... | [
"Adds",
"tables",
"from",
"a",
"directory",
"."
] | d91f986ca3e046b300a0d7d9ee2a13b07610fe1a | https://github.com/niklasf/python-chess/blob/d91f986ca3e046b300a0d7d9ee2a13b07610fe1a/chess/syzygy.py#L1506-L1539 | train |
niklasf/python-chess | chess/syzygy.py | Tablebase.probe_dtz | def probe_dtz(self, board: chess.Board) -> int:
"""
Probes DTZ tables for distance to zero information.
Both DTZ and WDL tables are required in order to probe for DTZ.
Returns a positive value if the side to move is winning, ``0`` if the
position is a draw and a negative value ... | python | def probe_dtz(self, board: chess.Board) -> int:
"""
Probes DTZ tables for distance to zero information.
Both DTZ and WDL tables are required in order to probe for DTZ.
Returns a positive value if the side to move is winning, ``0`` if the
position is a draw and a negative value ... | [
"def",
"probe_dtz",
"(",
"self",
",",
"board",
":",
"chess",
".",
"Board",
")",
"->",
"int",
":",
"v",
"=",
"self",
".",
"probe_dtz_no_ep",
"(",
"board",
")",
"if",
"not",
"board",
".",
"ep_square",
"or",
"self",
".",
"variant",
".",
"captures_compulso... | Probes DTZ tables for distance to zero information.
Both DTZ and WDL tables are required in order to probe for DTZ.
Returns a positive value if the side to move is winning, ``0`` if the
position is a draw and a negative value if the side to move is losing.
More precisely:
+---... | [
"Probes",
"DTZ",
"tables",
"for",
"distance",
"to",
"zero",
"information",
"."
] | d91f986ca3e046b300a0d7d9ee2a13b07610fe1a | https://github.com/niklasf/python-chess/blob/d91f986ca3e046b300a0d7d9ee2a13b07610fe1a/chess/syzygy.py#L1809-L1915 | train |
niklasf/python-chess | chess/pgn.py | GameNode.board | def board(self, *, _cache: bool = True) -> chess.Board:
"""
Gets a board with the position of the node.
It's a copy, so modifying the board will not alter the game.
"""
if self.board_cached is not None:
board = self.board_cached()
if board is not None:
... | python | def board(self, *, _cache: bool = True) -> chess.Board:
"""
Gets a board with the position of the node.
It's a copy, so modifying the board will not alter the game.
"""
if self.board_cached is not None:
board = self.board_cached()
if board is not None:
... | [
"def",
"board",
"(",
"self",
",",
"*",
",",
"_cache",
":",
"bool",
"=",
"True",
")",
"->",
"chess",
".",
"Board",
":",
"if",
"self",
".",
"board_cached",
"is",
"not",
"None",
":",
"board",
"=",
"self",
".",
"board_cached",
"(",
")",
"if",
"board",
... | Gets a board with the position of the node.
It's a copy, so modifying the board will not alter the game. | [
"Gets",
"a",
"board",
"with",
"the",
"position",
"of",
"the",
"node",
"."
] | d91f986ca3e046b300a0d7d9ee2a13b07610fe1a | https://github.com/niklasf/python-chess/blob/d91f986ca3e046b300a0d7d9ee2a13b07610fe1a/chess/pgn.py#L139-L157 | train |
niklasf/python-chess | chess/pgn.py | GameNode.root | def root(self) -> "GameNode":
"""Gets the root node, i.e., the game."""
node = self
while node.parent:
node = node.parent
return node | python | def root(self) -> "GameNode":
"""Gets the root node, i.e., the game."""
node = self
while node.parent:
node = node.parent
return node | [
"def",
"root",
"(",
"self",
")",
"->",
"\"GameNode\"",
":",
"node",
"=",
"self",
"while",
"node",
".",
"parent",
":",
"node",
"=",
"node",
".",
"parent",
"return",
"node"
] | Gets the root node, i.e., the game. | [
"Gets",
"the",
"root",
"node",
"i",
".",
"e",
".",
"the",
"game",
"."
] | d91f986ca3e046b300a0d7d9ee2a13b07610fe1a | https://github.com/niklasf/python-chess/blob/d91f986ca3e046b300a0d7d9ee2a13b07610fe1a/chess/pgn.py#L177-L184 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.