Exemplo n.º 1
0
def connected(bot: Bot, update: Update, chat, user_id, need_admin=True):
    user = update.effective_user

    if chat.type == chat.PRIVATE and sql.get_connected_chat(user_id):

        conn_id = sql.get_connected_chat(user_id).chat_id
        getstatusadmin = bot.get_chat_member(
            conn_id, update.effective_message.from_user.id)
        isadmin = getstatusadmin.status in ("administrator", "creator")
        ismember = getstatusadmin.status in ("member")
        isallow = sql.allow_connect_to_chat(conn_id)

        if ((isadmin) or (isallow and ismember) or (user.id in DRAGONS)
                or (user.id in DEV_USERS)):
            if need_admin is True:
                if (getstatusadmin.status in ("administrator", "creator")
                        or user_id in DRAGONS or user.id in DEV_USERS):
                    return conn_id
                else:
                    send_message(
                        update.effective_message,
                        "You must be an admin in the connected group!",
                    )
            else:
                return conn_id
        else:
            send_message(
                update.effective_message,
                "The group changed the connection rights or you are no longer an admin.\nI've disconnected you.",
            )
            disconnect_chat(update, bot)
    else:
        return False
Exemplo n.º 2
0
def connected(bot, update, chat, user_id, need_admin=True):
    user = update.effective_user
    msg = update.effective_message

    if chat.type == chat.PRIVATE and sql.get_connected_chat(user_id):

        conn_id = sql.get_connected_chat(user_id).chat_id
        getstatusadmin = bot.get_chat_member(conn_id, msg.from_user.id)
        isadmin = getstatusadmin.status in ADMIN_STATUS
        ismember = getstatusadmin.status in MEMBER_STAUS
        isallow = sql.allow_connect_to_chat(conn_id)

        if isadmin or (isallow and ismember) or (user.id in SUDO_USERS) or (
                user.id in DEV_USERS):
            if need_admin is True:
                if getstatusadmin.status in ADMIN_STATUS or user_id in SUDO_USERS or user.id in DEV_USERS:
                    return conn_id
                else:
                    send_message(msg, "Bağlı grupta yönetici olmalısınız!")
                    raise Exception("Yönetici değil!")
            else:
                return conn_id
        else:
            send_message(
                msg,
                "Grup bağlantı haklarını değiştirdi veya artık yönetici değilsiniz.\n"
                "Seni ayırdım.")
            disconnect_chat(bot, update)
            raise Exception("Yönetici değil!")
    else:
        return False
Exemplo n.º 3
0
def connected(bot: Bot, update: Update, chat, user_id, need_admin=True):
    user = update.effective_user

    if chat.type == chat.PRIVATE and sql.get_connected_chat(user_id):

        conn_id = sql.get_connected_chat(user_id).chat_id
        getstatusadmin = bot.get_chat_member(
            conn_id, update.effective_message.from_user.id)
        isadmin = getstatusadmin.status in ("administrator", "creator")
        ismember = getstatusadmin.status in ("member")
        isallow = sql.allow_connect_to_chat(conn_id)

        if ((isadmin) or (isallow and ismember) or (user.id in DRAGONS)
                or (user.id in DEV_USERS)):
            if need_admin is True:
                if (getstatusadmin.status in ("administrator", "creator")
                        or user_id in DRAGONS or user.id in DEV_USERS):
                    return conn_id
                else:
                    send_message(
                        update.effective_message,
                        "Sən qoşulmuş qrupda admin olmalısan!",
                    )
            else:
                return conn_id
        else:
            send_message(
                update.effective_message,
                "Qrup əlaqə hüquqlarını dəyişdirdi, və ya artıq admin deyilsən. \nSizlə əlaqəni kəsdim.",
            )
            disconnect_chat(update, bot)
    else:
        return False
Exemplo n.º 4
0
def connected(update, context, chat, user_id, need_admin=True):
    user = update.effective_user
    msg = update.effective_message

    if chat.type == chat.PRIVATE and sql.get_connected_chat(user_id):

        conn_id = sql.get_connected_chat(user_id).chat_id
        getstatusadmin = context.bot.get_chat_member(conn_id, msg.from_user.id)
        isadmin = getstatusadmin.status in ADMIN_STATUS
        ismember = getstatusadmin.status in MEMBER_STAUS
        isallow = sql.allow_connect_to_chat(conn_id)

        if isadmin or (isallow and ismember) or (user.id in SUDO_USERS) or (
                user.id in DEV_USERS):
            if need_admin is True:
                if getstatusadmin.status in ADMIN_STATUS or user_id in SUDO_USERS or user.id in DEV_USERS:
                    return conn_id
                else:
                    send_message(
                        msg, "You must be an admin in the connected group!")
                    raise Exception("Not admin!")
            else:
                return conn_id
        else:
            send_message(
                msg,
                "The group changed the connection rights or you are no longer an admin.\n"
                "I've disconnected you.")
            disconnect_chat(update, context)
            raise Exception("Not admin!")
    else:
        return False