Skip to content

Commit

Permalink
Merge pull request #571 from botpress/fix-variables-dollar
Browse files Browse the repository at this point in the history
fix(builtins): allow $ in variable names
  • Loading branch information
slvnperron authored May 29, 2018
2 parents 4bcc9b2 + 4818d2e commit 916cdaf
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
24 changes: 12 additions & 12 deletions packages/core/botpress-builtins/src/actions/storage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const setUserVariable = baseAction(
...Annotate('Storage', 'Set user variable', "Stores a variable under this user's storage, with optional expiry"),
name: Joi.string()
.required()
.token()
.regex(/^[a-z0-9_$]+$/i, 'token with allowed $')
.description('The name of the variable.'),
value: Joi.any()
.optional()
Expand All @@ -41,12 +41,12 @@ export const getUserVariable = baseAction(
),
name: Joi.string()
.required()
.token()
.regex(/^[a-z0-9_$]+$/i, 'token with allowed $')
.description('The name of the variable.'),
output: Joi.string()
.required()
.default('$r')
.token()
.regex(/^[a-z0-9_$]+$/i, 'token with allowed $')
.description('The state variable to output to')
})
)
Expand All @@ -61,7 +61,7 @@ export const resetUserVariable = baseAction(
...Annotate('Storage', 'Reset user variable', 'Deletes a user variable'),
name: Joi.string()
.required()
.token()
.regex(/^[a-z0-9_$]+$/i, 'token with allowed $')
.description('The name of the variable.')
})
)
Expand All @@ -80,7 +80,7 @@ export const setConversationVariable = baseAction(
),
name: Joi.string()
.required()
.token()
.regex(/^[a-z0-9_$]+$/i, 'token with allowed $')
.description('The name of the variable.'),
value: Joi.any()
.optional()
Expand All @@ -107,12 +107,12 @@ export const getConversationVariable = baseAction(
),
name: Joi.string()
.required()
.token()
.regex(/^[a-z0-9_$]+$/i, 'token with allowed $')
.description('The name of the variable.'),
output: Joi.string()
.required()
.default('$r')
.token()
.regex(/^[a-z0-9_$]+$/i, 'token with allowed $')
.description('The state variable to output to')
})
)
Expand All @@ -127,7 +127,7 @@ export const resetConversationVariable = baseAction(
...Annotate('Storage', 'Reset conversation variable', 'Deletes a conversation variable'),
name: Joi.string()
.required()
.token()
.regex(/^[a-z0-9_$]+$/i, 'token with allowed $')
.description('The name of the variable.')
})
)
Expand All @@ -141,7 +141,7 @@ export const setGlobalVariable = baseAction(
...Annotate('Storage', 'Set global variable', 'Stores a variable globally, with optional expiry'),
name: Joi.string()
.required()
.token()
.regex(/^[a-z0-9_$]+$/i, 'token with allowed $')
.description('The name of the variable.'),
value: Joi.any()
.optional()
Expand All @@ -167,12 +167,12 @@ export const getGlobalVariable = baseAction(
),
name: Joi.string()
.required()
.token()
.regex(/^[a-z0-9_$]+$/i, 'token with allowed $')
.description('The name of the variable.'),
output: Joi.string()
.required()
.default('$r')
.token()
.regex(/^[a-z0-9_$]+$/i, 'token with allowed $')
.description('The state variable to output to')
})
)
Expand All @@ -186,7 +186,7 @@ export const resetGlobalVariable = baseAction(
...Annotate('Storage', 'Reset global variable', 'Deletes a global variable'),
name: Joi.string()
.required()
.token()
.regex(/^[a-z0-9_$]+$/i, 'token with allowed $')
.description('The name of the variable.')
})
)
4 changes: 2 additions & 2 deletions packages/dev-bot/generated/flows/main.flow.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
{
"id": "a54a82eb7c",
"name": "entry",
"onEnter": ["getUserVariable {\"name\":\"nickname\"}"],
"onEnter": ["getUserVariable {\"name\":\"nickname\",\"output\":\"$r\"}"],
"onReceive": null,
"next": [
{
Expand All @@ -80,7 +80,7 @@
"onEnter": ["say #!builtin_text-z0J9qh"],
"onReceive": [
"setUserVariable {\"name\":\"nickname\",\"value\":\"{{event.text}}\",\"expiry\":\"never\"}",
"getUserVariable {\"name\":\"nickname\"}"
"getUserVariable {\"name\":\"nickname\",\"output\":\"$r\"}"
]
}
]
Expand Down
4 changes: 2 additions & 2 deletions templates/init-default/generated/flows/main.flow.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
{
"id": "a54a82eb7c",
"name": "entry",
"onEnter": ["getUserVariable {\"name\":\"nickname\"}"],
"onEnter": ["getUserVariable {\"name\":\"nickname\",\"output\":\"$r\"}"],
"onReceive": null,
"next": [
{
Expand All @@ -80,7 +80,7 @@
"onEnter": ["say #!builtin_text-z0J9qh"],
"onReceive": [
"setUserVariable {\"name\":\"nickname\",\"value\":\"{{event.text}}\",\"expiry\":\"never\"}",
"getUserVariable {\"name\":\"nickname\"}"
"getUserVariable {\"name\":\"nickname\",\"output\":\"$r\"}"
]
}
]
Expand Down

0 comments on commit 916cdaf

Please sign in to comment.