def handle_task(message): content = message.text user_id = message.chat.id if len(content) <= 64: states.remove_state(user_id) utils.create_task(user_id, content) bot.send_message(user_id, 'Done.') else: bot.send_message(user_id, 'Symbol limit exceeded, try again.')
def bid_callback(self, msg): if msg.bid: self.logger.debug("Robot {0} has bid {1}".format( msg.robot_id, msg.bid)) self._bids[msg.robot_id] = (msg.bid, utils.create_task(msg.task)) remaining_robots = [ 1 for _, bid in self._bids.iteritems() if bid[0] == -1 ] #if all bids are received if len(remaining_robots) == 0: self.logger.info("All bids received") robot_id, task = self._calc_winner() self._bids = {robot.id: (-1, None) for robot in self.robots} self._send_winner(msg.auc_id, robot_id, task)
def bid_callback(self, msg): if msg.bid: print "Robot " + str(msg.robot_id) + " has bid " + str(msg.bid) self._bids[msg.robot_id] = (msg.bid, utils.create_task(msg.task)) remaining_robots = [ 1 for _, bid in self._bids.iteritems() if bid[0] == -1 ] #if all bids are received if len(remaining_robots) == 0: print "All bids received" robot_id, task = self._calc_winner() self._bids = {(i + 1): (-1, None) for i in range(self._robot_count)} print "Sending winner" self._send_winner(msg.auc_id, robot_id, task)
def winner_callback(self, msg): print "Robot " + str(self.id) + ": Winner received" winner_robot_id = msg.robot_id task = utils.create_task(msg.task) if winner_robot_id == self.id: print "Robot " + str(self.id) + " is the winner" self.stn.insert_task(task, self._best_task_pos[task.id]) self.stn.solve_stn(self._tasks_preconditions) print "Robot " + str(self.id) + ": Following task has been scheduled." print str(task) print "" self._t_auc.remove(task) self._winner_received = True
def winner_callback(self, msg): self.logger.info("Robot {0}: Winner received".format(self.id)) winner_robot_id = msg.robot_id task = utils.create_task(msg.task) if winner_robot_id == self.id: self.logger.info("Robot {0} is the winner".format(self.id)) self.stn.insert_task(task, self._best_task_pos[task.id]) self.stn.solve_stn(self._tasks_preconditions) self.logger.debug( "Robot {0}: Following task has been scheduled.".format(self.id)) self.logger.debug("{0}".format(str(task))) self._t_auc.remove(task) self._winner_received = True