def button(bot: Bot, update: Update) -> str: query = update.callback_query # type: Optional[CallbackQuery] user = update.effective_user # type: Optional[User] match = re.match(r"rm_warn\((.+?)\)", query.data) if match: user_id = match.group(1) chat = update.effective_chat # type: Optional[Chat] if not is_user_admin(chat, int(user.id)): query.answer( text= "ചീള് പിള്ളേർസ് ADMIN അല്ല എന്നിട്ട് REMOVE WARN അമർത്താൻ വന്നിരിക്കുന്നു", show_alert=True) return "" res = sql.remove_warn(user_id, chat.id) if res: update.effective_message.edit_text("Warn removed by {}.".format( mention_html(user.id, user.first_name)), parse_mode=ParseMode.HTML) user_member = chat.get_member(user_id) return "<b>{}:</b>" \ "\n#UNWARN" \ "\n<b>Admin:</b> {}" \ "\n<b>User:</b> {} (<code>{}</code>)".format(html.escape(chat.title), mention_html(user.id, user.first_name), mention_html(user_member.user.id, user_member.user.first_name), user_member.user.id) else: update.effective_message.edit_text( "ഇയാൾക്ക് നിലവിൽ warns ഒന്നുമില്ല.".format( mention_html(user.id, user.first_name)), parse_mode=ParseMode.HTML) return ""
def rmwarn_handler(bot: Bot, update: Update) -> str: query = update.callback_query # type: Optional[CallbackQuery] user = update.effective_user # type: Optional[User] match = re.match(r"rm_warn\((.+?)\)", query.data) if match: user_id = match.group(1) chat = update.effective_chat # type: Optional[Chat] if not is_user_admin(chat, int(user.id)): query.answer( text= "You are not authorized to remove this warn! Only administrators may remove warns.", show_alert=True) return "" res = sql.remove_warn(user_id, chat.id) if res: update.effective_message.edit_text("Warn removed by {}.".format( mention_html(user.id, user.first_name)), parse_mode=ParseMode.HTML) user_member = chat.get_member(user_id) return "<b>{}:</b>" \ "\n#UNWARN" \ "\n<b>Admin:</b> {}" \ "\n<b>User:</b> {} (<code>{}</code>)".format(html.escape(chat.title), mention_html(user.id, user.first_name), mention_html(user_member.user.id, user_member.user.first_name), user_member.user.id) else: update.effective_message.edit_text( "User has already has no warns.".format( mention_html(user.id, user.first_name)), parse_mode=ParseMode.HTML) return ""
def rmwarn_handler(bot: Bot, update: Update) -> str: chat = update.effective_chat query = update.callback_query user = update.effective_user match = re.match(r"rm_warn\((.+?)\)", query.data) if match: user_id = match.group(1) if not is_user_admin(chat, int(user.id)): query.answer(text=tld(chat.id, 'warns_remove_admin_only'), show_alert=True) return "" res = sql.remove_warn(user_id, chat.id) if res: update.effective_message.edit_text(tld( chat.id, 'warns_remove_success').format( mention_html(user.id, user.first_name)), parse_mode=ParseMode.HTML) user_member = chat.get_member(user_id) return tld(chat.id, 'warns_remove_log_channel').format( html.escape(chat.title), mention_html(user.id, user.first_name), mention_html(user_member.user.id, user_member.user.first_name), user_member.user.id) else: update.effective_message.edit_text(tld( chat.id, 'warns_user_has_no_warns').format( mention_html(user.id, user.first_name)), parse_mode=ParseMode.HTML) return ""
def button(update, context): query = update.callback_query # type: Optional[CallbackQuery] user = update.effective_user # type: Optional[User] match = re.match(r"rm_warn\((.+?)\)", query.data) if match: user_id = match.group(1) chat = update.effective_chat # type: Optional[Chat] res = sql.remove_warn(user_id, chat.id) if res: update.effective_message.edit_text(tl( update.effective_message, "Peringatkan dihapus oleh {}.").format( mention_html(user.id, user.first_name)), parse_mode=ParseMode.HTML) user_member = chat.get_member(user_id) return "<b>{}:</b>" \ "\n#UNWARN" \ "\n<b>Admin:</b> {}" \ "\n<b>User:</b> {} (<code>{}</code>)".format(html.escape(chat.title), mention_html(user.id, user.first_name), mention_html(user_member.user.id, user_member.user.first_name), user_member.user.id) else: update.effective_message.edit_text(tl( update.effective_message, "Pengguna sudah tidak memiliki peringatan.").format( mention_html(user.id, user.first_name)), parse_mode=ParseMode.HTML) return ""
def remove_warns(bot: Bot, update: Update, args: List[str]) -> str: message = update.effective_message chat = update.effective_chat user = update.effective_user user_id = extract_user(message, args) if user_id: sql.remove_warn(user_id, chat.id) message.reply_text(tld(chat.id, 'warns_latest_remove_success')) warned = chat.get_member(user_id).user return tld(chat.id, 'warns_remove_log_channel').format( html.escape(chat.title), mention_html(user.id, user.first_name), mention_html(warned.id, warned.first_name), warned.id) else: message.reply_text(tld(chat.id, 'common_err_no_user')) return ""