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 # Commenting out fban health decrease cause it wasnt working and isnt needed ig. #_, 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 = "{} is afk".format(fst_name) update.effective_message.reply_text(res) else: if int(userc_id) == int(user_id): return res = "{} is afk.\nReason: <code>{}</code>\n#afk".format( html.escape(fst_name), html.escape(user.reason)) update.effective_message.reply_text(res, parse_mode="html")