def unregToken(self, chat_id: int): ''' chat_id of owner ''' db = Database() db.connection() db.delTeamOrOwner(chat_id=chat_id)
def unregChat(self, chat_id): ''' chat_id of user ''' db = Database() db.connection() return db.delUser(chat_id=chat_id)
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
def listChat(self, chat_id): ''' chat_id of owner ''' db = Database() db.connection() hasil = messageformat.parsingList(db.getUser(chat_id=chat_id)) return hasil
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)
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
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)
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
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")
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)
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
def tesaja(self): db = Database() db.connection() hasilquery = db.tesquery() return hasilquery
def removeToken(self, chat_id: int): db = Database() db.connection() db.updateOwner(chat_id=chat_id, token=None)