def warn(user_id, chat, reason, bot, message):
if is_user_admin(chat, user_id):
message.reply_text("Damn admins, can't even be warned!")
return
user_warned = sql.warn_user(user_id, chat.id, reason)
if user_warned.num_warns >= 3:
res = chat.kick_member(user_id)
if res:
bot.send_sticker(chat.id, 'CAADAgADOwADPPEcAXkko5EB3YGYAg') # banhammer marie sticker
message.reply_text("3 warnings, this user has been banned!")
sql.reset_warns(user_id, chat.id)
else:
message.reply_text("An error occurred, I couldn't ban this person!")
else:
keyboard = InlineKeyboardMarkup([[InlineKeyboardButton("Remove warn", callback_data="rm_warn({})".format(user_id))]])
if reason:
message.reply_text("{}/3 warnings... watch out! Latest one was because:\n{}".format(user_warned.num_warns, reason), reply_markup=keyboard)
else:
message.reply_text("{}/3 warnings... watch out!".format(user_warned.num_warns), reply_markup=keyboard)
评论列表
文章目录