Esempio 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'
Esempio n. 2
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'
Esempio n. 3
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>'
Esempio n. 4
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 '𝙰𝚞𝚝𝚑𝚘𝚛𝚒𝚣𝚎𝚍 𝚜𝚞𝚌𝚌𝚎𝚜𝚜𝚏𝚞𝚕𝚕𝚢😉'
Esempio n. 5
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>'
Esempio n. 6
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 '𝚄𝚗𝚊𝚞𝚝𝚑𝚘𝚛𝚒𝚣𝚎𝚍 𝚜𝚞𝚌𝚌𝚎𝚜𝚜𝚏𝚞𝚕𝚕𝚢😐'
Esempio n. 7
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>'
Esempio n. 8
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"
Esempio n. 9
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 '𝚂𝚞𝚌𝚌𝚎𝚜𝚜𝚏𝚞𝚕𝚕𝚢 𝙰𝚞𝚝𝚑𝚘𝚛𝚒𝚣𝚎𝚍 𝚊𝚗𝚍 𝚙𝚛𝚘𝚖𝚘𝚝𝚎𝚍 𝚊𝚜 𝚜𝚞𝚍𝚘🤗'
Esempio n. 10
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)
Esempio n. 11
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)
Esempio n. 12
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)
Esempio n. 13
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)
Esempio n. 14
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)
Esempio n. 15
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()
Esempio n. 16
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)
Esempio n. 17
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)
Esempio n. 18
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)
Esempio n. 19
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)
Esempio n. 20
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)
Esempio n. 21
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)
Esempio n. 22
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)
Esempio n. 23
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)
Esempio n. 24
0
def authorize(bot, update):
    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, bot, update)
Esempio n. 25
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)
Esempio n. 26
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)