Exemplo n.º 1
0
 def db_unauth(self, chat_id: int):
     self.connect()
     if self.err:
         return "There's some error check log for details"
     sql = 'DELETE from users where uid = {};'.format(chat_id)
     self.cur.execute(sql)
     self.conn.commit()
     self.disconnect()
     AUTHORIZED_CHATS.remove(chat_id)
     return 'Unauthorized successfully'
Exemplo n.º 2
0
 def db_unauth(self,chat_id: int):
     self.connect()
     if self.err :
         return "<b>Tʜᴇʀᴇ's Sᴏᴍᴇ Eʀʀᴏʀ Cʜᴇᴄᴋ Lᴏɢ Fᴏʀ Dᴇᴛᴀɪʟs</b>"
     else:
         sql = 'DELETE from users where uid = {};'.format(chat_id)
         self.cur.execute(sql)
         self.conn.commit()
         self.disconnect()
         AUTHORIZED_CHATS.remove(chat_id)
         if chat_id in SUDO_USERS:
             SUDO_USERS.remove(chat_id)
         return '<b>UɴAᴜᴛʜᴏʀɪᴢᴇᴅ Sᴜᴄᴄᴇssꜰᴜʟʟʏ<b>'
Exemplo n.º 3
0
 def db_unauth(self, chat_id: int):
     self.connect()
     if self.err:
         return "T𝚑𝚎𝚛𝚎'𝚜 𝚜𝚘𝚖𝚎 𝚎𝚛𝚛𝚘𝚛 𝚌𝚑𝚎𝚌𝚔 𝚕𝚘𝚐 𝚏𝚘𝚛 𝚍𝚎𝚝𝚊𝚒𝚕𝚜"
     else:
         sql = 'DELETE from users where uid = {};'.format(chat_id)
         self.cur.execute(sql)
         self.conn.commit()
         self.disconnect()
         AUTHORIZED_CHATS.remove(chat_id)
         if chat_id in SUDO_USERS:
             SUDO_USERS.remove(chat_id)
         return '𝚄𝚗𝚊𝚞𝚝𝚑𝚘𝚛𝚒𝚣𝚎𝚍 𝚜𝚞𝚌𝚌𝚎𝚜𝚜𝚏𝚞𝚕𝚕𝚢😐'
Exemplo n.º 4
0
def unauthorize(update, context):
    reply_message = update.message.reply_to_message
    message_ = update.message.text.split(' ')
    if len(message_) == 2:
        chat_id = int(message_[1])
        if chat_id in AUTHORIZED_CHATS:
            AUTHORIZED_CHATS.remove(chat_id)
            msg = 'Chat unauthorized'
        else:
            msg = 'User already unauthorized'
    else:
        if reply_message is None:
            # Trying to unauthorize a chat
            chat_id = update.effective_chat.id
            if chat_id in AUTHORIZED_CHATS:
                AUTHORIZED_CHATS.remove(chat_id)
                msg = 'Chat unauthorized'
            else:
                msg = 'Already unauthorized chat'
        else:
            # Trying to authorize someone in specific
            user_id = reply_message.from_user.id
            if user_id in AUTHORIZED_CHATS:
                AUTHORIZED_CHATS.remove(user_id)
                msg = 'Person unauthorized to use the bot!'
            else:
                msg = 'Person already unauthorized!'
    with open('authorized_chats.txt', 'a') as file:
        file.truncate(0)
        for i in AUTHORIZED_CHATS:
            file.write(f'{i}\n')
    sendMessage(msg, context.bot, update)
Exemplo n.º 5
0
def unauthorize(update, context):
    reply_message = update.message.reply_to_message
    message_ = update.message.text.split(' ')
    if len(message_) == 2:
        chat_id = int(message_[1])
        if chat_id in AUTHORIZED_CHATS:
            AUTHORIZED_CHATS.remove(chat_id)
            msg = '<b>Cʜᴀᴛ UɴAᴜᴛʜᴏʀɪᴢᴇᴅ!</b>'
        else:
            msg = '<b>Usᴇʀ Aʟʀᴇᴀᴅʏ UɴAᴜᴛʜᴏʀɪᴢᴇᴅ!</b>'
    else:
        if reply_message is None:
            # Trying to unauthorize a chat
            chat_id = update.effective_chat.id
            if chat_id in AUTHORIZED_CHATS:
                AUTHORIZED_CHATS.remove(chat_id)
                msg = '<b>Cʜᴀᴛ UɴAᴜᴛʜᴏʀɪᴢᴇᴅ!</b>'
            else:
                msg = '<b>Aʟʀᴇᴀᴅʏ UɴAᴜᴛʜᴏʀɪᴢᴇᴅ Cʜᴀᴛ!</b>'
        else:
            # Trying to authorize someone in specific
            user_id = reply_message.from_user.id
            if user_id in AUTHORIZED_CHATS:
                AUTHORIZED_CHATS.remove(user_id)
                msg = '<b>Pᴇʀsᴏɴ UɴAᴜᴛʜᴏʀɪᴢᴇᴅ Tᴏ Usᴇ Tʜᴇ Bᴏᴛ!</b>'
            else:
                msg = '<b>Pᴇʀsᴏɴ Aʟʀᴇᴀᴅʏ UɴAᴜᴛʜᴏʀɪᴢᴇᴅ Tᴏ Usᴇ Tʜᴇ Bᴏᴛ!</b>'
    with open('authorized_chats.txt', 'a') as file:
        file.truncate(0)
        for i in AUTHORIZED_CHATS:
            file.write(f'{i}\n')
    sendMessage(msg, context.bot, update)
Exemplo n.º 6
0
def unauthorize(update, context):
    reply_message = None
    message_ = None
    reply_message = update.message.reply_to_message
    message_ = update.message.text.split(' ')
    if len(message_) == 2:
        user_id = int(message_[1])
        if user_id in AUTHORIZED_CHATS:
            AUTHORIZED_CHATS.remove(user_id)
            msg = 'User Unauthorized'
        else:
            msg = 'User Already Unauthorized'
    else:
        if reply_message is None:
            # Trying to unauthorize a chat
            chat_id = update.effective_chat.id
            if chat_id in AUTHORIZED_CHATS:
                AUTHORIZED_CHATS.remove(chat_id)
                msg = 'Chat Unauthorized'
            else:
                msg = 'Chat Already Unauthorized'
        else:
            # Trying to authorize someone by replying
            user_id = reply_message.from_user.id
            if user_id in AUTHORIZED_CHATS:
                AUTHORIZED_CHATS.remove(user_id)
                msg = 'User Unauthorized'
            else:
                msg = 'User Already Unauthorized'
    with open('authorized_chats.txt', 'a') as file:
        file.truncate(0)
        for i in AUTHORIZED_CHATS:
            file.write(f'{i}\n')
    sendMessage(msg, context.bot, update)
Exemplo n.º 7
0
def removeSudo(update, context):
    reply_message = None
    message_ = None
    reply_message = update.message.reply_to_message
    message_ = update.message.text.split(' ')
    if len(message_) == 2:
        user_id = int(message_[1])
        if user_id in SUDO_USERS:
            if DB_URI is not None:
                msg = DbManger().db_rmsudo(user_id)
            else:
                AUTHORIZED_CHATS.remove(user_id)
                SUDO_USERS.remove(user_id)
                msg = 'Demoted'
        else:
            msg = 'Not a Sudo'
    else:
        if reply_message is None:
            msg = "Give ID or Reply To message of whom you want to remove from Sudo"
        else:
            user_id = reply_message.from_user.id
            if user_id in SUDO_USERS:
                if DB_URI is not None:
                    msg = DbManger().db_rmsudo(user_id)
                else:
                    AUTHORIZED_CHATS.remove(user_id)
                    SUDO_USERS.remove(user_id)
                    msg = 'Demoted'
            else:
                msg = 'Not a Sudo'
    if DB_URI is None:
        with open('authorized_chats.txt', 'a') as file:
            file.truncate(0)
            for i in AUTHORIZED_CHATS:
                file.write(f'{i}\n')
        with open('sudo_users.txt', 'a') as file:
            file.truncate(0)
            for i in SUDO_USERS:
                file.write(f'{i}\n')
    sendMessage(msg, context.bot, update)
Exemplo n.º 8
0
def unauthorize(update, context):
    reply_message = update.message.reply_to_message
    if reply_message is None:
        # Trying to unauthorize a chat
        chat_id = update.effective_chat.id
        if chat_id in AUTHORIZED_CHATS:
            AUTHORIZED_CHATS.remove(chat_id)
            msg = 'Quyền sử dụng bot đã bị khoá!'
        else:
            msg = 'Quyền sử dụng bot đã được mở!'
    else:
        # Trying to authorize someone in specific
        user_id = reply_message.from_user.id
        if user_id in AUTHORIZED_CHATS:
            AUTHORIZED_CHATS.remove(user_id)
            msg = 'Person unauthorized to use the bot!'
        else:
            msg = 'Person already unauthorized!'
    with open('authorized_chats.txt', 'a') as file:
        file.truncate(0)
        for i in AUTHORIZED_CHATS:
            file.write(f'{i}\n')
    sendMessage(msg, context.bot, update)
Exemplo n.º 9
0
def unauthorize(update, context):
    reply_message = update.message.reply_to_message
    if reply_message is None:
        # Trying to unauthorize a chat
        chat_id = update.effective_chat.id
        if chat_id in AUTHORIZED_CHATS:
            AUTHORIZED_CHATS.remove(chat_id)
            msg = 'Sadly, This Chat unauthorized'
        else:
            msg = 'This is an unauthorized chat'
    else:
        # Trying to authorize someone in specific
        user_id = reply_message.from_user.id
        if user_id in AUTHORIZED_CHATS:
            AUTHORIZED_CHATS.remove(user_id)
            msg = 'This Guy is now unauthorized to use the bot!'
        else:
            msg = 'This Guy is already unauthorized!'
    with open('authorized_chats.txt', 'a') as file:
        file.truncate(0)
        for i in AUTHORIZED_CHATS:
            file.write(f'{i}\n')
    sendMessage(msg, context.bot, update)
Exemplo n.º 10
0
def unauthorize(update, context):
    reply_message = update.message.reply_to_message
    if reply_message is None:
        # Trying to unauthorize a chat
        chat_id = update.effective_chat.id
        if chat_id in AUTHORIZED_CHATS:
            AUTHORIZED_CHATS.remove(chat_id)
            msg = '⛔ Chat Unauthorize'
        else:
            msg = 'Already unauthorized chat'
    else:
        # Trying to authorize someone in specific
        user_id = reply_message.from_user.id
        if user_id in AUTHORIZED_CHATS:
            AUTHORIZED_CHATS.remove(user_id)
            msg = '❌🙍‍♂️🙍‍♀️ Person Unauthorize'
        else:
            msg = 'Person already unauthorized!'
    with open('authorized_chats.txt', 'a') as file:
        file.truncate(0)
        for i in AUTHORIZED_CHATS:
            file.write(f'{i}\n')
    sendMessage(msg, context.bot, update)
Exemplo n.º 11
0
def unauthorize(update, context):
    reply_message = update.message.reply_to_message
    if reply_message is None:
        # Trying to unauthorize a chat
        chat_id = update.effective_chat.id
        if chat_id in AUTHORIZED_CHATS:
            AUTHORIZED_CHATS.remove(chat_id)
            msg = "Chat unauthorized"
        else:
            msg = "Already unauthorized chat"
    else:
        # Trying to authorize someone in specific
        user_id = reply_message.from_user.id
        if user_id in AUTHORIZED_CHATS:
            AUTHORIZED_CHATS.remove(user_id)
            msg = "Person unauthorized to use the bot!"
        else:
            msg = "Person already unauthorized!"
    with open("authorized_chats.txt", "a") as file:
        file.truncate(0)
        for i in AUTHORIZED_CHATS:
            file.write(f"{i}\n")
    sendMessage(msg, context.bot, update)
Exemplo n.º 12
0
def unauthorize(update,context):
    reply_message = update.message.reply_to_message
    if reply_message is None:
        # Trying to unauthorize a chat
        chat_id = update.effective_chat.id
        if chat_id in AUTHORIZED_CHATS:
            AUTHORIZED_CHATS.remove(chat_id)
            msg = '⛽𝐓𝐡𝐢𝐬 𝐂𝐡𝐚𝐭 𝐈𝐬 𝐔𝐧𝐀𝐮𝐭𝐡𝐨𝐫𝐢𝐳𝐞𝐝'
        else:
            msg = '⛽𝐓𝐡𝐢𝐬 𝐂𝐡𝐚𝐭 𝐀𝐥𝐫𝐞𝐚𝐝𝐲 𝐀𝐮𝐭𝐡𝐨𝐫𝐢𝐳𝐞𝐝'
    else:
        # Trying to authorize someone in specific
        user_id = reply_message.from_user.id
        if user_id in AUTHORIZED_CHATS:
            AUTHORIZED_CHATS.remove(user_id)
            msg = '⛽𝐏𝐞𝐫𝐬𝐨𝐧 𝐔𝐧𝐀𝐮𝐭𝐡𝐨𝐫𝐢𝐳𝐞𝐝 𝐓𝐨 𝐔𝐬𝐞 𝐓𝐡𝐞 𝐁𝐨𝐭!'
        else:
            msg = '⛽𝐏𝐞𝐫𝐬𝐨𝐧 𝐀𝐥𝐫𝐞𝐚𝐝𝐲 𝐔𝐧𝐀𝐮𝐭𝐡𝐨𝐫𝐢𝐳𝐞𝐝 𝐓𝐨 𝐔𝐬𝐞 𝐓𝐡𝐞 𝐁𝐨𝐭!'
    with open('authorized_chats.txt', 'a') as file:
        file.truncate(0)
        for i in AUTHORIZED_CHATS:
            file.write(f'{i}\n')
    sendMessage(msg, context.bot, update)