Skip to content

Commit

Permalink
Add some mediocre factoid quoting support; Fixes #6
Browse files Browse the repository at this point in the history
  • Loading branch information
dsamarin committed Sep 8, 2012
1 parent 9920870 commit 808ed52
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion shared.js
Expand Up @@ -101,7 +101,7 @@ var Shared = module.exports = {
learn: function(context, text) {

try {
var parsed = text.match(/^(alias)?\s*(.+?)\s*(=~?)\s*(.+)$/i);
var parsed = text.match(/^(alias)?\s*("[^"]*"|.+?)\s*(=~?)\s*(.+)$/i);
if (!parsed) {
throw new SyntaxError(
"Syntax is `learn ( [alias] foo = bar | foo =~ s/expression/replace/gi )`.");
Expand All @@ -112,6 +112,10 @@ var Shared = module.exports = {
var operation = parsed[3];
var value = parsed[4];

if (factoid.charAt(0) === '"') {
factoid = JSON.parse(factoid);
}

if (alias) {
var key = this.factoids.alias(factoid, value);
context.channel.send_reply(context.sender,
Expand Down

0 comments on commit 808ed52

Please sign in to comment.