Example #1
0
def no_longer_afk(update, context):
    user = update.effective_user
    message = update.effective_message
    if not user:  # ignore channels
        return

    if not is_user_afk(user.id):  #Check if user is afk or not
        return
    end_afk_time = get_readable_time((time.time() - float(REDIS.get(f'afk_time_{user.id}'))))
    REDIS.delete(f'afk_time_{user.id}')
    res = end_afk(user.id)
    if res:
        if message.new_chat_members:  # dont say msg
            return
        firstname = update.effective_user.first_name
        try:
            options = [
                "{} Is wasting his time in the chat!",
                "The Dead {} Came Back From His Grave!",
                "Welcome back {}! I hope you bought pizza",
                "Good to hear from you again {}",
                "{} Good job waking up now get ready for your classes!",
                "Hey {}! Why weren't you online for such a long time?",
                "{} why did you came back?",
                "{} Is now back online!",
                "OwO, Welcome back {}",
                "Welcome to hell again {}",
                "Whats poppin {}?",
            ]
            chosen_option = random.choice(options)
            update.effective_message.reply_text(
                chosen_option.format(firstname),
            )
        except Exception:
            return
Example #2
0
def end_afk(userid):
    REDIS.delete(f'is_afk_{userid}')
    return True