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:
            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
def is_approved(chat_id, user_id):
    approved = ast.literal_eval(REDIS.get("Approvals"))
    try:
        list = approved[chat_id]
        if user_id in list:
            return True
        return
    except BaseException:
        return
def disapprove(chat_id, user_id):
    approved = ast.literal_eval(REDIS.get("Approvals"))
    try:
        list = approved[chat_id]
        if user_id in list:
            list.remove(user_id)
        approved.update({chat_id: list})
    except BaseException:
        pass
    return REDIS.set("Approvals", str(approved))
def approve(chat_id, user_id):
    approved = ast.literal_eval(REDIS.get("Approvals"))
    try:
        list = approved[chat_id]
        if user_id not in list:
            list.append(user_id)
        approved.update({chat_id: list})
    except BaseException:
        approved.update({chat_id: [user_id]})
    return REDIS.set("Approvals", str(approved))
Beispiel #5
0
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 = "This user is currently afk (away from keyboard)."
        text += f"\nLast Seen: {since_afk} Ago."
       
    else:
        text = "This user currently isn't afk (not away from keyboard)."
    return text
Beispiel #6
0
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 Dead!\nLast Liveliness: {} Ago.".format(fst_name, since_afk)
        else:
            res = "{} is afk!\nReason: {}\nLast seen: {} Ago.".format(fst_name, reason, since_afk)

        update.effective_message.reply_text(res)
Beispiel #7
0
def afk_reason(userid):
    return strb(REDIS.get(f'is_afk_{userid}'))
Beispiel #8
0
def is_user_afk(userid):
    rget = REDIS.get(f'is_afk_{userid}')
    return bool(rget)
def list_approved(chat_id):
    approved = ast.literal_eval(REDIS.get("Approvals"))
    try:
        return approved[chat_id]
    except BaseException:
        return
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
"""

import ast
from Cutiepii_Robot import REDIS

try:
    ast.literal_eval(REDIS.get("Approvals"))
except BaseException:
    REDIS.set("Approvals", "{}")


def approve(chat_id, user_id):
    approved = ast.literal_eval(REDIS.get("Approvals"))
    try:
        list = approved[chat_id]
        if user_id not in list:
            list.append(user_id)
        approved.update({chat_id: list})
    except BaseException:
        approved.update({chat_id: [user_id]})
    return REDIS.set("Approvals", str(approved))