Beispiel #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:
            message.reply_text(
                "{} is no longer AFK!\nTime you were AFK for: {}".format(firstname, end_afk_time))
        except Exception:
            return
Beispiel #2
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:
            message.reply_text(
                "<b>{}</b> is now Up!\nYou were Away for : <code>{}</code>".format(firstname, end_afk_time), parse_mode="html")
        except Exception:
            return
Beispiel #3
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 here!', '{} is back!', '{} is now in the chat!',
                '{} why you came here?',
                '{} is wasting his time in this chat!',
                '{} welcome back... now pay 100$ or get banned.',
                'Yamete...Yamete-kudasai {}-sama', 'Oh my! {} got no chills!!',
                '{} got a girlfriend! thats why he was afk.',
                '{} welcome to hell again.', '{} is here! start the show!',
                '{} bruh you should delete your telegram account.',
                '{} ahem! my love is here!',
                '{} damn... I saw you were online.. reading the messages.. but u were afk.',
                '{} yess.. lets start trashing the chat!',
                'Spammer just arrived.. be ready everyone.. let me grab my ban-hammer!',
                '{} please be gentle with me... in the chat..'
            ]
            chosen_option = random.choice(options)
            update.effective_message.reply_text(
                chosen_option.format(firstname), )
        except Exception:
            return
def end_afk(userid):
    REDIS.delete(f'is_afk_{userid}')
    return True