def target_items_in_container(self, user_input, input_kwargs): target = None for y in Gen.items_in_container(input_kwargs['target_parent']): if Lex.first_three(y.keyword) in user_input: target = y print("HANDLER | Target Found: item in container, ", target) # print("Items in room:", item_list) return target
def target_items_in_room(self, user_input, input_kwargs): # check if the target is an item in the room target = None for y in Gen.items_in_room(self): if Lex.first_three(y.keyword) in user_input: target = y print("HANDLER | Target Found: item in room, ", target) return target
def target_items_in_self_l_hand(self, user_input, input_kwargs): # check left hand next target = None print("hand user_input:", user_input) if self.inventory['l_hand']['contents']: if Lex.first_three(self.inventory['l_hand'] ['contents'].keyword) in user_input: target = item print("HANDLER | Target Found: self l_hand, ", target) return target
def target_self_inventory(self, user_input, input_kwargs): # check if the target is in your inventory target = None for inv in self.inventory: if self.inventory[inv]['contents']: item = self.inventory[inv]['contents'] if Lex.first_three(item.keyword) in user_input: target = item return target
def message_received(client, server, message): send_kwargs = {'type': 'text', 'spacing': True} # WsWrap.ws_send(client, send_kwargs, "") # if client['token'] == None: # client['guest_progress'] = 'name_input' # user_id = message.replace('"', "") # print(username) # client['token'] = username if client['type'] == 'guest': # server.send_message(client, send_kwargs, "> {}".format(message)) check_user(client, server, message) elif client['type'] == 'member_authenticated' or client['type'] == 'tourist': if client['obj'].conditions['echo'] == True: WsWrap.ws_send(client, {'type': 'text', 'spacing': 0}, "|repeat|> {}|repeatx|".format(message)) logging.debug('%s %s %s', ":", client['obj'].name, client['obj'].uuid_id) logging.debug('%s %s', ":", message) input_kwargs = {} all_ok = True cmd_found = False cmd_help = None user_input = message.split() print("SERVER PY | Splitting Input:", user_input) if not user_input: WsWrap.ws_send(client, send_kwargs, "|alert|No input.|alertx|") else: speaking = Input_Parser.speech(client['obj'], user_input, input_kwargs) if speaking == False: cmd_input, params = Input_Parser.parse_input(user_input) print("SERVER PY | cmd_input:", cmd_input) print("SERVER PY | params:", params) print("SERVER PY | user_input:", user_input) print("PARSE | inp matching command:", user_input) # input_kwargs['target'] = Input_Handler.full_handler(client['obj'], user_input, params) # try: T3_CMD = Lex.first_three(cmd_input) for i in all_commands: for hotkey in all_commands[i]['hotkey']: if user_input[0] == hotkey: cmd_found = True if all_commands[i]['requirements']: for func in all_commands[i]['requirements']: input_kwargs['cmd_name'] = i input_kwargs['cmd_req'] = all_commands[i]['requirements'][func]['req'] if 'help' in all_commands[i]: cmd_help = all_commands[i]['help'] status, response = all_commands[i]['requirements'][func]['func'](client['obj'], user_input, input_kwargs) input_kwargs['status'] = status input_kwargs['response'] = response if input_kwargs['status'] == False: if response != None: WsWrap.ws_send(client, {'type': 'text', 'spacing': 1}, "{}".format(response)) all_ok = False break # cmd_help if client['obj'].conditions['help'] == "enabled": if cmd_help != None: WsWrap.ws_send(client, {'type': 'text', 'spacing': 1}, "{}".format(cmd_help)) if all_ok == True: if all_commands[i]["need_com_name"] == "yes": all_commands[i]["func"](client['obj'], user_input, all_commands[i]["name"]) break elif all_commands[i]["need_com_input"] == "yes": all_commands[i]["func"](client['obj'], user_input, input_kwargs) break else: all_commands[i]["func"](client['obj']) break if cmd_found == False: WsWrap.ws_send(client, {'type': 'text', 'spacing': 1}, "Hmm?") logging.info("----------")