def participate(self):
random.seed(self.worker_id)
chatbot = random.choice(self.PERSONALITIES)
WebDriverWait(self.driver, 10).until(
EC.element_to_be_clickable((By.ID, 'send-message')))
logger.info("Entering participate method")
start = time.time()
while (time.time() - start) < self.TOTAL_CHAT_TIME:
self.wait_to_send_message()
history = self.get_chat_history()
logger.info("History: %s" % history)
if history and history[-1]:
logger.info("Responding to: %s" % history[-1])
output = chatbot.respond(history[-1])
else:
logger.info("Using random greeting.")
output = random.choice(self.GREETINGS)
logger.info("Output: %s" % output)
self.send_message(output)
self.leave_chat()
评论列表
文章目录