def waitAnswer(self): time = '[' + str(now()) + ']' print(c.green(time), self.info(), '| waiting answer') response = self.queue[TypeQ.MSG_RECEIVER].get(block=True) print(c.green(time), self.info(), '| response: ', c.orange(msg.readText(response))) return response
def __init__(self, user, queue): Thread.__init__(self) self.user = user self.entityName = self.__class__.__name__ self.daemon = True self.timeStart = now() time = '[' + str(self.timeStart) + ']' print(c.green(time), ' Start ', self.info()) if queue: self.queue = queue else: self.queue = { TypeQ.MSG_SENDER: Queue(), TypeQ.MSG_RECEIVER: Queue(), TypeQ.SWITCH_CONVERSATION: Queue() }
def sendTextWithKeyboard(self, text, buttonList): self.addMessageToSenderQ( msg.createKeyboardMessage(self.user['id'], text, buttonList)) time = '[' + str(now()) + ']' print(c.green(time), self.info(), '| sent: ', c.light_blue(text)) return self.waitAnswer()
def sendText(self, text): self.addMessageToSenderQ(msg.createTextMessage(self.user['id'], text)) time = '[' + str(now()) + ']' print(c.green(time), self.info(), '| sent: ', c.light_blue(text))
def __del__(self): self.timeEnd = now() time = '[' + str(self.timeEnd) + ']' print(c.orange(time), ' End ', self.info(), '| DT: ', delta(self.timeStart, self.timeEnd))