Esempio n. 1
0
 def unregToken(self, chat_id: int):
     '''
     chat_id of owner
     '''
     db = Database()
     db.connection()
     db.delTeamOrOwner(chat_id=chat_id)
Esempio n. 2
0
 def unregChat(self, chat_id):
     '''
     chat_id of user
     '''
     db = Database()
     db.connection()
     return db.delUser(chat_id=chat_id)
Esempio n. 3
0
 def unregChat(self, chat_id):
     db = Database()
     db.connection()
     ##Check if user registered to db##
     if db.delUser(chat_id=chat_id):
         return
     else:
         return False
Esempio n. 4
0
 def listChat(self, chat_id):
     '''
     chat_id of owner
     '''
     db = Database()
     db.connection()
     hasil = messageformat.parsingList(db.getUser(chat_id=chat_id))
     return hasil
Esempio n. 5
0
    def registerChat(self, chat_id: int, chat_name: str, owner_id: str):
        '''
        :param token: chat_id of owner
        '''

        db = Database()
        db.connection()
        db.insertUser(chat_id, chat_name, owner_id)
Esempio n. 6
0
 def listToken(cls):
     '''
     Return hasilparsing = (markup, teks)
     '''
     db = Database()
     db.connection()
     hasilquery = db.getOwner()
     print(f'ini hasil query {hasilquery}\n masuk messageformat')
     hasilparsing = messageformat.parsingGetOwner(hasilquery)
     print(hasilparsing)
     return hasilparsing
Esempio n. 7
0
def notifUpdate():
    parser.read("config/message.ini")
    msg = parser.get("bot", "notifUpdate")
    sticker = parser.get("bot", "notifUpdateSticker")
    parser.clear()
    db = Database()
    db.connection()

    listchat_id = db.getAllUserOwner()

    #send message
    #send message
    for i in listchat_id:
        dispatcher.bot.send_message(chat_id=i, text=msg)
        dispatcher.bot.send_sticker(chat_id=i, sticker=sticker)
Esempio n. 8
0
 def registerToken(self,
                   chat_id: int,
                   chat_name: str,
                   username: str,
                   setpin: int,
                   team_name,
                   token=None,
                   sdtid=None):
     db = Database()
     db.connection()
     #check if this user already have token imported
     if db.getOwner(chat_id=chat_id):
         return False
     self.importToken(username, setpin, sdtid, token)
     db.insertOwner(chat_id, chat_name, team_name, username)
     return
Esempio n. 9
0
    def __init__(self, chat_id):
        db = Database()
        db.connection()
        isadmin = db.getAdmin(chat_id)
        isowner = db.getOwner(chat_id=chat_id)

        if isadmin:
            self.currentRole = Admin()
            print("jadi admin")

        elif isowner:
            self.currentRole = Owner()
            print("jadi owner")

        else:
            self.currentRole = User()
            print("jadi user")
Esempio n. 10
0
def notifMaintenance():
    parser.read("config/message.ini")

    msg = parser.get("bot", "notifMaintenance")
    #msg.replace('\\n','\n')
    sticker = parser.get("bot", "notifMaintenanceSticker")
    parser.clear()
    db = Database()
    db.connection()
    print(msg)
    listchat_id = db.getAllUserOwner()
    print(listchat_id)
    #send message

    for i in listchat_id:
        dispatcher.bot.send_message(chat_id=i,
                                    text=msg,
                                    parse_mode=ParseMode.HTML)
        dispatcher.bot.send_sticker(chat_id=i, sticker=sticker)
Esempio n. 11
0
    def reqPasscode(self, tokenid, nexttoken=None):
        '''
        Return passcode->str
        :param tokenid: chat_id of current user
        '''
        db = Database()
        db.connection()
        passcode = None
        button = []

        fetchtoken = db.getUser(tokenid=tokenid)
        if fetchtoken:
            print("masuk if fetchtoken")
            username = messageformat.parsingPasscode(fetchtoken)
            print(f"ini username {username}")

            #condition check callback data button
            if not nexttoken:

                cmd = os.popen(f"stoken --rcfile=rcfile/.{username}")
                passcode = cmd.read()
                cmd.close
                print(passcode)
                return passcode, username
            else:
                cmd = os.popen(
                    f"stoken --rcfile=rcfile/.{username} --use-time=+{nexttoken}"
                )
                passcode = cmd.read()
                cmd.close()
                waktu = (datetime.now() +
                         timedelta(seconds=nexttoken)).strftime("%H:%M:%S")
                return passcode, waktu, username

        else:
            print("masuk else fetchtoken")
            return None
Esempio n. 12
0
 def tesaja(self):
     db = Database()
     db.connection()
     hasilquery = db.tesquery()
     return hasilquery
Esempio n. 13
0
 def removeToken(self, chat_id: int):
     db = Database()
     db.connection()
     db.updateOwner(chat_id=chat_id, token=None)