{"id":335859,"date":"2022-07-18T15:00:43","date_gmt":"2022-07-18T15:00:43","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=335859"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=335859","title":{"rendered":"<span>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u044c \u0434\u043b\u044f Telegram bot api \u043d\u0430 Python<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442! \u042f \u043d\u0435\u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a, \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 &#8212; \u044d\u0442\u043e \u043c\u043e\u0435 \u0445\u043e\u0431\u0431\u0438. \u0418 &#171;\u043f\u043e\u0434\u0445\u043e\u0431\u0431\u0438&#187; \u044d\u0442\u043e\u0433\u043e \u0445\u043e\u0431\u0431\u0438 &#8212; \u0431\u0440\u0430\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u0445 \u0430\u043d\u0430\u043b\u043e\u0433\u0438, \u043f\u0440\u043e\u0441\u0442\u043e, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0439 \u0442\u0435\u043c\u0435 (\u0430 \u0435\u0449\u0435 \u043f\u0435\u0440\u0435\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u0451 \u043f\u043e \u0441\u0432\u043e\u0435\u043c\u0443 \u0436\u0435\u043b\u0430\u043d\u0438\u044e :)). \u0412 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437, \u044f \u0440\u0435\u0448\u0438\u043b \u0437\u0430\u043a\u043e\u0434\u0438\u0442\u044c \u0430\u043d\u0430\u043b\u043e\u0433 \u0434\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u043a\u0430\u043a aiogram \u0438\u043b\u0438 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f PyTelegramBotApi.<\/p>\n<h2>\u0414\u0438\u0441\u043a\u043b\u0435\u0439\u043c\u0435\u0440<\/h2>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0430\u043c \u043f\u043e\u043a\u0430\u0436\u0443\u0442\u0441\u044f \u0441\u0442\u0440\u0430\u043d\u043d\u044b\u043c\u0438, \u0432 \u043c\u043e\u0435\u043c \u043a\u043e\u0434\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u0435\u0439, \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0438 \u0442.\u0434. \u042f \u043f\u043b\u043e\u0445\u043e \u0437\u043d\u0430\u043a\u043e\u043c \u0441 \u0442\u0435\u043c\u043e\u0439 \u0438 \u043d\u0435 \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0432 \u0441\u0435\u0440\u044c\u0435\u0437\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445. \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u044f \u0431\u0443\u0434\u0443 \u043e\u0447\u0435\u043d\u044c \u0440\u0430\u0434, \u0435\u0441\u043b\u0438 \u0432\u044b \u0443\u0434\u0435\u043b\u0438\u0442\u0435 \u043c\u043d\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u0430\u0448\u0435\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438 \u043d\u0430\u043f\u0438\u0448\u0435\u0442\u0435 \u043e\u0431 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u0445 \u043c\u043e\u0435\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445. \u0412 \u0446\u0435\u043b\u043e\u043c, \u0440\u0430\u0434\u0438 \u044d\u0442\u043e\u0433\u043e \u044f \u0438 \u043f\u0438\u0448\u0443 \u0441\u0442\u0430\u0442\u044c\u044e. \u0421\u043f\u0430\u0441\u0438\u0431\u043e!)<\/p>\n<h2>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 pyTelegramBotApi<\/h2>\n<p>\u0414\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438, \u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u043c\u043e\u0434\u0443\u043b\u0435\u043c pyTelegramBotApi, \u0437\u0430 \u044d\u0442\u043e \u0432\u0440\u0435\u043c\u044f, \u043c\u043d\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u0437\u0430\u043b\u0435\u0437\u0430\u0442\u044c \u0432 \u0435\u0433\u043e \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u0438 \u044f \u0437\u0430\u043c\u0435\u0442\u0438\u043b \u0434\u0435\u0442\u0430\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u0430\u0441\u044c &#8212; \u044d\u0442\u043e \u043c\u043d\u043e\u0433\u043e\u043a\u0440\u0430\u0442\u043d\u043e\u0435 \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u0434\u0430. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0435\u0440\u0432\u0430\u044f \u0436\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044f process_updates, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u0435\u043b\u0438\u0442 \u0430\u043f\u0434\u0435\u0439\u0442\u044b, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u043e\u0442 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u0430 \u043d\u0430 \u0442\u0438\u043f\u044b \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u043d\u0438\u0445 \u0441\u0432\u043e\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e process_&#8230;_updates, \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442 \u043d\u0430\u0441 \u0432\u043e\u0442 \u0442\u0430\u043a\u0438\u043c:<\/p>\n<pre><code class=\"python\">new_messages = None new_edited_messages = None # \u0422\u0443\u0442 \u0435\u0449\u0435 11 \u0442\u0430\u043a\u0438\u0445 \u0436\u0435 \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u0438\u0439 chat_join_request = None  for update in updates:     logger.debug('Processing updates: {0}'.format(update))     if update.message:         if new_messages is None: new_messages = []         new_messages.append(update.message)     if update.edited_message:         if new_edited_messages is None: new_edited_messages = []         new_edited_messages.append(update.edited_message)     ... # \u0422\u0443\u0442 \u0435\u0449\u0435 11 \u0442\u0430\u043a\u0438\u0445 \u0436\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0439     if update.chat_join_request:         if chat_join_request is None: chat_join_request = []         chat_join_request.append(update.chat_join_request) if new_messages:     await self.process_new_messages(new_messages) if new_edited_messages:     await self.process_new_edited_messages(new_edited_messages) ... # \u0418 \u0442\u0443\u0442 \u0435\u0449\u0435 11 \u0442\u0430\u043a\u0438\u0445 \u0436\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 if chat_join_request:     await self.process_chat_join_request(chat_join_request)<\/code><\/pre>\n<p>\u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430, \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u044b Telegram Bot Api, \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"python\">async def send_message(         self, chat_id: Union[int, str], text: str,          parse_mode: Optional[str]=None,          entities: Optional[List[types.MessageEntity]]=None,         disable_web_page_preview: Optional[bool]=None,          disable_notification: Optional[bool]=None,          protect_content: Optional[bool]=None,         reply_to_message_id: Optional[int]=None,          allow_sending_without_reply: Optional[bool]=None,         reply_markup: Optional[REPLY_MARKUP_TYPES]=None,         timeout: Optional[int]=None) -> types.Message:<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0432\u043d\u0443\u0442\u0440\u0438 \u043c\u043e\u0434\u0443\u043b\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u043f\u043e\u043b\u043d\u0430\u044f \u043a\u043e\u043f\u0438\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 API, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435, \u0432 \u043d\u0435\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u0432\u0441\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u043c\u0435\u0442\u043e\u0434\u043e\u0432.<\/p>\n<p>\u041d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u044d\u0442\u043e:<\/p>\n<ol>\n<li>\n<p>\u0411\u0435\u0441\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u043d\u043e.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0442\u0430\u043a\u0438\u043c \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f\u043c, \u043a\u043e\u0433\u0434\u0430 API \u0431\u044b\u043b \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d, \u0430 \u043c\u043e\u0434\u0443\u043b\u044c \u0435\u0449\u0435 \u043d\u0435\u0442 &#8212; \u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0443 \u043c\u043e\u0434\u0443\u043b\u044f \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0432 \u043d\u0435\u043c \u0440\u043e\u0432\u043d\u043e \u0442\u0443 \u0436\u0435 \u043b\u043e\u0433\u0438\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u044b\u043b\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0430 \u0432 API. \u042f \u043b\u0438\u0447\u043d\u043e \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0435\u0439, \u043a\u043e\u0433\u0434\u0430 \u043c\u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0441\u0430\u043c\u043e\u043c\u0443 \u0434\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u044c, \u0442\u0430\u043a \u043a\u0430\u043a \u0432\u044b\u0448\u043b\u0430 \u043d\u043e\u0432\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f api, \u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0435\u0449\u0435 \u043d\u0435 \u0443\u0441\u043f\u0435\u043b \u0435\u0433\u043e \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c.<\/p>\n<\/li>\n<li>\n<p>\u0418, \u0435\u0441\u043b\u0438 \u044f \u043d\u0435 \u043e\u0448\u0438\u0431\u0430\u044e\u0441\u044c, \u043d\u0430\u0440\u0443\u0448\u0430\u0435\u0442 \u043f\u0440\u0438\u043d\u0446\u0438\u043f DRY: \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043e\u0434\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043b\u043e\u0433\u0438\u043a\u0438 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e \u0438 \u0432 \u043a\u043e\u0434\u0435 API, \u0438 \u0432 \u043a\u043e\u0434\u0435 \u043c\u043e\u0434\u0443\u043b\u044f.<\/p>\n<\/li>\n<\/ol>\n<h2>\u0417\u0430\u0434\u0443\u043c\u043a\u0430<\/h2>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u044f \u0440\u0435\u0448\u0438\u043b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u043c\u043e\u0434\u0443\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u043b\u0438\u0448\u0438\u0442\u044c \u0432\u0441\u0435\u0445 \u044d\u0442\u0438\u0445 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u043e\u0432. \u041c\u043e\u0434\u0443\u043b\u044c \u044d\u0442\u043e\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c &#171;light&#187; &#8212; \u0442\u043e \u0435\u0441\u0442\u044c \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b API. \u0418 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u043a\u0442\u043e-\u0442\u043e \u0437\u0430\u0445\u043e\u0447\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 API &#171;sendHolography&#187;, \u043c\u043e\u0434\u0443\u043b\u044c \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0435\u043f\u044f\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c, \u0442\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u043e \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u044b API, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u043f\u0440\u0438\u0448\u043b\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0443: <\/p>\n<pre><code class=\"json\">{\"ok\":false,\"error_code\":404,\"description\":\"Not Found\"}<\/code><\/pre>\n<p>\u0418\u043b\u0438 \u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u0435\u0442, \u0435\u0441\u043b\u0438 \u043a \u044d\u0442\u043e\u043c\u0443 \u043c\u043e\u043c\u0435\u043d\u0442\u0443 \u043f\u043e\u044f\u0432\u044f\u0442\u0441\u044f \u0433\u043e\u043b\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u044b \u0438 \u0441 \u043d\u0438\u043c\u0438 \u043c\u0435\u0442\u043e\u0434 &#171;sendHolography&#187;. \u0410 \u043c\u043e\u0434\u0443\u043b\u044c, \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0438 \u043e\u0442 pyTelegramBotApi \u0431\u0443\u0434\u0435\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0433\u043e\u0442\u043e\u0432 \u043a \u0442\u0430\u043a\u043e\u043c\u0443 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044e.<\/p>\n<h2>\u041d\u0430\u0447\u0438\u043d\u0430\u0435\u043c<\/h2>\n<p>\u0421\u043e\u0437\u0434\u0430\u044e \u043a\u043b\u0430\u0441\u0441 Bot, \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0432\u0441\u0435 \u043c\u0435\u0442\u043e\u0434\u044b Telegram Bot Api, \u043d\u043e \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0434\u0443\u043b\u044c \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0435\u043b \u043e\u0442 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044e \u043c\u0435\u0442\u043e\u0434 __getattr__. \u041e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043d\u0435\u043a\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u0432\u044b\u0437\u043e\u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043c\u0435\u0442\u043e\u0434, \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f. \u0422\u0430\u043a\u0436\u0435, \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u044b\u0432\u0430\u044e \u0435\u0451 \u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u044e \u0432 \u043c\u0435\u0442\u043e\u0434 &#8212; \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0435 \u0431\u044b\u043b\u043e \u043a\u0440\u0430\u0441\u0438\u0432\u043e. \u0418 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0432 \u043a\u044d\u0448, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0437\u0430\u043d\u043e\u0432\u043e \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0440\u0430\u0437.<\/p>\n<pre><code class=\"python\">from types import MethodType class Bot:     def __init__(self):         self.cache = {}            def __getattr__(self, attr: str):         if attr in cache: return self.cache[attr]                url = \"\/bot\"+self._token+\"\/\"+snake_case_to_camel_case(attr)       async def function(bot, **kwargs):           pass         method = MethodType(function, self)         self.cache[attr] = method         return method <\/code><\/pre>\n<p>\u0427\u0442\u043e\u0431\u044b \u0434\u0435\u043b\u0430\u0442\u044c \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0435 get \u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 aiohttp.ClientSession, \u043e\u0434\u043d\u0430\u043a\u043e \u0435\u0441\u043b\u0438 \u043f\u043e\u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0435\u0451 \u0432 Bot.__init__, \u0432\u044b\u0439\u0434\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0430:<\/p>\n<pre><code>The object should be created within an async function<\/code><\/pre>\n<p>\u0421\u0434\u0435\u043b\u0430\u0442\u044c __init__ \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u043c \u0442\u043e\u0436\u0435 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e &#8212; \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u0443, \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0448\u0438\u0431\u043a\u0430:<\/p>\n<pre><code>TypeError: __init__() should return None, not 'coroutine'<\/code><\/pre>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u043c\u0435\u043d\u044e \u0441\u0432\u043e\u0435\u0433\u043e \u0440\u043e\u0434\u0430 \u043a\u043e\u0441\u0442\u044b\u043b\u044c &#8212; \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e Bot.__new__ \u043a\u0430\u043a \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0443\u044e, \u0441\u043e\u0437\u0434\u0430\u043c \u0441\u0435\u0441\u0441\u0438\u044e \u0432 \u043d\u0435\u0439. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0432\u044b\u0437\u0432\u0430\u0432 __new__ \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u0443, \u0430 \u043f\u043e\u0442\u043e\u043c, \u043f\u043e\u0441\u043b\u0435 await, \u0432\u0435\u0440\u043d\u0435\u0442\u0441\u044f \u0441\u0430\u043c \u043e\u0431\u044a\u0435\u043a\u0442:<\/p>\n<pre><code class=\"python\">def __init__(self, token: str):     self._http_exceptions = {}     self._token = token     self.cache = {}      async def __new__(cls, *args, **kwargs):     obj = super().__new__(cls)     obj._session = aiohttp.ClientSession(url)     obj.__init__(*args, **kwargs)     return obj<\/code><\/pre>\n<pre><code class=\"python\">await Bot(token)<\/code><\/pre>\n<p>\u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u0431\u043b\u043e\u043a\u0435 \u043a\u043e\u0434\u0430 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e _http_exceptions. \u0417\u0430\u0447\u0435\u043c \u043e\u043d\u0430 \u043d\u0443\u0436\u043d\u0430? \u042f \u043c\u043e\u0433\u0443 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u043e \u043a\u043b\u0430\u0441\u0441\u0443 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e http \u043a\u043e\u0434\u0430 \u043e\u0448\u0438\u0431\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 telegram, \u043d\u043e \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0432 telegram bot api \u0434\u043e\u0431\u0430\u0432\u044f\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u043a\u043e\u0434\u044b \u043e\u0448\u0438\u0431\u043e\u043a? \u0418\u043b\u0438, \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c, \u0432\u044b\u0439\u0434\u0435\u0442 \u043d\u043e\u0432\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f http, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0443\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b \u043d\u043e\u0432\u044b\u0435 \u043a\u043e\u0434\u044b \u043e\u0448\u0438\u0431\u043e\u043a? \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443! \u0415\u0441\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043b\u0443\u0447\u0448\u0435!)<\/p>\n<pre><code class=\"python\">class TelegramError(Exception): pass<\/code><\/pre>\n<pre><code class=\"python\">class Bot: ...     def get_http_exception(self, number: int):         if number in self._http_exceptions:             return self._http_exceptions[number]         else:             HttpException = type(f\"TelegramError{number}\", (TelegramError,), {})             self._http_exceptions[number] = HttpException             return HttpException<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0432\u044b\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 type &#8212; \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430, \u0432\u0442\u043e\u0440\u043e\u0439 &#8212; \u043a\u043e\u0440\u0442\u0435\u0436 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c\u0441\u044f, \u0430 \u0442\u0440\u0435\u0442\u0438\u0439 &#8212; \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u0430. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0435\u0441\u043b\u0438 \u043a\u0430\u043a\u0430\u044f-\u0442\u043e \u043e\u0448\u0438\u0431\u043a\u0430 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u0435\u0440\u0432\u044b\u0439 \u0440\u0430\u0437, \u0434\u043b\u044f \u043d\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0441\u0432\u043e\u0439 \u043a\u043b\u0430\u0441\u0441, \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439\u0441\u044f \u043e\u0442 TelegramError \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u044c Bot._http_exceptions. <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0443 \u0441\u0430\u043c\u0443\u044e \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u0432 \u0440\u0430\u0437\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440.<\/p>\n<pre><code class=\"python\">async def function(bot, **kwargs):   async with bot._session.get(url, params=kwargs) as response:     response_data = await response.json()     if response_data[\"ok\"]:         return response_data[\"result\"]     else:         raise bot.get_http_exception(response_data[\"error_code\"])(           response_data[\"description\"]         )<\/code><\/pre>\n<p> \u0415\u0441\u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u044e http \u043e\u0448\u0438\u0431\u043a\u0443 &#8212; \u0441\u043e\u0437\u0434\u0430\u044e \u043d\u0443\u0436\u043d\u043e\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0438 \u0431\u0440\u043e\u0441\u0430\u044e \u0435\u0433\u043e.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0442\u044c \u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f, \u0438, \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u0435\u0441\u0442\u044c, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439. \u0412 PyTelegramBotApi \u0432\u044b\u0431\u043e\u0440 \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"python\">@bot.message_handler(commands=[\"start\", help]) def handler1: ... #\u0434\u043b\u044f \u043a\u043e\u043c\u0430\u043d\u0434 \/start \u0438 \/help  @bot.message_handler(content_types=[\"photo\"], chat_types=[\"private\"]) def handler2: ... #\u0434\u043b\u044f \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0439 \u0432 \u043b\u0438\u0447\u043d\u044b\u0445 \u0447\u0430\u0442\u0430\u0445  @bot.message_handler(func=lambda msg: msg.from_user.id in admins) def handler3: ... #\u0434\u043b\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439, \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u0435\u043b\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u0430\u0434\u043c\u0438\u043d\u043e\u0432.<\/code><\/pre>\n<p>\u041c\u0435\u043d\u044f \u043d\u0435 \u0443\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442 \u044d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u043e \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u0438\u0447\u0438\u043d\u0435: \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043c\u043d\u0435 \u043d\u0443\u0436\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u0434\u0438\u043d \u0438\u0437 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u043b\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u043f\u0440\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e, \u0447\u0442\u043e \u043e\u043d \u0430\u0434\u043c\u0438\u043d \u0438\u043b\u0438 \u0432\u043b\u0430\u0434\u0435\u043b\u0435\u0446. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0440\u0430\u0431\u043e\u0442\u0430 \u0441\u0430\u043c\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0437\u0430\u0432\u0438\u0441\u0435\u0442\u044c \u043e\u0442 \u0442\u043e\u0433\u043e, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0432\u0441\u0435 \u0442\u0430\u043a\u0438 \u0430\u0434\u043c\u0438\u043d \u0438\u043b\u0438 \u0432\u043b\u0430\u0434\u0435\u043b\u0435\u0446. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043c\u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0434\u0432\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445: \u043e\u0434\u0438\u043d \u0432 \u0444\u0438\u043b\u044c\u0442\u0440\u0435, \u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u0432 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0435 \u0438 \u044d\u0442\u043e \u043d\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e. \u0414\u0430, \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043d\u0430 \u0434\u0432\u0430: \u043e\u0434\u0438\u043d \u0434\u043b\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043e\u0442 \u0430\u0434\u043c\u0438\u043d\u043e\u0432, \u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u0434\u043b\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043e\u0442 \u0432\u043b\u0430\u0434\u0435\u043b\u044c\u0446\u0435\u0432. \u041d\u043e \u0442\u043e\u0433\u0434\u0430 \u0447\u0430\u0441\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0438, \u043e\u0431\u0449\u0443\u044e \u0434\u043b\u044f \u0430\u0434\u043c\u0438\u043d\u043e\u0432 \u0438 \u0432\u043b\u0430\u0434\u0435\u043b\u044c\u0446\u0435\u0432 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0432\u044b\u043d\u043e\u0441\u0438\u0442\u044c \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0447\u0442\u043e \u043d\u0435 \u0443\u0434\u043e\u0431\u043d\u043e.<\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u044f \u0432\u044b\u0431\u0440\u0430\u043b \u0434\u0440\u0443\u0433\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442. \u041f\u0443\u0441\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0432\u044b\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a. \u0412 \u043d\u0435\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043c\u043e\u0436\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u0430\u043a\u043e\u0435-\u0442\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u0435 &#8212; \u0438 \u043f\u043e \u043d\u0435\u043c\u0443 \u0432\u044b\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0441 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c NextHandler. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a. \u0415\u0441\u043b\u0438 \u0436\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0431\u0435\u0437 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439, \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u043c.<\/p>\n<pre><code class=\"python\">class NextHandler(Exception):     def __init__(self):         self.args = (\"don't use this error outside of light_telegram_bot handler\",)<\/code><\/pre>\n<pre><code class=\"python\">class BotPolling:     def __init__(self, bot, start_offset=0):         self._handlers = []         self._bot = bot         self._offset = start_offset      async def start(self, timeout=60, **kwargs):         try:             while 1:                 updates = await self._bot.get_updates(                   timeout=timeout,                   offset=self._offset,                   **kwargs                 )                 if updates:                     self._offset = updates[-1][\"update_id\"]+1                 for update in updates:                     for handler in self._handlers:                         try:                             await handler(update)                         except NextHandler:                             pass                         else:                             break         except Exception:             raise LightTelegramBotPollingError()                      def handler(self, f):         self._handlers.append(f)<\/code><\/pre>\n<p>\u0418 \u0432\u043e\u0442, \u0434\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f, \u0432\u043e\u0442 \u0442\u0435 \u0436\u0435 \u0442\u0440\u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0432 \u043c\u043e\u0435\u043c \u043c\u043e\u0434\u0443\u043b\u0435:<\/p>\n<pre><code class=\"python\">@bot.handler() def handler1(message): if not test_commands(message.text, [\"start\", \"help\"]):   raise NextHandler()      @bot.handler() def handler2(message): if not (\"photo\" in message) and message.chat_type == \"private\"   raise NextHandler()     @bot.handler() def handler3(message):   if not msg[\"from_user\"][\"id\"] in admins:     raise NextHandler()<\/code><\/pre>\n<p>\u0414\u0430, \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0434\u043b\u0438\u043d\u043d\u0435\u0435, \u043d\u043e, \u0437\u0430\u0442\u043e, \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u043e\u043b\u0435\u0435 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u043e. \u041e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0434\u043e\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u0435\u0449\u0435\u0439, \u043d\u0435 \u0437\u0430\u0441\u043b\u0443\u0436\u0438\u0432\u0430\u044e\u0449\u0438\u0445 \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u043d\u0438\u044f. \u0418 \u0432\u0443\u0430\u043b\u044f!<\/p>\n<p>\u041a\u043e\u0434 \u043c\u043e\u0434\u0443\u043b\u044f \u0446\u0435\u043b\u0438\u043a\u043e\u043c \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0438 <a href=\"https:\/\/github.com\/Chebotarev-Alexey\/light_telegram_bot\" rel=\"noopener noreferrer nofollow\">light_telegram_bot<\/a>, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e pip install light_telegram_bot. \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u0442\u044c\u0438!<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/677456\/\"> https:\/\/habr.com\/ru\/post\/677456\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442! \u042f \u043d\u0435\u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a, \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 &#8212; \u044d\u0442\u043e \u043c\u043e\u0435 \u0445\u043e\u0431\u0431\u0438. \u0418 &#171;\u043f\u043e\u0434\u0445\u043e\u0431\u0431\u0438&#187; \u044d\u0442\u043e\u0433\u043e \u0445\u043e\u0431\u0431\u0438 &#8212; \u0431\u0440\u0430\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0438\u0445 \u0430\u043d\u0430\u043b\u043e\u0433\u0438, \u043f\u0440\u043e\u0441\u0442\u043e, \u0447\u0442\u043e\u0431\u044b \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0439 \u0442\u0435\u043c\u0435 (\u0430 \u0435\u0449\u0435 \u043f\u0435\u0440\u0435\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u0441\u0451 \u043f\u043e \u0441\u0432\u043e\u0435\u043c\u0443 \u0436\u0435\u043b\u0430\u043d\u0438\u044e :)). \u0412 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437, \u044f \u0440\u0435\u0448\u0438\u043b \u0437\u0430\u043a\u043e\u0434\u0438\u0442\u044c \u0430\u043d\u0430\u043b\u043e\u0433 \u0434\u043b\u044f \u0442\u0430\u043a\u0438\u0445 \u043c\u043e\u0434\u0443\u043b\u0435\u0439 \u043a\u0430\u043a aiogram \u0438\u043b\u0438 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f PyTelegramBotApi.<\/p>\n<h2>\u0414\u0438\u0441\u043a\u043b\u0435\u0439\u043c\u0435\u0440<\/h2>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0430\u043c \u043f\u043e\u043a\u0430\u0436\u0443\u0442\u0441\u044f \u0441\u0442\u0440\u0430\u043d\u043d\u044b\u043c\u0438, \u0432 \u043c\u043e\u0435\u043c \u043a\u043e\u0434\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e \u0443\u044f\u0437\u0432\u0438\u043c\u043e\u0441\u0442\u0435\u0439, \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0438 \u0442.\u0434. \u042f \u043f\u043b\u043e\u0445\u043e \u0437\u043d\u0430\u043a\u043e\u043c \u0441 \u0442\u0435\u043c\u043e\u0439 \u0438 \u043d\u0435 \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0432 \u0441\u0435\u0440\u044c\u0435\u0437\u043d\u044b\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445. \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u044f \u0431\u0443\u0434\u0443 \u043e\u0447\u0435\u043d\u044c \u0440\u0430\u0434, \u0435\u0441\u043b\u0438 \u0432\u044b \u0443\u0434\u0435\u043b\u0438\u0442\u0435 \u043c\u043d\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0432\u0430\u0448\u0435\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0438 \u043d\u0430\u043f\u0438\u0448\u0435\u0442\u0435 \u043e\u0431 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u0445 \u043c\u043e\u0435\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445. \u0412 \u0446\u0435\u043b\u043e\u043c, \u0440\u0430\u0434\u0438 \u044d\u0442\u043e\u0433\u043e \u044f \u0438 \u043f\u0438\u0448\u0443 \u0441\u0442\u0430\u0442\u044c\u044e. \u0421\u043f\u0430\u0441\u0438\u0431\u043e!)<\/p>\n<h2>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 pyTelegramBotApi<\/h2>\n<p>\u0414\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438, \u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u043c\u043e\u0434\u0443\u043b\u0435\u043c pyTelegramBotApi, \u0437\u0430 \u044d\u0442\u043e \u0432\u0440\u0435\u043c\u044f, \u043c\u043d\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u043b\u043e\u0441\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u0437\u0430\u043b\u0435\u0437\u0430\u0442\u044c \u0432 \u0435\u0433\u043e \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u0438 \u044f \u0437\u0430\u043c\u0435\u0442\u0438\u043b \u0434\u0435\u0442\u0430\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043c\u043d\u0435 \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u043f\u043e\u043d\u0440\u0430\u0432\u0438\u043b\u0430\u0441\u044c &#8212; \u044d\u0442\u043e \u043c\u043d\u043e\u0433\u043e\u043a\u0440\u0430\u0442\u043d\u043e\u0435 \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u0434\u0430. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0435\u0440\u0432\u0430\u044f \u0436\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u044f process_updates, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u0435\u043b\u0438\u0442 \u0430\u043f\u0434\u0435\u0439\u0442\u044b, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u043e\u0442 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u0430 \u043d\u0430 \u0442\u0438\u043f\u044b \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u043d\u0438\u0445 \u0441\u0432\u043e\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e process_&#8230;_updates, \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442 \u043d\u0430\u0441 \u0432\u043e\u0442 \u0442\u0430\u043a\u0438\u043c:<\/p>\n<pre><code class=\"python\">new_messages = None new_edited_messages = None # \u0422\u0443\u0442 \u0435\u0449\u0435 11 \u0442\u0430\u043a\u0438\u0445 \u0436\u0435 \u043f\u0440\u0438\u0441\u0432\u043e\u0435\u043d\u0438\u0439 chat_join_request = None  for update in updates:     logger.debug('Processing updates: {0}'.format(update))     if update.message:         if new_messages is None: new_messages = []         new_messages.append(update.message)     if update.edited_message:         if new_edited_messages is None: new_edited_messages = []         new_edited_messages.append(update.edited_message)     ... # \u0422\u0443\u0442 \u0435\u0449\u0435 11 \u0442\u0430\u043a\u0438\u0445 \u0436\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0439     if update.chat_join_request:         if chat_join_request is None: chat_join_request = []         chat_join_request.append(update.chat_join_request) if new_messages:     await self.process_new_messages(new_messages) if new_edited_messages:     await self.process_new_edited_messages(new_edited_messages) ... # \u0418 \u0442\u0443\u0442 \u0435\u0449\u0435 11 \u0442\u0430\u043a\u0438\u0445 \u0436\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 if chat_join_request:     await self.process_chat_join_request(chat_join_request)<\/code><\/pre>\n<p>\u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430, \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u044b Telegram Bot Api, \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"python\">async def send_message(         self, chat_id: Union[int, str], text: str,          parse_mode: Optional[str]=None,          entities: Optional[List[types.MessageEntity]]=None,         disable_web_page_preview: Optional[bool]=None,          disable_notification: Optional[bool]=None,          protect_content: Optional[bool]=None,         reply_to_message_id: Optional[int]=None,          allow_sending_without_reply: Optional[bool]=None,         reply_markup: Optional[REPLY_MARKUP_TYPES]=None,         timeout: Optional[int]=None) -> types.Message:<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0432\u043d\u0443\u0442\u0440\u0438 \u043c\u043e\u0434\u0443\u043b\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u043f\u043e\u043b\u043d\u0430\u044f \u043a\u043e\u043f\u0438\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 API, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435, \u0432 \u043d\u0435\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u0432\u0441\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u043c\u0435\u0442\u043e\u0434\u043e\u0432.<\/p>\n<p>\u041d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u044d\u0442\u043e:<\/p>\n<ol>\n<li>\n<p>\u0411\u0435\u0441\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u043d\u043e.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0442\u0430\u043a\u0438\u043c \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f\u043c, \u043a\u043e\u0433\u0434\u0430 API \u0431\u044b\u043b \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d, \u0430 \u043c\u043e\u0434\u0443\u043b\u044c \u0435\u0449\u0435 \u043d\u0435\u0442 &#8212; \u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0443 \u043c\u043e\u0434\u0443\u043b\u044f \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0432 \u043d\u0435\u043c \u0440\u043e\u0432\u043d\u043e \u0442\u0443 \u0436\u0435 \u043b\u043e\u0433\u0438\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u044b\u043b\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0430 \u0432 API. \u042f \u043b\u0438\u0447\u043d\u043e \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0435\u0439, \u043a\u043e\u0433\u0434\u0430 \u043c\u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u0441\u0430\u043c\u043e\u043c\u0443 \u0434\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u044c, \u0442\u0430\u043a \u043a\u0430\u043a \u0432\u044b\u0448\u043b\u0430 \u043d\u043e\u0432\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f api, \u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0435\u0449\u0435 \u043d\u0435 \u0443\u0441\u043f\u0435\u043b \u0435\u0433\u043e \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c.<\/p>\n<\/li>\n<li>\n<p>\u0418, \u0435\u0441\u043b\u0438 \u044f \u043d\u0435 \u043e\u0448\u0438\u0431\u0430\u044e\u0441\u044c, \u043d\u0430\u0440\u0443\u0448\u0430\u0435\u0442 \u043f\u0440\u0438\u043d\u0446\u0438\u043f DRY: \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043e\u0434\u043d\u043e \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043b\u043e\u0433\u0438\u043a\u0438 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e \u0438 \u0432 \u043a\u043e\u0434\u0435 API, \u0438 \u0432 \u043a\u043e\u0434\u0435 \u043c\u043e\u0434\u0443\u043b\u044f.<\/p>\n<\/li>\n<\/ol>\n<h2>\u0417\u0430\u0434\u0443\u043c\u043a\u0430<\/h2>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u044f \u0440\u0435\u0448\u0438\u043b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u043c\u043e\u0434\u0443\u043b\u044c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u043b\u0438\u0448\u0438\u0442\u044c \u0432\u0441\u0435\u0445 \u044d\u0442\u0438\u0445 \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043a\u043e\u0432. \u041c\u043e\u0434\u0443\u043b\u044c \u044d\u0442\u043e\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c &#171;light&#187; &#8212; \u0442\u043e \u0435\u0441\u0442\u044c \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b API. \u0418 \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u043a\u0442\u043e-\u0442\u043e \u0437\u0430\u0445\u043e\u0447\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 API &#171;sendHolography&#187;, \u043c\u043e\u0434\u0443\u043b\u044c \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0435\u043f\u044f\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c, \u0442\u0430\u043a \u043a\u0430\u043a \u044d\u0442\u043e \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u0430\u0431\u043e\u0442\u044b API, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u043f\u0440\u0438\u0448\u043b\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0443: <\/p>\n<pre><code class=\"json\">{\"ok\":false,\"error_code\":404,\"description\":\"Not Found\"}<\/code><\/pre>\n<p>\u0418\u043b\u0438 \u043d\u0435 \u043f\u0440\u0438\u0448\u043b\u0435\u0442, \u0435\u0441\u043b\u0438 \u043a \u044d\u0442\u043e\u043c\u0443 \u043c\u043e\u043c\u0435\u043d\u0442\u0443 \u043f\u043e\u044f\u0432\u044f\u0442\u0441\u044f \u0433\u043e\u043b\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0435 \u043c\u043e\u043d\u0438\u0442\u043e\u0440\u044b \u0438 \u0441 \u043d\u0438\u043c\u0438 \u043c\u0435\u0442\u043e\u0434 &#171;sendHolography&#187;. \u0410 \u043c\u043e\u0434\u0443\u043b\u044c, \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0438 \u043e\u0442 pyTelegramBotApi \u0431\u0443\u0434\u0435\u0442 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0433\u043e\u0442\u043e\u0432 \u043a \u0442\u0430\u043a\u043e\u043c\u0443 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044e.<\/p>\n<h2>\u041d\u0430\u0447\u0438\u043d\u0430\u0435\u043c<\/h2>\n<p>\u0421\u043e\u0437\u0434\u0430\u044e \u043a\u043b\u0430\u0441\u0441 Bot, \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0432\u0441\u0435 \u043c\u0435\u0442\u043e\u0434\u044b Telegram Bot Api, \u043d\u043e \u0447\u0442\u043e\u0431\u044b \u043c\u043e\u0434\u0443\u043b\u044c \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0435\u043b \u043e\u0442 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044e \u043c\u0435\u0442\u043e\u0434 __getattr__. \u041e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c \u043d\u0435\u043a\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u0432\u044b\u0437\u043e\u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043c\u0435\u0442\u043e\u0434, \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f. \u0422\u0430\u043a\u0436\u0435, \u043f\u0435\u0440\u0435\u0438\u043c\u0435\u043d\u043e\u0432\u044b\u0432\u0430\u044e \u0435\u0451 \u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u044e \u0432 \u043c\u0435\u0442\u043e\u0434 &#8212; \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0435 \u0431\u044b\u043b\u043e \u043a\u0440\u0430\u0441\u0438\u0432\u043e. \u0418 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0432 \u043a\u044d\u0448, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0437\u0430\u043d\u043e\u0432\u043e \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0440\u0430\u0437.<\/p>\n<pre><code class=\"python\">from types import MethodType class Bot:     def __init__(self):         self.cache = {}            def __getattr__(self, attr: str):         if attr in cache: return self.cache[attr]                url = \"\/bot\"+self._token+\"\/\"+snake_case_to_camel_case(attr)       async def function(bot, **kwargs):           pass         method = MethodType(function, self)         self.cache[attr] = method         return method <\/code><\/pre>\n<p>\u0427\u0442\u043e\u0431\u044b \u0434\u0435\u043b\u0430\u0442\u044c \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0435 get \u0437\u0430\u043f\u0440\u043e\u0441\u044b, \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 aiohttp.ClientSession, \u043e\u0434\u043d\u0430\u043a\u043e \u0435\u0441\u043b\u0438 \u043f\u043e\u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0435\u0451 \u0432 Bot.__init__, \u0432\u044b\u0439\u0434\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0430:<\/p>\n<pre><code>The object should be created within an async function<\/code><\/pre>\n<p>\u0421\u0434\u0435\u043b\u0430\u0442\u044c __init__ \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u043c \u0442\u043e\u0436\u0435 \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e &#8212; \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u0443, \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0448\u0438\u0431\u043a\u0430:<\/p>\n<pre><code>TypeError: __init__() should return None, not 'coroutine'<\/code><\/pre>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u043c\u0435\u043d\u044e \u0441\u0432\u043e\u0435\u0433\u043e \u0440\u043e\u0434\u0430 \u043a\u043e\u0441\u0442\u044b\u043b\u044c &#8212; \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e Bot.__new__ \u043a\u0430\u043a \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0443\u044e, \u0441\u043e\u0437\u0434\u0430\u043c \u0441\u0435\u0441\u0441\u0438\u044e \u0432 \u043d\u0435\u0439. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0432\u044b\u0437\u0432\u0430\u0432 __new__ \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u043e\u043b\u0443\u0447\u0438\u0442 \u043a\u043e\u0440\u0443\u0442\u0438\u043d\u0443, \u0430 \u043f\u043e\u0442\u043e\u043c, \u043f\u043e\u0441\u043b\u0435 await, \u0432\u0435\u0440\u043d\u0435\u0442\u0441\u044f \u0441\u0430\u043c \u043e\u0431\u044a\u0435\u043a\u0442:<\/p>\n<pre><code class=\"python\">def __init__(self, token: str):     self._http_exceptions = {}     self._token = token     self.cache = {}      async def __new__(cls, *args, **kwargs):     obj = super().__new__(cls)     obj._session = aiohttp.ClientSession(url)     obj.__init__(*args, **kwargs)     return obj<\/code><\/pre>\n<pre><code class=\"python\">await Bot(token)<\/code><\/pre>\n<p>\u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u043c \u0431\u043b\u043e\u043a\u0435 \u043a\u043e\u0434\u0430 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e _http_exceptions. \u0417\u0430\u0447\u0435\u043c \u043e\u043d\u0430 \u043d\u0443\u0436\u043d\u0430? \u042f \u043c\u043e\u0433\u0443 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u043e \u043a\u043b\u0430\u0441\u0441\u0443 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e http \u043a\u043e\u0434\u0430 \u043e\u0448\u0438\u0431\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 telegram, \u043d\u043e \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0432 telegram bot api \u0434\u043e\u0431\u0430\u0432\u044f\u0442\u0441\u044f \u043d\u043e\u0432\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u043a\u043e\u0434\u044b \u043e\u0448\u0438\u0431\u043e\u043a? \u0418\u043b\u0438, \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c, \u0432\u044b\u0439\u0434\u0435\u0442 \u043d\u043e\u0432\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f http, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0443\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b \u043d\u043e\u0432\u044b\u0435 \u043a\u043e\u0434\u044b \u043e\u0448\u0438\u0431\u043e\u043a? \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443! \u0415\u0441\u0442\u044c \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043b\u0443\u0447\u0448\u0435!)<\/p>\n<pre><code class=\"python\">class TelegramError(Exception): pass<\/code><\/pre>\n<pre><code class=\"python\">class Bot: ...     def get_http_exception(self, number: int):         if number in self._http_exceptions:             return self._http_exceptions[number]         else:             HttpException = type(f\"TelegramError{number}\", (TelegramError,), {})             self._http_exceptions[number] = HttpException             return HttpException<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0432\u044b\u0439 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 type &#8212; \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u0430, \u0432\u0442\u043e\u0440\u043e\u0439 &#8212; \u043a\u043e\u0440\u0442\u0435\u0436 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0439 \u0434\u043e\u043b\u0436\u0435\u043d \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c\u0441\u044f, \u0430 \u0442\u0440\u0435\u0442\u0438\u0439 &#8212; \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u0430. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0435\u0441\u043b\u0438 \u043a\u0430\u043a\u0430\u044f-\u0442\u043e \u043e\u0448\u0438\u0431\u043a\u0430 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u0435\u0440\u0432\u044b\u0439 \u0440\u0430\u0437, \u0434\u043b\u044f \u043d\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0441\u0432\u043e\u0439 \u043a\u043b\u0430\u0441\u0441, \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439\u0441\u044f \u043e\u0442 TelegramError \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u0442\u0441\u044f \u0432 \u0441\u043b\u043e\u0432\u0430\u0440\u044c Bot._http_exceptions. <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0443 \u0441\u0430\u043c\u0443\u044e \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u0432 \u0440\u0430\u0437\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440.<\/p>\n<pre><code class=\"python\">async def function(bot, **kwargs):   async with bot._session.get(url, params=kwargs) as response:     response_data = await response.json()     if response_data[\"ok\"]:         return response_data[\"result\"]     else:         raise bot.get_http_exception(response_data[\"error_code\"])(           response_data[\"description\"]         )<\/code><\/pre>\n<p> \u0415\u0441\u043b\u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u044e http \u043e\u0448\u0438\u0431\u043a\u0443 &#8212; \u0441\u043e\u0437\u0434\u0430\u044e \u043d\u0443\u0436\u043d\u043e\u0435 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0438 \u0431\u0440\u043e\u0441\u0430\u044e \u0435\u0433\u043e.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0442\u044c \u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0430 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f, \u0438, \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u0435\u0441\u0442\u044c, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439. \u0412 PyTelegramBotApi \u0432\u044b\u0431\u043e\u0440 \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"python\">@bot.message_handler(commands=[\"start\", help]) def handler1: ... #\u0434\u043b\u044f \u043a\u043e\u043c\u0430\u043d\u0434 \/start \u0438 \/help  @bot.message_handler(content_types=[\"photo\"], chat_types=[\"private\"]) def handler2: ... #\u0434\u043b\u044f \u0444\u043e\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0439 \u0432 \u043b\u0438\u0447\u043d\u044b\u0445 \u0447\u0430\u0442\u0430\u0445  @bot.message_handler(func=lambda msg: msg.from_user.id in admins) def handler3: ... #\u0434\u043b\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439, \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u0435\u043b\u0438 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u0430\u0434\u043c\u0438\u043d\u043e\u0432.<\/code><\/pre>\n<p>\u041c\u0435\u043d\u044f \u043d\u0435 \u0443\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442 \u044d\u0442\u043e\u0442 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u043e \u0442\u0430\u043a\u043e\u0439 \u043f\u0440\u0438\u0447\u0438\u043d\u0435: \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043c\u043d\u0435 \u043d\u0443\u0436\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u0434\u0438\u043d \u0438\u0437 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u043b\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u043f\u0440\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e, \u0447\u0442\u043e \u043e\u043d \u0430\u0434\u043c\u0438\u043d \u0438\u043b\u0438 \u0432\u043b\u0430\u0434\u0435\u043b\u0435\u0446. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0440\u0430\u0431\u043e\u0442\u0430 \u0441\u0430\u043c\u043e\u0433\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0437\u0430\u0432\u0438\u0441\u0435\u0442\u044c \u043e\u0442 \u0442\u043e\u0433\u043e, \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0432\u0441\u0435 \u0442\u0430\u043a\u0438 \u0430\u0434\u043c\u0438\u043d \u0438\u043b\u0438 \u0432\u043b\u0430\u0434\u0435\u043b\u0435\u0446. \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043c\u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0434\u0432\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445: \u043e\u0434\u0438\u043d \u0432 \u0444\u0438\u043b\u044c\u0442\u0440\u0435, \u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u0432 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0435 \u0438 \u044d\u0442\u043e \u043d\u0435 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e. \u0414\u0430, \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043d\u0430 \u0434\u0432\u0430: \u043e\u0434\u0438\u043d \u0434\u043b\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043e\u0442 \u0430\u0434\u043c\u0438\u043d\u043e\u0432, \u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u0434\u043b\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043e\u0442 \u0432\u043b\u0430\u0434\u0435\u043b\u044c\u0446\u0435\u0432. \u041d\u043e \u0442\u043e\u0433\u0434\u0430 \u0447\u0430\u0441\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0438, \u043e\u0431\u0449\u0443\u044e \u0434\u043b\u044f \u0430\u0434\u043c\u0438\u043d\u043e\u0432 \u0438 \u0432\u043b\u0430\u0434\u0435\u043b\u044c\u0446\u0435\u0432 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0432\u044b\u043d\u043e\u0441\u0438\u0442\u044c \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438, \u0447\u0442\u043e \u043d\u0435 \u0443\u0434\u043e\u0431\u043d\u043e.<\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u044f \u0432\u044b\u0431\u0440\u0430\u043b \u0434\u0440\u0443\u0433\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442. \u041f\u0443\u0441\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0432\u044b\u0439 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a. \u0412 \u043d\u0435\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043c\u043e\u0436\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u0430\u043a\u043e\u0435-\u0442\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u0435 &#8212; \u0438 \u043f\u043e \u043d\u0435\u043c\u0443 \u0432\u044b\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0441 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c NextHandler. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a. \u0415\u0441\u043b\u0438 \u0436\u0435 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0431\u0435\u0437 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439, \u0441\u043e\u0431\u044b\u0442\u0438\u0435 \u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u043c.<\/p>\n<pre><code class=\"python\">class NextHandler(Exception):     def __init__(self):         self.args = (\"don't use this error outside of light_telegram_bot handler\",)<\/code><\/pre>\n<pre><code class=\"python\">class BotPolling:     def __init__(self, bot, start_offset=0):         self._handlers = []         self._bot = bot         self._offset = start_offset      async def start(self, timeout=60, **kwargs):         try:             while 1:                 updates = await self._bot.get_updates(                   timeout=timeout,                   offset=self._offset,                   **kwargs                 )                 if updates:                     self._offset = updates[-1][\"update_id\"]+1                 for update in updates:                     for handler in self._handlers:                         try:                             await handler(update)                         except NextHandler:                             pass                         else:                             break         except Exception:             raise<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-335859","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/335859","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=335859"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/335859\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=335859"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=335859"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=335859"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}