def check_afk(update, context, user_id, fst_name, user_name, userc_id): if sql.is_afk(user_id): user = sql.check_afk_status(user_id) afk_time = sql.get_time(user) if int(userc_id) == int(user_id): return if not user.reason: try: res = "*{}* está AFK desde hace {}.".format(fst_name, afk_time) update.effective_message.reply_text( res, parse_mode=ParseMode.MARKDOWN) except: res = "*@{}* está AFK desde hace {}.".format( user_name, afk_time) update.effective_message.reply_text( res, parse_mode=ParseMode.MARKDOWN) else: try: res = "*{}* está AFK desde hace {}.\n*Razón:* {}".format( fst_name, afk_time, user.reason) update.effective_message.reply_text( res, parse_mode=ParseMode.MARKDOWN) except: res = "*@{}* está AFK desde hace {}.\n*Razón:* {}".format( user_name, afk_time, user.reason) update.effective_message.reply_text( res, parse_mode=ParseMode.MARKDOWN)
def hpmanager(user): total_hp = (get_user_num_chats(user.id) + 10) * 10 if not is_user_gbanned(user.id): # Assign new var `new_hp` since we need `total_hp` in # end to calculate percentage. new_hp = total_hp # if no username decrease 25% of hp. if not user.username: new_hp -= no_by_per(total_hp, 25) try: dispatcher.bot.get_user_profile_photos(user.id).photos[0][-1] except IndexError: # no profile photo ==> -25% of hp new_hp -= no_by_per(total_hp, 25) # if no /setme exist ==> -20% of hp if not sql.get_user_me_info(user.id): new_hp -= no_by_per(total_hp, 20) # if no bio exsit ==> -10% of hp if not sql.get_user_bio(user.id): new_hp -= no_by_per(total_hp, 10) if is_afk(user.id): afkst = check_afk_status(user.id) # if user is afk and no reason then decrease 7% # else if reason exist decrease 5% if not afkst.reason: new_hp -= no_by_per(total_hp, 7) else: new_hp -= no_by_per(total_hp, 5) # fbanned users will have (2*number of fbans) less from max HP # Example: if HP is 100 but user has 5 diff fbans # Available HP is (2*5) = 10% less than Max HP # So.. 10% of 100HP = 90HP _, fbanlist = get_user_fbanlist(user.id) new_hp -= no_by_per(total_hp, 2 * len(fbanlist)) # Bad status effects: # gbanned users will always have 5% HP from max HP # Example: If HP is 100 but gbanned # Available HP is 5% of 100 = 5HP else: new_hp = no_by_per(total_hp, 5) return { "earnedhp": int(new_hp), "totalhp": int(total_hp), "percentage": get_percentage(total_hp, new_hp), }
def check_afk(update, context, user_id, fst_name, userc_id): 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 = "{} está afk".format(fst_name) update.effective_message.reply_text(res) else: if int(userc_id) == int(user_id): return res = "{} está afk.\nRazón: \n{}".format(fst_name, user.reason) update.effective_message.reply_text(res)
def info(update: Update, context: CallbackContext): bot, args = context.bot, context.args message = update.effective_message chat = update.effective_chat user_id = extract_user(update.effective_message, args) if user_id: user = bot.get_chat(user_id) elif not message.reply_to_message and not args: user = message.from_user elif not message.reply_to_message and ( not args or (len(args) >= 1 and not args[0].startswith("@") and not args[0].isdigit() and not message.parse_entities([MessageEntity.TEXT_MENTION]))): message.reply_text("No puedo extraer un usuario de esto.") return else: return rep = message.reply_text("Buscando...") text = (f"<b>Información:</b>\n\n" f"<b>ID:</b> <code>{user.id}</code>\n" f"<b>Nombre:</b> {mention_html(user.id, user.first_name)} ") if user.last_name: text += f"{mention_html(user.id, user.last_name)}" if user.username: text += f"\n<b>Alías:</b> <code>{html.escape(user.username)}</code>" if chat.type != "private" and user_id != bot.id: _stext = "\n<b>Presencia:</b> <code>{}</code>" afk_st = is_afk(user.id) if afk_st: text += _stext.format("AFK") else: status = status = bot.get_chat_member(chat.id, user.id).status if status: if status in {"left", "kicked"}: text += _stext.format("Ausente") elif status == "member": text += _stext.format("Presente") elif status in {"administrator"}: text += _stext.format("Administrador") elif status in {"creator"}: text += _stext.format("Propietario") if user_id != bot.id: userhp = hpmanager(user) text += f"\n\n<b>Vida:</b> <code>{userhp['earnedhp']}/{userhp['totalhp']}</code>\n »{make_bar(int(userhp['percentage']))}« " text += f"[{userhp['percentage']}%] " text += '» [<a href="https://t.me/MeguRobotChannel/7">Info</a>]' try: spamwtc = sw.get_ban(int(user.id)) if spamwtc: text += "\n\n<b>Esta persona está vigilada por Spam!</b>" text += f"\n<b>Razón:</b> \n<pre>{spamwtc.reason}</pre>" text += "\n<b>Apelar en @SpamWatchSupport</b>" else: pass except: pass # don't crash if api is down somehow... disaster_level_present = False if user.id == OWNER_ID: text += "\n\n<b>Es Kazuma.</b>" disaster_level_present = True elif user.id in DEV_USERS: text += "\n\nEste usuario es un <b>Demonio Carmesí</b>." disaster_level_present = True elif user.id in SUDO_USERS: text += "\n\nEste usuario es un <b>Destroyer</b>." disaster_level_present = True elif user.id in SUPPORT_USERS: text += "\n\nEste usuario es un <b>Demonio</b>." disaster_level_present = True elif user.id in FROG_USERS: text += "\n\nEste usuario es una <b>Rana Gigante</b>." disaster_level_present = True elif user.id in WHITELIST_USERS: text += "\n\nEste usuario es un <b>Sapo Gigante</b>." disaster_level_present = True if disaster_level_present: text += '\n » [<a href="https://t.me/{}?start=adventurers">Info</a>]'.format( bot.username) try: user_member = chat.get_member(user.id) if user_member.status == "administrator": result = requests.post( f"https://api.telegram.org/bot{TOKEN}/getChatMember?chat_id={chat.id}&user_id={user.id}" ) result = result.json()["result"] if "custom_title" in result.keys(): custom_title = result["custom_title"] text += f"\n\n<b>Título:</b> <code>{custom_title}</code>" except BadRequest: pass for mod in USER_INFO: try: mod_info = mod.__user_info__(user.id).strip() except TypeError: mod_info = mod.__user_info__(user.id, chat.id).strip() if mod_info: text += "\n\n" + mod_info if INFOPIC: try: profile = bot.get_user_profile_photos(user.id).photos[0][-1] _file = bot.get_file(profile["file_id"]) _file.download(f"temp/{user.id}.png") message.reply_document( document=open(f"temp/{user.id}.png", "rb"), caption=(text), parse_mode=ParseMode.HTML, ) os.remove(f"temp/{user.id}.png") except BadRequest as e: if str(e) == "Reply message not found": message.reply_document( document=open(f"temp/{user.id}.png", "rb"), caption=text, parse_mode=ParseMode.HTML, quote=False, ) os.remove(f"temp/{user.id}.png") # Incase user don't have profile pic, send normal text except IndexError: message.reply_text(text, parse_mode=ParseMode.HTML, disable_web_page_preview=True) else: message.reply_text(text, parse_mode=ParseMode.HTML, disable_web_page_preview=True) rep.delete()