Python telegram.error.BadRequest() Examples
The following are 30
code examples of telegram.error.BadRequest().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
telegram.error
, or try the search function
.
Example #1
Source File: admin.py From SkittBot with GNU General Public License v3.0 | 6 votes |
def unpin(bot: Bot, update: Update) -> str: chat = update.effective_chat user = update.effective_user # type: Optional[User] try: bot.unpinChatMessage(chat.id) except BadRequest as excp: if excp.message == "Chat_not_modified": pass else: raise return "<b>{}:</b>" \ "\n#UNPINNED" \ "\n<b>Admin:</b> {}".format(html.escape(chat.title), mention_html(user.id, user.first_name))
Example #2
Source File: blacklist.py From SkittBot with GNU General Public License v3.0 | 6 votes |
def del_blacklist(bot: Bot, update: Update): chat = update.effective_chat # type: Optional[Chat] message = update.effective_message # type: Optional[Message] to_match = extract_text(message) if not to_match: return chat_filters = sql.get_chat_blacklist(chat.id) for trigger in chat_filters: pattern = r"( |^|[^\w])" + re.escape(trigger) + r"( |$|[^\w])" if re.search(pattern, to_match, flags=re.IGNORECASE): try: message.delete() except BadRequest as excp: if excp.message == "Message to delete not found": pass else: LOGGER.exception("Error while deleting blacklist message.") break
Example #3
Source File: rules_bot.py From rules-bot with GNU Affero General Public License v3.0 | 6 votes |
def forward_faq(update: Update, context: CallbackContext): if update.message.chat.username not in [ONTOPIC_USERNAME, OFFTOPIC_USERNAME]: return admins = context.bot.get_chat_administrators(ONTOPIC_USERNAME) if update.effective_user.id not in [x.user.id for x in admins]: return if not update.message: return reply_to = update.message.reply_to_message if not reply_to: return try: update.message.delete() except BadRequest: pass # Forward message to FAQ channel reply_to.forward(const.FAQ_CHANNEL_ID, disable_notification=True)
Example #4
Source File: special.py From SkittBot with GNU General Public License v3.0 | 6 votes |
def getlink(bot: Bot, update: Update, args: List[int]): message = update.effective_message if args: pattern = re.compile(r'-\d+') else: message.reply_text("You don't seem to be referring to any chats.") links = "Invite link(s):\n" for chat_id in pattern.findall(message.text): try: chat = bot.getChat(chat_id) bot_member = chat.get_member(bot.id) if bot_member.can_invite_users: invitelink = bot.exportChatInviteLink(chat_id) links += str(chat_id) + ":\n" + invitelink + "\n" else: links += str(chat_id) + ":\nI don't have access to the invite link." + "\n" except BadRequest as excp: links += str(chat_id) + ":\n" + excp.message + "\n" except TelegramError as excp: links += str(chat_id) + ":\n" + excp.message + "\n" message.reply_text(links)
Example #5
Source File: admin.py From SkittBot with GNU General Public License v3.0 | 6 votes |
def pin(bot: Bot, update: Update, args: List[str]) -> str: user = update.effective_user # type: Optional[User] chat = update.effective_chat # type: Optional[Chat] is_group = chat.type != "private" and chat.type != "channel" prev_message = update.effective_message.reply_to_message is_silent = True if len(args) >= 1: is_silent = not (args[0].lower() == 'notify' or args[0].lower() == 'loud' or args[0].lower() == 'violent') if prev_message and is_group: try: bot.pinChatMessage(chat.id, prev_message.message_id, disable_notification=is_silent) except BadRequest as excp: if excp.message == "Chat_not_modified": pass else: raise return "<b>{}:</b>" \ "\n#PINNED" \ "\n<b>Admin:</b> {}".format(html.escape(chat.title), mention_html(user.id, user.first_name)) return ""
Example #6
Source File: alternate.py From EmiliaHikari with GNU General Public License v3.0 | 6 votes |
def send_message(message, text, target_id=None, *args,**kwargs): if not target_id: try: return message.reply_text(text, *args,**kwargs) except error.BadRequest as err: if str(err) == "Reply message not found": try: return message.reply_text(text, quote=False, *args, **kwargs) except error.BadRequest as err: LOGGER.exception("ERROR: {}".format(err)) elif str(err) == "Have no rights to send a message": try: dispatcher.bot.leaveChat(message.chat.id) dispatcher.bot.sendMessage(DUMP_CHAT, "I am leave chat `{}`\nBecause of: `Muted`".format(message.chat.title)) except error.BadRequest as err: if str(err) == "Chat not found": pass else: LOGGER.exception("ERROR: {}".format(err)) else: try: dispatcher.bot.send_message(target_id, text, *args, **kwarg) except error.BadRequest as err: LOGGER.exception("ERROR: {}".format(err))
Example #7
Source File: alternate.py From EmiliaHikari with GNU General Public License v3.0 | 6 votes |
def send_message_raw(chat_id, text, *args, **kwargs): try: return dispatcher.bot.sendMessage(chat_id, text, *args,**kwargs) except error.BadRequest as err: if str(err) == "Reply message not found": try: if kwargs.get('reply_to_message_id'): kwargs['reply_to_message_id'] = None return dispatcher.bot.sendMessage(chat_id, text, *args,**kwargs) except error.BadRequest as err: LOGGER.exception("ERROR: {}".format(err)) '''elif str(err) == "Have no rights to send a message": try: dispatcher.bot.leaveChat(message.chat.id) dispatcher.bot.sendMessage(DUMP_CHAT, "I am leave chat `{}`\nBecause of: `Muted`".format(message.chat.title)) except error.BadRequest as err: if str(err) == "Chat not found": pass''' else: LOGGER.exception("ERROR: {}".format(err))
Example #8
Source File: misc.py From EmiliaHikari with GNU General Public License v3.0 | 6 votes |
def echo(update, context): message = update.effective_message chat_id = update.effective_chat.id try: message.delete() except BadRequest: pass # Advanced text, data_type, content, buttons = get_message_type(message) tombol = build_keyboard_alternate(buttons) if str(data_type) in ('Types.BUTTON_TEXT', 'Types.TEXT'): try: if message.reply_to_message: context.bot.send_message(chat_id, text, parse_mode="markdown", reply_to_message_id=message.reply_to_message.message_id, disable_web_page_preview=True, reply_markup=InlineKeyboardMarkup(tombol)) else: context.bot.send_message(chat_id, text, quote=False, disable_web_page_preview=True, parse_mode=ParseMode.MARKDOWN, reply_markup=InlineKeyboardMarkup(tombol)) except BadRequest: context.bot.send_message(chat_id, tl(update.effective_message, "Teks markdown salah!\nJika anda tidak tahu apa itu markdown, silahkan ketik `/markdownhelp` pada PM."), parse_mode="markdown") return
Example #9
Source File: feds_sql.py From EmiliaHikari with GNU General Public License v3.0 | 6 votes |
def get_fed_log(fed_id): fed_setting = FEDERATION_BYFEDID.get(str(fed_id)) if fed_setting == None: fed_setting = False return fed_setting if fed_setting.get('flog') == None: return False elif fed_setting.get('flog'): try: dispatcher.bot.get_chat(fed_setting.get('flog')) except BadRequest: set_fed_log(fed_id, None) return False except Unauthorized: set_fed_log(fed_id, None) return False return fed_setting.get('flog') else: return False
Example #10
Source File: maintenance.py From sticker-finder with MIT License | 6 votes |
def distribute_tasks(bot, session): """Distribute tasks under idle maintenance chats.""" idle_maintenance_chats = ( session.query(Chat) .filter(Chat.is_maintenance) .filter(Chat.current_task_id.is_(None)) .all() ) for chat in idle_maintenance_chats: try: tg_chat = call_tg_func(bot, "get_chat", args=[chat.id]) except BadRequest as e: if e.message == "Chat not found": # noqa session.delete(chat) continue raise e try: check_maintenance_chat(session, tg_chat, chat, job=True) except (Unauthorized, ChatMigrated): session.delete(chat) session.commit()
Example #11
Source File: chat.py From sticker-finder with MIT License | 6 votes |
def cancel_tagging(self, bot): """Cancel the tagging process.""" if self.tag_mode == TagMode.STICKER_SET and self.current_sticker is not None: keyboard = get_continue_tagging_keyboard(self.current_sticker.file_id) try: call_tg_func( bot, "edit_message_reply_markup", [self.id, self.last_sticker_message_id], {"reply_markup": keyboard}, ) except BadRequest as e: # An update for a reply keyboard has failed (Probably due to button spam) logger = logging.getLogger() if "Message to edit not found" in str( e ) or "Message is not modified" in str(e): logger.info("Message to edit has been deleted.") pass else: raise e self.tag_mode = None self.current_sticker = None self.last_sticker_message_id = None
Example #12
Source File: common.py From NanoWalletBot with BSD 3-Clause "New" or "Revised" License | 6 votes |
def push_simple(bot, chat_id, message): try: bot.sendMessage(chat_id=chat_id, text=message) except BadRequest as e: bot.sendMessage(chat_id=chat_id, text=replace_unsafe(message)) except RetryAfter as e: sleep(240) bot.sendMessage(chat_id=chat_id, text=message) except TimedOut as e: sleep(60) bot.sendMessage(chat_id=chat_id, text=message) except Unauthorized as e: sleep(0.25) except NetworkError as e: sleep(30) bot.sendMessage(chat_id=chat_id, text=message) except Exception as e: sleep(1) bot.sendMessage(chat_id=chat_id, text=message)
Example #13
Source File: bot.py From ab-2018 with GNU General Public License v3.0 | 6 votes |
def run_job_queue(bot): try: redix = redis.Redis(host=REDIS_HOST, port=REDIS_PORT) while True: # get job from redis _, job = redix.brpop(TELEGRAM_WORKER_QUEUE) job = json.loads(job) message = "Hello this is your periodic star reminder and these are the lucky repos:\n" for repo in job["repos"]: message = "{}\n--\t[{}]({})".format(message, repo["name"], repo["url"]) message = "{}".format(message) try: bot.send_message(int(job['to']), message, parse_mode="Markdown", disable_web_page_preview=True) except error.BadRequest as e: logger.error("{}, UserID: {}".format(e, job["to"])) except error.Unauthorized as e: logger.error("{}, UserID: {}".format(e, job["to"])) # report job done. except KeyboardInterrupt: raise KeyboardInterrupt
Example #14
Source File: job.py From ultimate-poll-bot with MIT License | 6 votes |
def send_notifications_for_poll(context, session, poll, message_key): """Send the notifications for a single poll depending on the remaining time.""" locale = poll.locale for notification in poll.notifications: try: # Get the chat and send the notification tg_chat = context.bot.get_chat(notification.chat_id) tg_chat.send_message( i18n.t(message_key, locale=locale, name=poll.name), parse_mode="markdown", reply_to_message_id=notification.poll_message_id, ) except BadRequest as e: if e.message == "Chat not found": session.delete(notification) # Bot was removed from group except Unauthorized: session.delete(notification)
Example #15
Source File: message_utils.py From python-aria-mirror-bot with GNU General Public License v3.0 | 5 votes |
def delete_all_messages(): with status_reply_dict_lock: for message in list(status_reply_dict.values()): try: deleteMessage(bot, message) del status_reply_dict[message.chat.id] except BadRequest as e: LOGGER.info(str(e)) del status_reply_dict[message.chat.id] pass
Example #16
Source File: towel_mode.py From vldc-bot with MIT License | 5 votes |
def _delete_user_rel_messages(chat_id: int, user_id: str, context: CallbackContext): for msg_id in db.find_user(user_id=user_id)["rel_messages"]: try: context.bot.delete_message(chat_id, msg_id) except BadRequest as err: logger.info(f"can't delete msg: {err}")
Example #17
Source File: update.py From ultimate-poll-bot with MIT License | 5 votes |
def remove_poll_messages(session, bot, poll, remove_all=False): """Remove all messages (references) of a poll.""" if not remove_all: poll.closed = True send_updates(session, bot, poll) return for reference in poll.references: try: # 1. Admin poll management interface # 2. User that votes in private chat (priority vote) if reference.type in [ ReferenceType.admin.name, ReferenceType.private_vote.name, ]: bot.edit_message_text( i18n.t("deleted.poll", locale=poll.locale), chat_id=reference.user.id, message_id=reference.message_id, ) # Remove message created via inline_message_id else: bot.edit_message_text( i18n.t("deleted.poll", locale=poll.locale), inline_message_id=reference.bot_inline_message_id, ) except BadRequest as e: if e.message.startswith("Message_id_invalid") or e.message.startswith( "Message to edit not found" ): pass else: raise
Example #18
Source File: bot.py From m00dbot with MIT License | 5 votes |
def periodic_notifiction_callback(bot, job): for chat in chat_storage.get_chats(): if chat['frequency'] == 'none': continue created_at = datetime.strptime(chat['created_at'], '%Y-%m-%d %H-%M-%S') now = datetime.now() if created_at.hour != now.hour: continue if (chat['frequency'] == 'weekly') and (now.weekday() != created_at.weekday()): continue try: bot.send_message(chat_id=chat['id'], text=texts.PERIODIC_NOTIFICATION[chat['language']]) except BadRequest: pass
Example #19
Source File: poll.py From ultimate-poll-bot with MIT License | 5 votes |
def remove_old_references(session, bot, poll, user): """Remove old references in private chats.""" references = ( session.query(Reference) .filter(Reference.poll == poll) .filter(Reference.user == user) .all() ) for reference in references: try: bot.delete_message( chat_id=reference.user_id, message_id=reference.message_id ) except Unauthorized: session.delete(reference) except BadRequest as e: if ( e.message.startswith("Message_id_invalid") or e.message.startswith("Message can't be edited") or e.message.startswith("Message to edit not found") or e.message.startswith("Chat not found") or e.message.startswith("Can't access the chat") ): session.delete(reference) session.commit()
Example #20
Source File: whitepaper.py From OpenCryptoBot with GNU Affero General Public License v3.0 | 5 votes |
def get_action(self, bot, update, args): if not args: update.message.reply_text( text=f"Usage:\n{self.get_usage()}", parse_mode=ParseMode.MARKDOWN) return coin = args[0].upper() search = str() if len(args) > 1: search = args[1] try: link = self._from_allcryptowhitepaper(coin) if not link: if RateLimit.limit_reached(update): return link = self._from_coinmarketcap(coin) if not link and search == "all": link = self._from_coinpaprika(coin) except Exception as e: return self.handle_error(e, update) if link: try: update.message.reply_document( document=link, caption=f"{self.name} Whitepaper") except BadRequest: msg = f"{self.name} Whitepaper\n{link}" update.message.reply_text(text=msg) else: update.message.reply_text( text=f"{emo.INFO} No whitepaper for *{coin}* found", parse_mode=ParseMode.MARKDOWN)
Example #21
Source File: users.py From SkittBot with GNU General Public License v3.0 | 5 votes |
def get_user_id(username): # ensure valid userid if len(username) <= 5: return None if username.startswith('@'): username = username[1:] users = sql.get_userid_by_name(username) if not users: return None elif len(users) == 1: return users[0].user_id else: for user_obj in users: try: userdat = dispatcher.bot.get_chat(user_obj.user_id) if userdat.username == username: return userdat.id except BadRequest as excp: if excp.message == 'Chat not found': pass else: LOGGER.exception("Error extracting user ID") return None
Example #22
Source File: sticker_set.py From sticker-finder with MIT License | 5 votes |
def extract_text(tg_sticker): """Extract the text from a telegram sticker.""" text = None logger = logging.getLogger() try: # Get Image and preprocess it tg_file = call_tg_func(tg_sticker, "get_file") image_bytes = call_tg_func(tg_file, "download_as_bytearray") with Image.open(io.BytesIO(image_bytes)).convert("RGB") as image: image = preprocess_image(image) # Extract text text = image_to_string(image).strip().lower() # Only allow chars and remove multiple spaces to single spaces text = re.sub("[^a-zA-Z\ ]+", "", text) text = re.sub(" +", " ", text) text = text.strip() if text == "": text = None except TimedOut: logger.info(f"Finally failed on file {tg_sticker.file_id}") pass except BadRequest: logger.info(f"Failed to get image of {tg_sticker.file_id}") pass except OSError: logger.info(f"Failed to open image {tg_sticker.file_id}") pass except: sentry.captureException() pass return text
Example #23
Source File: admin.py From sticker-finder with MIT License | 5 votes |
def fix_stuff(bot, update, session, chat, user): """Entry point for quick fixes.""" call_tg_func(bot, "send_message", [chat.id, "starting to fix"]) stickers = session.query(Sticker).filter(Sticker.sticker_set_name.is_(None)).all() count = 0 print(f"found {len(stickers)}") for sticker in stickers: count += 1 if count % 100 == 0: print(f"fixed {count}") try: tg_sticker = bot.get_file(sticker.file_id) except BadRequest as e: if e.message == "Wrong file id": session.delete(sticker) continue # File id changed if tg_sticker.file_id != sticker.file_id: new_sticker = session.query(Sticker).get(tg_sticker.file_id) if new_sticker is not None: sticker.sticker_set = new_sticker.sticker_set else: session.delete(sticker) # Sticker set got deleted else: session.delete(sticker) session.commit() call_tg_func(bot, "send_message", [chat.id, "Fixing done"])
Example #24
Source File: admin.py From EmiliaHikari with GNU General Public License v3.0 | 5 votes |
def permapin(update, context): chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] message = update.effective_message # type: Optional[Message] args = context.args conn = connected(context.bot, update, chat, user.id, need_admin=False) if conn: chat = dispatcher.bot.getChat(conn) chat_id = conn chat_name = dispatcher.bot.getChat(conn).title else: if update.effective_message.chat.type == "private": send_message(update.effective_message, tl(update.effective_message, "Anda bisa lakukan command ini pada grup, bukan pada PM")) return "" chat = update.effective_chat chat_id = update.effective_chat.id chat_name = update.effective_message.chat.title text, data_type, content, buttons = get_message_type(message) tombol = build_keyboard_alternate(buttons) try: message.delete() except BadRequest: pass if str(data_type) in ('Types.BUTTON_TEXT', 'Types.TEXT'): try: sendingmsg = context.bot.send_message(chat_id, text, parse_mode="markdown", disable_web_page_preview=True, reply_markup=InlineKeyboardMarkup(tombol)) except BadRequest: context.bot.send_message(chat_id, tl(update.effective_message, "Teks markdown salah!\nJika anda tidak tahu apa itu markdown, silahkan ketik `/markdownhelp` pada PM."), parse_mode="markdown") return else: sendingmsg = ENUM_FUNC_MAP[str(data_type)](chat_id, content, caption=text, parse_mode="markdown", disable_web_page_preview=True, reply_markup=InlineKeyboardMarkup(tombol)) try: context.bot.pinChatMessage(chat_id, sendingmsg.message_id) except BadRequest: send_message(update.effective_message, tl(update.effective_message, "Saya tidak punya akses untuk pin pesan!"))
Example #25
Source File: admin.py From EmiliaHikari with GNU General Public License v3.0 | 5 votes |
def unpin(update, context): chat = update.effective_chat user = update.effective_user # type: Optional[User] args = context.args conn = connected(context.bot, update, chat, user.id, need_admin=True) if conn: chat = dispatcher.bot.getChat(conn) chat_id = conn chat_name = dispatcher.bot.getChat(conn).title else: if update.effective_message.chat.type == "private": send_message(update.effective_message, tl(update.effective_message, "Anda bisa lakukan command ini pada grup, bukan pada PM")) return "" chat = update.effective_chat chat_id = update.effective_chat.id chat_name = update.effective_message.chat.title try: context.bot.unpinChatMessage(chat.id) if conn: send_message(update.effective_message, tl(update.effective_message, "Saya sudah unpin pesan dalam grup {}").format(chat_name)) except BadRequest as excp: if excp.message == "Chat_not_modified": pass else: raise return "<b>{}:</b>" \ "\n#UNPINNED" \ "\n<b>Admin:</b> {}".format(html.escape(chat.title), mention_html(user.id, user.first_name))
Example #26
Source File: log_channel.py From SkittBot with GNU General Public License v3.0 | 5 votes |
def send_log(bot: Bot, log_chat_id: str, orig_chat_id: str, result: str): try: bot.send_message(log_chat_id, result, parse_mode=ParseMode.HTML) except BadRequest as excp: if excp.message == "Chat not found": bot.send_message(orig_chat_id, "This log channel has been deleted - unsetting.") sql.stop_chat_logging(orig_chat_id) else: LOGGER.warning(excp.message) LOGGER.warning(result) LOGGER.exception("Could not parse") bot.send_message(log_chat_id, result + "\n\nFormatting has been disabled due to an unexpected error.")
Example #27
Source File: verifier.py From EmiliaHikari with GNU General Public License v3.0 | 5 votes |
def verify_button_pressed(update, context): chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] query = update.callback_query # type: Optional[CallbackQuery] match = re.match(r"verify_me\((.+?)\)", query.data) match = match.group(1).split("|") is_ok = match[0] user_id = match[1] chat_id = match[2] message = update.effective_message # type: Optional[Message] print("-> {} was clicked welcome verify button".format(user.id)) if is_ok == "y": if context.bot.getChatMember(chat_id, user_id).status in ('left'): query.answer(text=tl(update.effective_message, "Failed: user left chat")) return try: context.bot.restrict_chat_member(chat_id, user_id, permissions=ChatPermissions(can_send_messages=True, can_send_media_messages=True, can_send_other_messages=True, can_add_web_page_previews=True)) sql.add_to_userlist(chat_id, user_id, True) sql.rm_from_timeout(chat_id, user_id) except BadRequest as err: if not update.effective_chat.get_member(context.bot.id).can_restrict_members: query.answer(text=tl(update.effective_message, "Saya tidak dapat membatasi orang disini, tanya admin untuk unmute!")) else: query.answer(text="Error: " + str(err)) return chat_name = context.bot.get_chat(chat_id).title context.bot.edit_message_media(chat.id, message_id=query.message.message_id, media=InputMediaPhoto(media="https://telegra.ph/file/06d2c5ec80af3858c2d4b.jpg", caption=tl(update.effective_message, "*Berhasil!*\n\nKerja bagus manusia, kini Anda dapat chatting di: *{}*").format(chat_name), parse_mode="markdown")) query.answer(text=tl(update.effective_message, "Berhasil! Anda dapat chatting di {} sekarang").format(chat_name), show_alert=True) else: context.bot.edit_message_media(chat.id, message_id=query.message.message_id, media=InputMediaPhoto(media="https://telegra.ph/file/d81cdcbafb240071add84.jpg", caption=tl(update.effective_message, "Maaf robot, kamu telah salah klik tombol verifikasi.\n\nCoba lagi dengan klik tombol verifikasi pada pesan selamat datang."), parse_mode="markdown")) query.answer(text=tl(update.effective_message, "Gagal! Kamu telah salah mengklik tombol verifikasi"), show_alert=True)
Example #28
Source File: alternate.py From EmiliaHikari with GNU General Public License v3.0 | 5 votes |
def leave_chat(message): try: dispatcher.bot.leaveChat(message.chat.id) dispatcher.bot.sendMessage(DUMP_CHAT, "I am leave chat `{}`\nBecause of: `Muted`".format(message.chat.title)) except error.BadRequest as err: if str(err) == "Chat not found": pass
Example #29
Source File: bans.py From SkittBot with GNU General Public License v3.0 | 5 votes |
def unban(bot: Bot, update: Update, args: List[str]) -> str: message = update.effective_message # type: Optional[Message] user = update.effective_user # type: Optional[User] chat = update.effective_chat # type: Optional[Chat] user_id, reason = extract_user_and_text(message, args) if not user_id: return "" try: member = chat.get_member(user_id) except BadRequest as excp: if excp.message == "User not found": message.reply_text("This user is ded mate.") return "" else: raise if user_id == bot.id: message.reply_text("What exactly are you attempting to do?") return "" if is_user_in_chat(chat, user_id): message.reply_text("Boi! this user is already in the group!") return "" chat.unban_member(user_id) message.reply_text("Fine, I'll allow it, this time...") log = "<b>{}:</b>" \ "\n#UNBANNED" \ "\n<b>Admin:</b> {}" \ "\n<b>User:</b> {} (<code>{}</code>)".format(html.escape(chat.title), mention_html(user.id, user.first_name), mention_html(member.user.id, member.user.first_name), member.user.id) if reason: log += "\n<b>Reason:</b> {}".format(reason) return log
Example #30
Source File: raiwalletbot.py From NanoWalletBot with BSD 3-Clause "New" or "Revised" License | 5 votes |
def check(bot, update, args): info_log(update) user_info = mysql_select_by_account(args[0]) if (user_info is not False): text_reply(update, 'User ID: {0}'.format(user_info[0])) text = 'Your @NanoWalletBot account: {0}. Do not forget to save your bot /seed !'.format(user_info[1]) sleep(1) try: push(bot, user_info[0], text) sleep(1) text_reply(update, 'Status: Valid') except BadRequest as e: text_reply(update, 'Status: Bad Request') else: text_reply(update, 'Status: User not found in bot')