def __user_info__(user_id, chat_id): bio = html.escape(sql.get_user_bio(user_id) or "") me = html.escape(sql.get_user_me_info(user_id) or "") if bio and me: return tld(chat_id, "userinfo_what_i_and_other_say").format(me, bio) elif bio: return tld(chat_id, "userinfo_what_other_say").format(bio) elif me: return tld(chat_id, "userinfo_what_i_say").format(me) else: return ""
def stickerid(bot: Bot, update: Update): chat = update.effective_chat msg = update.effective_message if msg.reply_to_message and msg.reply_to_message.sticker: update.effective_message.reply_text(tld( chat.id, 'stickers_stickerid').format( escape_markdown(msg.reply_to_message.sticker.file_id)), parse_mode=ParseMode.MARKDOWN) else: update.effective_message.reply_text( tld(chat.id, 'stickers_stickerid_no_reply'))
def promote(bot: Bot, update: Update, args: List[str]) -> str: message = update.effective_message user = update.effective_user chat = update.effective_chat conn = connected(bot, update, chat, user.id) if conn: chatD = dispatcher.bot.getChat(conn) else: chatD = update.effective_chat if chat.type == "private": return if not chatD.get_member(bot.id).can_promote_members: update.effective_message.reply_text(tld(chat.id, "admin_err_no_perm")) return user_id = extract_user(message, args) if not user_id: message.reply_text(tld(chat.id, "common_err_no_user")) return user_member = chatD.get_member(user_id) if user_member.status == 'administrator' or user_member.status == 'creator': message.reply_text(tld(chat.id, "admin_err_user_admin")) return if user_id == bot.id: message.reply_text(tld(chat.id, "admin_err_self_promote")) return # set same perms as bot - bot can't assign higher perms than itself! bot_member = chatD.get_member(bot.id) bot.promoteChatMember(chatD.id, user_id, can_change_info=bot_member.can_change_info, can_post_messages=bot_member.can_post_messages, can_edit_messages=bot_member.can_edit_messages, can_delete_messages=bot_member.can_delete_messages, can_invite_users=bot_member.can_invite_users, can_restrict_members=bot_member.can_restrict_members, can_pin_messages=bot_member.can_pin_messages, can_promote_members=bot_member.can_promote_members) message.reply_text(tld(chat.id, "admin_promote_success").format( mention_html(user.id, user.first_name), mention_html(user_member.user.id, user_member.user.first_name), html.escape(chatD.title)), parse_mode=ParseMode.HTML) return f"<b>{html.escape(chatD.title)}:</b>" \ "\n#PROMOTED" \ f"\n<b>Admin:</b> {mention_html(user.id, user.first_name)}" \ f"\n<b>User:</b> {mention_html(user_member.user.id, user_member.user.first_name)}"
def list_cmds(bot: Bot, update: Update): chat = update.effective_chat if DISABLE_CMDS + DISABLE_OTHER: result = "" for cmd in set(DISABLE_CMDS + DISABLE_OTHER): result += " - `{}`\n".format(escape_markdown(cmd)) update.effective_message.reply_text(tld( chat.id, "disable_able_commands").format(result), parse_mode=ParseMode.MARKDOWN) else: update.effective_message.reply_text( tld(chat.id, "disable_able_commands_none"))
def locale_button(bot, update): chat = update.effective_chat user = update.effective_user query = update.callback_query lang_match = re.findall(r"en-US|ru|id|ru|es", query.data) if lang_match: if lang_match[0]: switch_to_locale(chat.id, lang_match[0]) query.answer(text=tld(chat.id, 'language_switch_success_pm'). format(list_locales[lang_match[0]])) else: query.answer(text="Error!", show_alert=True) try: LANGUAGE = prev_locale(chat.id) locale = LANGUAGE.locale_name curr_lang = list_locales[locale] except Exception: curr_lang = "Russian 🇷🇺" text = tld(chat.id, "language_select_language") text += tld(chat.id, "language_user_language").format(curr_lang) conn = connected(bot, update, chat, user.id, need_admin=False) if conn: try: chatlng = prev_locale(conn).locale_name chatlng = list_locales[chatlng] text += tld(chat.id, "language_chat_language").format(chatlng) except Exception: chatlng = "Russian 🇷🇺" text += tld(chat.id, "language_sel_user_lang") bot.edit_message_text( chat_id=query.message.chat_id, message_id=query.message.message_id, text=text, parse_mode=ParseMode.MARKDOWN, reply_markup=InlineKeyboardMarkup([[ InlineKeyboardButton("English (US) 🇺🇸", callback_data="set_lang_en-US"), ]] + [[ InlineKeyboardButton("Russian 🇷🇺", callback_data="set_lang_ru") ]] + [[ InlineKeyboardButton(f"{tld(chat.id, 'btn_go_back')}", callback_data="bot_start") ]])) # query.message.delete() bot.answer_callback_query(query.id)
def security_text(bot: Bot, update: Update, args: List[str]) -> str: chat = update.effective_chat # type: Optional[Chat] getcur, cur_value, cust_text = sql.welcome_security(chat.id) if len(args) >= 1: text = " ".join(args) sql.set_welcome_security(chat.id, getcur, cur_value, text) text = tld(chat.id, 'welcome_mute_btn_text_changed').format(text) update.effective_message.reply_text(text, parse_mode="markdown") else: update.effective_message.reply_text(tld( chat.id, 'welcome_mute_btn_curr_text').format(cust_text), parse_mode="markdown")
def unlock(bot: Bot, update: Update, args: List[str]) -> str: chat = update.effective_chat user = update.effective_user message = update.effective_message if is_user_admin(chat, message.from_user.id): if len(args) >= 1: if args[0] in LOCK_TYPES: sql.update_lock(chat.id, args[0], locked=False) message.reply_text(tld(chat.id, "locks_unlock_success").format(args[0]), parse_mode=ParseMode.MARKDOWN) return "<b>{}:</b>" \ "\n#UNLOCK" \ "\n<b>Admin:</b> {}" \ "\nUnlocked <code>{}</code>.".format(html.escape(chat.title), mention_html(user.id, user.first_name), args[0]) elif args[0] in RESTRICTION_TYPES: sql.update_restriction(chat.id, args[0], locked=False) # members = users_sql.get_chat_members(chat.id) # if args[0] == "messages": # unrestr_members(bot, chat.id, members, media=False, other=False, previews=False) # elif args[0] == "media": # unrestr_members(bot, chat.id, members, other=False, previews=False) # elif args[0] == "other": # unrestr_members(bot, chat.id, members, previews=False) # elif args[0] == "previews": # unrestr_members(bot, chat.id, members) # elif args[0] == "all": # unrestr_members(bot, chat.id, members, True, True, True, True) message.reply_text(tld(chat.id, "locks_unlock_success").format(args[0]), parse_mode=ParseMode.MARKDOWN) return "<b>{}:</b>" \ "\n#UNLOCK" \ "\n<b>Admin:</b> {}" \ "\nUnlocked <code>{}</code>.".format(html.escape(chat.title), mention_html(user.id, user.first_name), args[0]) else: message.reply_text(tld(chat.id, "locks_type_invalid")) else: bot.sendMessage(chat.id, tld(chat.id, "locks_unlock_no_type")) return ""
def antispam(bot: Bot, update: Update, args: List[str]): chat = update.effective_chat if len(args) > 0: if args[0].lower() in ["on", "yes"]: sql.enable_antispam(chat.id) update.effective_message.reply_text(tld(chat.id, "antispam_on")) elif args[0].lower() in ["off", "no"]: sql.disable_antispam(chat.id) update.effective_message.reply_text(tld(chat.id, "antispam_off")) else: update.effective_message.reply_text( tld(chat.id, "antispam_err_wrong_arg").format(sql.does_chat_gban(chat.id)))
def media(bot: Bot, update: Update, args: List[str]) -> str: chat = update.effective_chat user = update.effective_user message = update.effective_message conn = connected(bot, update, chat, user.id) if conn: chatD = dispatcher.bot.getChat(conn) else: if chat.type == "private": return else: chatD = chat user_id = extract_user(message, args) if not user_id: message.reply_text(tld(chat.id, "unrestrict_invalid")) return "" member = chatD.get_member(int(user_id)) if member.status != 'kicked' and member.status != 'left': if member.can_send_messages and member.can_send_media_messages \ and member.can_send_other_messages and member.can_add_web_page_previews: message.reply_text( tld(chat.id, "unrestrict_not_restricted").format(chatD.title)) else: bot.restrict_chat_member(chatD.id, int(user_id), can_send_messages=True, can_send_media_messages=True, can_send_other_messages=True, can_add_web_page_previews=True) keyboard = [] reply = tld(chat.id, "unrestrict_success").format( mention_html(member.user.id, member.user.first_name), chatD.title) message.reply_text(reply, reply_markup=keyboard, parse_mode=ParseMode.HTML) return "<b>{}:</b>" \ "\n#UNRESTRICTED" \ "\n<b>• Admin:</b> {}" \ "\n<b>• User:</b> {}" \ "\n<b>• ID:</b> <code>{}</code>".format(html.escape(chatD.title), mention_html(user.id, user.first_name), mention_html(member.user.id, member.user.first_name), user_id) else: message.reply_text(tld(chat.id, "unrestrict_not_in_chat")) return ""
def __user_info__(user_id, chat_id): is_gbanned = sql.is_user_gbanned(user_id) is_gmuted = sql.is_user_gmuted(user_id) if not user_id in SUDO_USERS: text = tld(chat_id,"antispam_gban") if is_gbanned: text = text.format(tld(chat_id, "antispam_yes")) user = sql.get_gbanned_user(user_id) if user.reason: text += tld(chat_id, "antispam_reason").format(html.escape(user.reason)) else: text = text.format(tld(chat_id, "antispam_no")) text += tld(chat_id,"antispam_gmuted") if is_gmuted: text = text.format(tld(chat_id, "antispam_yes")) user = sql.get_gmuted_user(user_id) if user.reason: text += tld(chat_id, "antispam_reason").format(html.escape(user.reason)) else: text = text.format(tld(chat_id, "antispam_no")) return text else: return ""
def get_blacklisted_urls(bot: Bot, update: Update): chat = update.effective_chat message = update.effective_message base_string = tld(chat.id, "url_blacklist_current") blacklisted = sql.get_blacklisted_urls(chat.id) if not blacklisted: message.reply_text(tld(chat.id, "url_blacklist_no_existed")) return for domain in blacklisted: base_string += "- <code>{}</code>\n".format(domain) message.reply_text(base_string, parse_mode=ParseMode.HTML)
def clear_rules(bot: Bot, update: Update): chat = update.effective_chat user = update.effective_user conn = connected(bot, update, chat, user.id) if conn: chat_id = conn else: if chat.type == 'private': msg.reply_text(tld(chat.id, 'common_cmd_group_only')) return chat_id = chat.id sql.set_rules(chat_id, "") update.effective_message.reply_text(tld(chat.id, 'rules_clean_success'))
def keyboard(bot, update): chat = update.effective_chat user = update.effective_user conn_id = con_sql.get_connected_chat(user.id) if conn_id and not conn_id == False: btn1 = "/disconnect - {}".format(tld(chat.id, "keyboard_disconnect")) btn2 = "" btn3 = "" else: if con_sql.get_history(user.id): history = con_sql.get_history(user.id) try: chat_name1 = dispatcher.bot.getChat(history.chat_id1).title except Exception: chat_name1 = "" try: chat_name2 = dispatcher.bot.getChat(history.chat_id2).title except Exception: chat_name2 = "" try: chat_name3 = dispatcher.bot.getChat(history.chat_id3).title except Exception: chat_name3 = "" if chat_name1: btn1 = "/connect {} - {}".format(history.chat_id1, chat_name1) else: btn1 = "/connect - {}".format(tld(chat.id, "keyboard_connect")) if chat_name2: btn2 = "/connect {} - {}".format(history.chat_id2, chat_name2) else: btn2 = "" if chat_name3: btn3 = "/connect {} - {}".format(history.chat_id3, chat_name3) else: btn3 = "" #TODO: Remove except garbage update.effective_message.reply_text( tld(chat.id, "keyboard_updated"), reply_markup=ReplyKeyboardMarkup([[ KeyboardButton("/help"), KeyboardButton("/notes - {}".format(tld(chat.id, "keyboard_notes"))) ], [KeyboardButton(btn1)], [KeyboardButton(btn2)], [KeyboardButton(btn3)]]))
def purge(bot: Bot, update: Update, args: List[str]) -> str: msg = update.effective_message if msg.reply_to_message: user = update.effective_user chat = update.effective_chat if can_delete(chat, bot.id): message_id = msg.reply_to_message.message_id if args and args[0].isdigit(): if int(args[0]) < int(1): return delete_to = message_id + int(args[0]) else: delete_to = msg.message_id - 1 for m_id in range(delete_to, message_id - 1, -1): # Reverse iteration over message ids try: bot.deleteMessage(chat.id, m_id) except BadRequest as err: if err.message == "Message can't be deleted": bot.send_message( chat.id, tld(chat.id, "purge_msg_cant_del_too_old")) elif err.message != "Message to delete not found": LOGGER.exception("Error while purging chat messages.") try: msg.delete() except BadRequest as err: if err.message == "Message can't be deleted": bot.send_message( chat.id, tld(chat.id, "purge_msg_cant_del_too_old")) elif err.message != "Message to delete not found": LOGGER.exception("Error while purging chat messages.") bot.send_message(chat.id, tld(chat.id, "purge_msg_success")) return "<b>{}:</b>" \ "\n#PURGE" \ "\n<b>• Admin:</b> {}" \ "\nPurged <code>{}</code> messages.".format(html.escape(chat.title), mention_html(user.id, user.first_name), delete_to - message_id) else: msg.reply_text(tld(chat.id, "purge_invalid")) return ""
def check_afk(bot, update, user_id, fst_name, userc_id): chat = update.effective_chat if sql.is_afk(user_id): user = sql.check_afk_status(user_id) if not user.reason: if int(userc_id) == int(user_id): return res = tld(chat.id, "status_afk_noreason").format(fst_name) update.effective_message.reply_text(res) else: if int(userc_id) == int(user_id): return res = tld(chat.id, "status_afk_reason").format(fst_name, user.reason) update.effective_message.reply_text(res)
def unsetlog(bot: Bot, update: Update): message = update.effective_message # type: Optional[Message] chat = update.effective_chat # type: Optional[Chat] log_channel = sql.stop_chat_logging(chat.id) if log_channel: try: bot.send_message( log_channel, tld(chat.id, "log_channel_unlink_success").format(chat.title)) message.reply_text(tld(chat.id, "Log channel has been un-set.")) except Exception: print("Nut") else: message.reply_text(tld(chat.id, "log_channel_unlink_none"))
def banme(bot: Bot, update: Update): user_id = update.effective_message.from_user.id chat = update.effective_chat if is_user_admin(update.effective_chat, user_id): update.effective_message.reply_text( tld(chat.id, "bans_err_usr_is_admin")) return res = update.effective_chat.kick_member(user_id) if res: update.effective_message.reply_text(tld(chat.id, "bans_kickme_success")) else: update.effective_message.reply_text(tld(chat.id, "bans_kickme_failed"))
def kickme(bot: Bot, update: Update): chat = update.effective_chat # type: Optional[Chat] user_id = update.effective_message.from_user.id if is_user_admin(update.effective_chat, user_id): update.effective_message.reply_text(tld(chat.id, "bans_kick_is_admin")) return res = update.effective_chat.unban_member( user_id) # unban on current user = kick if res: update.effective_message.reply_text(tld(chat.id, "bans_kickme_success")) else: update.effective_message.reply_text(tld(chat.id, "bans_kickme_failed"))
def adminlist(bot: Bot, update: Update): chat = update.effective_chat administrators = update.effective_chat.get_administrators() text = tld(chat.id, "admin_list").format( update.effective_chat.title or tld(chat.id, "common_this_chat").lower()) for admin in administrators: user = admin.user name = "[{}](tg://user?id={})".format(user.first_name, user.id) if user.username: esc = escape_markdown("@" + user.username) name = "[{}](tg://user?id={})".format(esc, user.id) text += "\n - {}".format(name) update.effective_message.reply_text(text, parse_mode=ParseMode.MARKDOWN)
def save(bot: Bot, update: Update): chat = update.effective_chat user = update.effective_user conn = connected(bot, update, chat, user.id) if conn: chat_id = conn chat_name = dispatcher.bot.getChat(conn).title else: chat_id = update.effective_chat.id if chat.type == "private": chat_name = tld(chat.id, "note_is_local") else: chat_name = chat.title msg = update.effective_message note_name, text, data_type, content, buttons = get_note_type(msg) note_name = note_name.lower() if data_type is None: msg.reply_text(tld(chat.id, "save_invalid")) return if len(text.strip()) == 0: text = note_name if not sql.get_note(chat_id, note_name): sql.add_note_to_db(chat_id, note_name, text, data_type, buttons=buttons, file=content) msg.reply_text(tld(chat.id, "save_success").format(note_name, chat_name, note_name, note_name), parse_mode=ParseMode.MARKDOWN) else: sql.add_note_to_db(chat_id, note_name, text, data_type, buttons=buttons, file=content) msg.reply_text(tld(chat.id, "save_updated").format(note_name, chat_name, note_name, note_name), parse_mode=ParseMode.MARKDOWN)
def spongemocktext(bot: Bot, update: Update, args: List[str]): message = update.effective_message chat = update.effective_chat noreply = False if message.reply_to_message: data = message.reply_to_message.text elif args: noreply = True data = message.text.split(None, 1)[1] else: noreply = True data = tld(chat.id, "memes_no_message") if not Path('images/bob.jpg').is_file(): LOGGER.warning( "images/bob.jpg not found! Spongemock memes module is turned off!") return for mocked in glob.glob("images/mocked*"): os.remove(mocked) reply_text = spongemock.mock(data) randint = random.randint(1, 699) magick = """convert images/bob.jpg -font Impact -pointsize 30 -size 512x300 -stroke black -strokewidth 1 -fill white -background none -gravity north caption:"{}" -flatten images/mocked{}.jpg""".format( reply_text, randint) os.system(magick) with open('images/mocked{}.jpg'.format(randint), 'rb') as mockedphoto: if noreply: message.reply_photo(photo=mockedphoto, reply=message.reply_to_message) else: message.reply_to_message.reply_photo( photo=mockedphoto, reply=message.reply_to_message) os.remove('images/mocked{}.jpg'.format(randint))
def deepfryer(bot: Bot, update: Update): message = update.effective_message chat = update.effective_chat if message.reply_to_message: data = message.reply_to_message.photo data2 = message.reply_to_message.sticker else: data = [] data2 = [] # check if message does contain media and cancel when not if not data and not data2: message.reply_text(tld(chat.id, "memes_deepfry_nothing")) return # download last photo (highres) as byte array if data: photodata = data[len(data) - 1].get_file().download_as_bytearray() image = Image.open(io.BytesIO(photodata)) elif data2: sticker = bot.get_file(data2.file_id) sticker.download('sticker.png') image = Image.open("sticker.png") # the following needs to be executed async (because dumb lib) loop = asyncio.new_event_loop() loop.run_until_complete( process_deepfry(image, message.reply_to_message, bot)) loop.close()
def add_warn_filter(bot: Bot, update: Update): chat = update.effective_chat msg = update.effective_message args = msg.text.split( None, 1) # use python's maxsplit to separate Cmd, keyword, and reply_text if len(args) < 2: return extracted = split_quotes(args[1]) if len(extracted) >= 2: # set trigger -> lower, so as to avoid adding duplicate filters with different cases keyword = extracted[0].lower() content = extracted[1] else: return # Note: perhaps handlers can be removed somehow using sql.get_chat_filters for handler in dispatcher.handlers.get(WARN_HANDLER_GROUP, []): if handler.filters == (keyword, chat.id): dispatcher.remove_handler(handler, WARN_HANDLER_GROUP) sql.add_warn_filter(chat.id, keyword, content) update.effective_message.reply_text( tld(chat.id, 'warns_handler_add_success').format(keyword)) raise DispatcherHandlerStop
def fed_chat(bot: Bot, update: Update, args: List[str]): chat = update.effective_chat fed_id = sql.get_fed_id(chat.id) if not fed_id: update.effective_message.reply_text( tld(chat.id, "feds_group_not_in_fed")) return chat = update.effective_chat info = sql.get_fed_info(fed_id) text = tld(chat.id, "feds_group_part_of_fed") text += "\n{} (ID: <code>{}</code>)".format(info['fname'], fed_id) update.effective_message.reply_text(text, parse_mode=ParseMode.HTML)
async def phh(event): if event.sender_id is None: return chat_id = event.chat_id try: fetch = get( "https://api.github.com/repos/phhusson/treble_experimentations/releases/latest", timeout=5) except Timeout: await event.reply( "Haruka Aya have been trying to connect to Github User Content, It seem like Github User Content is down" ) return usr = json.loads(fetch.content) reply_text = tld(chat_id, "phh_releases") for i in range(len(usr)): try: name = usr['assets'][i]['name'] url = usr['assets'][i]['browser_download_url'] reply_text += f"[{name}]({url})\n" except IndexError: continue await event.reply(reply_text)
def lock(bot: Bot, update: Update, args: List[str]) -> str: chat = update.effective_chat user = update.effective_user message = update.effective_message if can_delete(chat, bot.id): if len(args) >= 1: if args[0] in LOCK_TYPES: sql.update_lock(chat.id, args[0], locked=True) message.reply_text(tld(chat.id, "locks_lock_success").format(args[0]), parse_mode=ParseMode.MARKDOWN) return "<b>{}:</b>" \ "\n#LOCK" \ "\n<b>Admin:</b> {}" \ "\nLocked <code>{}</code>.".format(html.escape(chat.title), mention_html(user.id, user.first_name), args[0]) elif args[0] in RESTRICTION_TYPES: sql.update_restriction(chat.id, args[0], locked=True) if args[0] == "previews": members = users_sql.get_chat_members(str(chat.id)) restr_members(bot, chat.id, members, messages=True, media=True, other=True) message.reply_text(tld(chat.id, "locks_lock_success").format(args[0]), parse_mode=ParseMode.MARKDOWN) return "<b>{}:</b>" \ "\n#LOCK" \ "\n<b>Admin:</b> {}" \ "\nLocked <code>{}</code>.".format(html.escape(chat.title), mention_html(user.id, user.first_name), args[0]) else: message.reply_text(tld(chat.id, "locks_type_invalid")) else: message.reply_text(tld(chat.id, "locks_lock_no_type")) else: message.reply_text(tld(chat.id, "locks_bot_not_admin")) return ""
def kick(bot: Bot, update: Update, args: List[str]) -> str: chat = update.effective_chat # type: Optional[Chat] user = update.effective_user # type: Optional[User] message = update.effective_message # type: Optional[Message] user_id, reason = extract_user_and_text(message, args) if not user_id: message.reply_text(tld(chat.id, "common_err_no_user")) return "" try: member = chat.get_member(user_id) except BadRequest as excp: if excp.message == "User not found.": message.reply_text(tld(chat.id, "bans_err_usr_not_found")) return "" else: raise if user_id == bot.id: message.reply_text(tld(chat.id, "bans_kick_is_bot")) return "" if is_user_ban_protected(chat, user_id): message.reply_text(tld(chat.id, "bans_kick_is_admin")) return "" res = chat.unban_member(user_id) # unban on current user = kick if res: reply = tld(chat.id, "bans_kick_success").format( mention_html(user.id, user.first_name), mention_html(member.user.id, member.user.first_name), html.escape(chat.title)) if reason: reply += tld(chat.id, "bans_logger_reason").format(reason) message.reply_text(reply, parse_mode=ParseMode.HTML) log = tld(chat.id, "bans_kick_logger").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 += tld(chat.id, "bans_logger_reason").format(reason) return log else: message.reply_text(tld(chat.id, "bans_err_unknown").format("kicking")) return ""
def delete_rights(bot: Bot, update: Update, *args, **kwargs): chat = update.effective_chat if can_delete(update.effective_chat, bot.id): return func(bot, update, *args, **kwargs) else: update.effective_message.reply_text( tld(chat.id, 'helpers_bot_cant_delete'))
def logging(bot: Bot, update: Update): message = update.effective_message # type: Optional[Message] chat = update.effective_chat # type: Optional[Chat] log_channel = sql.get_chat_log_channel(chat.id) if log_channel: try: log_channel_info = bot.get_chat(log_channel) message.reply_text(tld(chat.id, "log_channel_grp_curr_conf").format( escape_markdown(log_channel_info.title), log_channel), parse_mode=ParseMode.MARKDOWN) except Exception: print("Nut") else: message.reply_text(tld(chat.id, "log_channel_none"))
def pin_rights(bot: Bot, update: Update, *args, **kwargs): chat = update.effective_chat if update.effective_chat.get_member(bot.id).can_pin_messages: return func(bot, update, *args, **kwargs) else: update.effective_message.reply_text( tld(chat.id, 'helpers_bot_cant_pin'))