Ejemplo n.º 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:
            afkback = message.reply_text(
                "{} is back online!\nYou were AFK for: {}".format(
                    firstname, end_afk_time
                )
            )
            sleep(10)
            afkback.delete()
        except BaseException:
            return
Ejemplo n.º 2
0
Archivo: afk.py Proyecto: EruBot/Kai
def __user_info__(user_id):
    is_afk = is_user_afk(user_id)
    text = ""
    if is_afk:
        since_afk = get_readable_time(
            (time.time() - float(REDIS.get(f"afk_time_{user_id}"))))
        text = "<i>This user is currently afk (away from keyboard).</i>"
        text += f"\n<i>Since: {since_afk}</i>"

    else:
        text = "<i>This user is currently isn't afk (away from keyboard).</i>"
    return text
Ejemplo n.º 3
0
Archivo: afk.py Proyecto: EruBot/Kai
def check_afk(update, context, user_id, fst_name, userc_id):
    if is_user_afk(user_id):
        reason = afk_reason(user_id)
        since_afk = get_readable_time(
            (time.time() - float(REDIS.get(f"afk_time_{user_id}"))))
        if int(userc_id) == int(user_id):
            return
        if reason == "none":
            res = "{} is AFK!\nSince: {}".format(fst_name, since_afk)
        else:
            res = "{} is AFK! Says it's because of:\n{}\nSince: {}".format(
                fst_name, reason, since_afk)

        update.effective_message.reply_text(res)
Ejemplo n.º 4
0
def is_user_afk(userid):
    rget = REDIS.get(f"is_afk_{userid}")
    return bool(rget)
Ejemplo n.º 5
0
def afk_reason(userid):
    return strb(REDIS.get(f"is_afk_{userid}"))