Exemplo n.º 1
0
 def db_auth(self, chat_id: int):
     self.connect()
     if self.err:
         return "There's some error check log for details"
     sql = 'INSERT INTO users VALUES ({});'.format(chat_id)
     self.cur.execute(sql)
     self.conn.commit()
     self.disconnect()
     AUTHORIZED_CHATS.add(chat_id)
     return 'Authorized successfully'
Exemplo n.º 2
0
 def db_auth(self,chat_id: int):
     self.connect()
     if self.err :
         return "<b>Tʜᴇʀᴇ's Sᴏᴍᴇ Eʀʀᴏʀ Cʜᴇᴄᴋ Lᴏɢ Fᴏʀ Dᴇᴛᴀɪʟs</b>"
     else:
         sql = 'INSERT INTO users VALUES ({});'.format(chat_id)
         self.cur.execute(sql)
         self.conn.commit()
         self.disconnect()
         AUTHORIZED_CHATS.add(chat_id)
         return '<b>Aᴜᴛʜᴏʀɪᴢᴇᴅ Sᴜᴄᴄᴇssꜰᴜʟʟʏ</b>'
Exemplo n.º 3
0
 def db_auth(self, chat_id: int):
     self.connect()
     if self.err:
         return "T𝚑𝚎𝚛𝚎'𝚜 𝚜𝚘𝚖𝚎 𝚎𝚛𝚛𝚘𝚛 𝚌𝚑𝚎𝚌𝚔 𝚕𝚘𝚐 𝚏𝚘𝚛 𝚍𝚎𝚝𝚊𝚒𝚕𝚜"
     else:
         sql = 'INSERT INTO users VALUES ({});'.format(chat_id)
         self.cur.execute(sql)
         self.conn.commit()
         self.disconnect()
         AUTHORIZED_CHATS.add(chat_id)
         return '𝙰𝚞𝚝𝚑𝚘𝚛𝚒𝚣𝚎𝚍 𝚜𝚞𝚌𝚌𝚎𝚜𝚜𝚏𝚞𝚕𝚕𝚢😉'
Exemplo n.º 4
0
 def db_addsudo(self, chat_id: int):
     self.connect()
     if self.err:
         return "There's some error check log for details"
     else:
         if chat_id in AUTHORIZED_CHATS:
             sql = "UPDATE users SET sudo = TRUE where uid = {};".format(chat_id)
             self.cur.execute(sql)
             self.conn.commit()
             self.disconnect()
             SUDO_USERS.add(chat_id)
             return "Successfully promoted as Sudo"
         else:
             sql = "INSERT INTO users VALUES ({},TRUE);".format(chat_id)
             self.cur.execute(sql)
             self.conn.commit()
             self.disconnect()
             AUTHORIZED_CHATS.add(chat_id)
             SUDO_USERS.add(chat_id)
             return "Successfully Authorized and promoted as Sudo"
Exemplo n.º 5
0
 def db_addsudo(self,chat_id: int):
     self.connect()
     if self.err :
         return "<b>Tʜᴇʀᴇ's Sᴏᴍᴇ Eʀʀᴏʀ Cʜᴇᴄᴋ Lᴏɢ Fᴏʀ Dᴇᴛᴀɪʟs</b>"
     else:
         if chat_id in AUTHORIZED_CHATS:
             sql = 'UPDATE users SET sudo = TRUE where uid = {};'.format(chat_id)
             self.cur.execute(sql)
             self.conn.commit()
             self.disconnect()
             SUDO_USERS.add(chat_id)
             return '<b>Sᴜᴄᴄᴇssꜰᴜʟʟʏ Pʀᴏᴍᴏᴛᴇᴅ Usᴇʀ As Sᴜᴅᴏ</b>'
         else:
             sql = 'INSERT INTO users VALUES ({},TRUE);'.format(chat_id)
             self.cur.execute(sql)
             self.conn.commit()
             self.disconnect()
             AUTHORIZED_CHATS.add(chat_id)
             SUDO_USERS.add(chat_id)
             return '<b>Sᴜᴄᴄᴇssꜰᴜʟʟʏ Aᴜᴛʜᴏʀɪᴢᴇᴅ Aɴᴅ Pʀᴏᴍᴏᴛᴇᴅ Usᴇʀ As Sᴜᴅᴏ</b>'
Exemplo n.º 6
0
 def db_addsudo(self, chat_id: int):
     self.connect()
     if self.err:
         return "T𝚑𝚎𝚛𝚎'𝚜 𝚜𝚘𝚖𝚎 𝚎𝚛𝚛𝚘𝚛 𝚌𝚑𝚎𝚌𝚔 𝚕𝚘𝚐 𝚏𝚘𝚛 𝚍𝚎𝚝𝚊𝚒𝚕𝚜"
     else:
         if chat_id in AUTHORIZED_CHATS:
             sql = 'UPDATE users SET sudo = TRUE where uid = {};'.format(
                 chat_id)
             self.cur.execute(sql)
             self.conn.commit()
             self.disconnect()
             SUDO_USERS.add(chat_id)
             return '𝚂𝚞𝚌𝚌𝚎𝚜𝚜𝚏𝚞𝚕𝚕𝚢 𝚙𝚛𝚘𝚖𝚘𝚝𝚎𝚍 𝚊𝚜 𝚜𝚞𝚍𝚘🤗'
         else:
             sql = 'INSERT INTO users VALUES ({},TRUE);'.format(chat_id)
             self.cur.execute(sql)
             self.conn.commit()
             self.disconnect()
             AUTHORIZED_CHATS.add(chat_id)
             SUDO_USERS.add(chat_id)
             return '𝚂𝚞𝚌𝚌𝚎𝚜𝚜𝚏𝚞𝚕𝚕𝚢 𝙰𝚞𝚝𝚑𝚘𝚛𝚒𝚣𝚎𝚍 𝚊𝚗𝚍 𝚙𝚛𝚘𝚖𝚘𝚝𝚎𝚍 𝚊𝚜 𝚜𝚞𝚍𝚘🤗'
Exemplo n.º 7
0
def authorize(update, context):
    reply_message = update.message.reply_to_message
    message_ = update.message.text.split(' ')
    msg = ''
    with open('authorized_chats.txt', 'a') as file:
        if len(message_) == 2:
            chat_id = int(message_[1])
            if chat_id not in AUTHORIZED_CHATS:
                file.write(f'{chat_id}\n')
                AUTHORIZED_CHATS.add(chat_id)
                msg = 'Chat authorized'
            else:
                msg = 'User already authorized'
        else:
            if reply_message is None:
                # Trying to authorize a chat
                chat_id = update.effective_chat.id
                if chat_id not in AUTHORIZED_CHATS:
                    file.write(f'{chat_id}\n')
                    AUTHORIZED_CHATS.add(chat_id)
                    msg = 'Chat authorized'
                else:
                    msg = 'Already authorized chat'
            else:
                # Trying to authorize someone in specific
                user_id = reply_message.from_user.id
                if user_id not in AUTHORIZED_CHATS:
                    file.write(f'{user_id}\n')
                    AUTHORIZED_CHATS.add(user_id)
                    msg = 'Person Authorized to use the bot!'
                else:
                    msg = 'Person already authorized'
        sendMessage(msg, context.bot, update)
Exemplo n.º 8
0
def authorize(update, context):
    reply_message = update.message.reply_to_message
    message_ = update.message.text.split(' ')
    msg = ''
    with open('authorized_chats.txt', 'a') as file:
        if len(message_) == 2:
            chat_id = int(message_[1])
            if chat_id not in AUTHORIZED_CHATS:
                file.write(f'{chat_id}\n')
                AUTHORIZED_CHATS.add(chat_id)
                msg = '<b>Cʜᴀᴛ Aᴜᴛʜᴏʀɪᴢᴇᴅ!</b>'
            else:
                msg = '<b>Usᴇʀ Aʟʀᴇᴀᴅʏ Aᴜᴛʜᴏʀɪᴢᴇᴅ!</b>'
        else:
            if reply_message is None:
                # Trying to authorize a chat
                chat_id = update.effective_chat.id
                if chat_id not in AUTHORIZED_CHATS:
                    file.write(f'{chat_id}\n')
                    AUTHORIZED_CHATS.add(chat_id)
                    msg = '<b>Cʜᴀᴛ Aᴜᴛʜᴏʀɪᴢᴇᴅ!</b>'
                else:
                    msg = '<b>Aʟʀᴇᴀᴅʏ Aᴜᴛʜᴏʀɪᴢᴇᴅ Cʜᴀᴛ!</b>'
            else:
                # Trying to authorize someone in specific
                user_id = reply_message.from_user.id
                if user_id not in AUTHORIZED_CHATS:
                    file.write(f'{user_id}\n')
                    AUTHORIZED_CHATS.add(user_id)
                    msg = '<b>Pᴇʀsᴏɴ Aᴜᴛʜᴏʀɪᴢᴇᴅ Tᴏ Usᴇ Tʜᴇ Bᴏᴛ!</b>'
                else:
                    msg = '<b>Pᴇʀsᴏɴ Aʟʀᴇᴀᴅʏ Aᴜᴛʜᴏʀɪᴢᴇᴅ Tᴏ Usᴇ Tʜᴇ Bᴏᴛ!</b>'
        sendMessage(msg, context.bot, update)
Exemplo n.º 9
0
def addSudo(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 not in SUDO_USERS:
            if DB_URI is not None:
                msg = DbManger().db_addsudo(user_id)
            else:
                with open('authorized_chats.txt', 'a') as file:
                    file.write(f'{user_id}\n')
                    AUTHORIZED_CHATS.add(user_id)
                with open('sudo_users.txt', 'a') as file:
                    file.write(f'{user_id}\n')
                    SUDO_USERS.add(user_id)
                    msg = 'Promoted as Sudo'
        else:
            msg = 'Already Sudo'
    else:
        if reply_message is None:
            msg = "Give ID or Reply To message of whom you want to Promote"
        else:
            # Trying to authorize someone by replying
            user_id = reply_message.from_user.id
            if user_id not in SUDO_USERS:
                if DB_URI is not None:
                    msg = DbManger().db_addsudo(user_id)
                else:
                    with open('authorized_chats.txt', 'a') as file:
                        file.write(f'{user_id}\n')
                        AUTHORIZED_CHATS.add(user_id)
                    with open('sudo_users.txt', 'a') as file:
                        file.write(f'{user_id}\n')
                        SUDO_USERS.add(user_id)
                        msg = 'Promoted as Sudo'
            else:
                msg = 'Already Sudo'
    sendMessage(msg, context.bot, update)
Exemplo n.º 10
0
 def db_load(self):
     # User Data
     self.cur.execute("SELECT * from users")
     rows = self.cur.fetchall(
     )  #returns a list ==> (uid, sudo, auth, media, doc, thumb)
     if rows:
         for row in rows:
             if row[1] and row[0] not in SUDO_USERS:
                 SUDO_USERS.add(row[0])
             elif row[2] and row[0] not in AUTHORIZED_CHATS:
                 AUTHORIZED_CHATS.add(row[0])
             if row[3]:
                 AS_MEDIA_USERS.add(row[0])
             elif row[4]:
                 AS_DOC_USERS.add(row[0])
             path = f"Thumbnails/{row[0]}.jpg"
             if row[5] is not None and not ospath.exists(path):
                 if not ospath.exists('Thumbnails'):
                     makedirs('Thumbnails')
                 with open(path, 'wb+') as f:
                     f.write(row[5])
                     f.close()
         LOGGER.info("Users data has been imported from Database")
     # Rss Data
     self.cur.execute("SELECT * FROM rss")
     rows = self.cur.fetchall(
     )  #returns a list ==> (name, feed_link, last_link, last_title, filters)
     if rows:
         for row in rows:
             f_lists = []
             if row[4] is not None:
                 filters_list = row[4].split('|')
                 for x in filters_list:
                     y = x.split(' or ')
                     f_lists.append(y)
             rss_dict[row[0]] = [row[1], row[2], row[3], f_lists]
         LOGGER.info("Rss data has been imported from Database.")
     self.disconnect()
Exemplo n.º 11
0
def authorize(update, context):
    reply_message = update.message.reply_to_message
    msg = ''
    with open('authorized_chats.txt', 'a') as file:
        if reply_message is None:
            # Trying to authorize a chat
            chat_id = update.effective_chat.id
            if chat_id not in AUTHORIZED_CHATS:
                file.write(f'{chat_id}\n')
                AUTHORIZED_CHATS.add(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 not in AUTHORIZED_CHATS:
                file.write(f'{user_id}\n')
                AUTHORIZED_CHATS.add(user_id)
                msg = 'Quyền sử dụng bot đã được mở!'
            else:
                msg = 'Quyền sử dụng bot đã bị khoá!'
        sendMessage(msg, context.bot, update)
Exemplo n.º 12
0
def authorize(update, context):
    reply_message = update.message.reply_to_message
    msg = ''
    with open('authorized_chats.txt', 'a') as file:
        if reply_message is None:
            # Trying to authorize a chat
            chat_id = update.effective_chat.id
            if chat_id not in AUTHORIZED_CHATS:
                file.write(f'{chat_id}\n')
                AUTHORIZED_CHATS.add(chat_id)
                msg = 'Congratulations! This Chat has been successfully authorized'
            else:
                msg = 'This Chat is Already authorized!'
        else:
            # Trying to authorize someone in specific
            user_id = reply_message.from_user.id
            if user_id not in AUTHORIZED_CHATS:
                file.write(f'{user_id}\n')
                AUTHORIZED_CHATS.add(user_id)
                msg = 'This guy is now Authorized to use the bot!'
            else:
                msg = 'This guy is already authorized'
        sendMessage(msg, context.bot, update)
Exemplo n.º 13
0
def authorize(update, context):
    reply_message = update.message.reply_to_message
    msg = ''
    with open('authorized_chats.txt', 'a') as file:
        if reply_message is None:
            # Trying to authorize a chat
            chat_id = update.effective_chat.id
            if chat_id not in AUTHORIZED_CHATS:
                file.write(f'{chat_id}\n')
                AUTHORIZED_CHATS.add(chat_id)
                msg = '⚜ Chat Authorize'
            else:
                msg = 'Already authorized chat'
        else:
            # Trying to authorize someone in specific
            user_id = reply_message.from_user.id
            if user_id not in AUTHORIZED_CHATS:
                file.write(f'{user_id}\n')
                AUTHORIZED_CHATS.add(user_id)
                msg = '🙍‍♂️ Person Authorized 🙍‍♀️'
            else:
                msg = 'Person already authorized'
        sendMessage(msg, context.bot, update)
Exemplo n.º 14
0
def authorize(update, context):
    reply_message = update.message.reply_to_message
    msg = ""
    with open("authorized_chats.txt", "a") as file:
        if reply_message is None:
            # Trying to authorize a chat
            chat_id = update.effective_chat.id
            if chat_id not in AUTHORIZED_CHATS:
                file.write(f"{chat_id}\n")
                AUTHORIZED_CHATS.add(chat_id)
                msg = "Chat authorized"
            else:
                msg = "Already authorized chat"
        else:
            # Trying to authorize someone in specific
            user_id = reply_message.from_user.id
            if user_id not in AUTHORIZED_CHATS:
                file.write(f"{user_id}\n")
                AUTHORIZED_CHATS.add(user_id)
                msg = "Person Authorized to use the bot!"
            else:
                msg = "Person already authorized"
        sendMessage(msg, context.bot, update)
Exemplo n.º 15
0
def authorize(update,context):
    reply_message = update.message.reply_to_message
    msg = ''
    with open('authorized_chats.txt', 'a') as file:
        if reply_message is None:
            # Trying to authorize a chat
            chat_id = update.effective_chat.id
            if chat_id not in AUTHORIZED_CHATS:
                file.write(f'{chat_id}\n')
                AUTHORIZED_CHATS.add(chat_id)
                msg = '⛽𝐓𝐡𝐢𝐬 𝐂𝐡𝐚𝐭 𝐀𝐮𝐭𝐡𝐨𝐫𝐢𝐳𝐞𝐝'
            else:
                msg = '⛽𝐓𝐡𝐢𝐬 𝐂𝐡𝐚𝐭 𝐈𝐬 𝐀𝐥𝐫𝐞𝐚𝐝𝐲 𝐀𝐮𝐭𝐡𝐨𝐫𝐢𝐳𝐞𝐝'
        else:
            # Trying to authorize someone in specific
            user_id = reply_message.from_user.id
            if user_id not in AUTHORIZED_CHATS:
                file.write(f'{user_id}\n')
                AUTHORIZED_CHATS.add(user_id)
                msg = '⛽𝐏𝐞𝐫𝐬𝐨𝐧 𝐀𝐮𝐭𝐡𝐨𝐫𝐢𝐳𝐞𝐝 𝐓𝐨 𝐔𝐬𝐞 𝐓𝐡𝐞 𝐁𝐨𝐭'
            else:
                msg = '⛽𝐏𝐞𝐫𝐬𝐨𝐧 𝐀𝐥𝐫𝐞𝐚𝐝𝐲 𝐀𝐮𝐭𝐡𝐨𝐫𝐢𝐳𝐞𝐝 𝐓𝐨 𝐔𝐬𝐞 𝐓𝐡𝐞 𝐁𝐨𝐭'
        sendMessage(msg, context.bot, update)
Exemplo n.º 16
0
def authorize(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 not in AUTHORIZED_CHATS:
            if DB_URI is not None:
                msg = DbManger().db_auth(user_id)
            else:
                with open('authorized_chats.txt', 'a') as file:
                    file.write(f'{user_id}\n')
                    AUTHORIZED_CHATS.add(user_id)
                    msg = '✅ User Authorized'
        else:
            msg = '✅ User Already Authorized'
    else:
        if reply_message is None:
            # Trying to authorize a chat
            chat_id = update.effective_chat.id
            if chat_id not in AUTHORIZED_CHATS:
                if DB_URI is not None:
                    msg = DbManger().db_auth(chat_id)
                else:
                    with open('authorized_chats.txt', 'a') as file:
                        file.write(f'{chat_id}\n')
                        AUTHORIZED_CHATS.add(chat_id)
                        msg = '✅ Chat Authorized'
            else:
                msg = '✅ Chat Already Authorized'

        else:
            # Trying to authorize someone by replying
            user_id = reply_message.from_user.id
            if user_id not in AUTHORIZED_CHATS:
                if DB_URI is not None:
                    msg = DbManger().db_auth(user_id)
                else:
                    with open('authorized_chats.txt', 'a') as file:
                        file.write(f'{user_id}\n')
                        AUTHORIZED_CHATS.add(user_id)
                        msg = '✅ User Authorized'
            else:
                msg = '✅ User Already Authorized'
    sendMessage(msg, context.bot, update)