mirror of
https://github.com/kolbytn/mindcraft.git
synced 2025-03-28 14:56:24 +01:00
fixed command parsing and allow startconvo during convo
This commit is contained in:
parent
a1a6f60d8d
commit
5eb35e993a
3 changed files with 11 additions and 25 deletions
|
@ -231,12 +231,7 @@ export class Agent {
|
|||
message = await handleEnglishTranslation(message);
|
||||
console.log('received message from', source, ':', message);
|
||||
|
||||
const checkInterrupt = () => {
|
||||
const interrupt = this.self_prompter.shouldInterrupt(self_prompt) || this.shut_up || convoManager.responseScheduledFor(source);
|
||||
if (interrupt)
|
||||
console.log('Interrupting loop!');
|
||||
return interrupt;
|
||||
}
|
||||
const checkInterrupt = () => this.self_prompter.shouldInterrupt(self_prompt) || this.shut_up || convoManager.responseScheduledFor(source);
|
||||
|
||||
let behavior_log = this.bot.modes.flushBehaviorLog();
|
||||
if (behavior_log.trim().length > 0) {
|
||||
|
|
|
@ -99,12 +99,12 @@ export const actionsList = [
|
|||
}, true)
|
||||
},
|
||||
{
|
||||
name: '!goToPosition',
|
||||
name: '!goToCoordinates',
|
||||
description: 'Go to the given x, y, z location.',
|
||||
params: {
|
||||
'x': {type: 'float', description: 'The x coordinate.', domain: [0, Infinity]},
|
||||
'y': {type: 'float', description: 'The y coordinate.', domain: [-64, 320]},
|
||||
'z': {type: 'float', description: 'The z coordinate.', domain: [0, Infinity]},
|
||||
'x': {type: 'int', description: 'The x coordinate.', domain: [-Infinity, Infinity]},
|
||||
'y': {type: 'int', description: 'The y coordinate.', domain: [-64, 320]},
|
||||
'z': {type: 'int', description: 'The z coordinate.', domain: [-Infinity, Infinity]},
|
||||
'closeness': {type: 'float', description: 'How close to get to the location.', domain: [0, Infinity]}
|
||||
},
|
||||
perform: runAsAction(async (agent, x, y, z, closeness) => {
|
||||
|
@ -386,8 +386,8 @@ export const actionsList = [
|
|||
'message': { type: 'string', description: 'The message to send.' },
|
||||
},
|
||||
perform: async function (agent, player_name, message) {
|
||||
if (convoManager.inConversation())
|
||||
return 'Already in conversation.';
|
||||
if (convoManager.inConversation() && !convoManager.inConversation(player_name))
|
||||
return 'You are already talking to someone else.';
|
||||
if (!convoManager.isOtherAgent(player_name))
|
||||
return player_name + ' is not a bot, cannot start conversation.';
|
||||
convoManager.startConversation(player_name, message);
|
||||
|
|
|
@ -14,8 +14,8 @@ export function getCommand(name) {
|
|||
return commandMap[name];
|
||||
}
|
||||
|
||||
const commandRegex = /!(\w+)(?:\(((?:\d+|true|false|"[^"]*")(?:\s*,\s*(?:\d+|true|false|"[^"]*"))*)\))?/
|
||||
const argRegex = /\d+|true|false|"[^"]*"/g;
|
||||
const commandRegex = /!(\w+)(?:\(((?:-?\d+|true|false|"[^"]*")(?:\s*,\s*(?:-?\d+|true|false|"[^"]*"))*)\))?/
|
||||
const argRegex = /-?\d+|true|false|"[^"]*"/g;
|
||||
|
||||
export function containsCommand(message) {
|
||||
const commandMatch = message.match(commandRegex);
|
||||
|
@ -106,15 +106,6 @@ export function parseCommandMessage(message) {
|
|||
const param = params[i];
|
||||
//Remove any extra characters
|
||||
let arg = args[i].trim();
|
||||
if ((arg.startsWith('"') && arg.endsWith('"')) || (arg.startsWith("'") && arg.endsWith("'"))) {
|
||||
arg = arg.substring(1, arg.length-1);
|
||||
}
|
||||
|
||||
if (arg.includes('=')) {
|
||||
// this sanitizes syntaxes like "x=2" and ignores the param name
|
||||
let split = arg.split('=');
|
||||
args[i] = split[1];
|
||||
}
|
||||
|
||||
//Convert to the correct type
|
||||
switch(param.type) {
|
||||
|
|
Loading…
Add table
Reference in a new issue