Browse files

Add some mediocre factoid quoting support; Fixes #6

  • Loading branch information...
1 parent 9920870 commit 808ed5226ff7fa9e0e58c5e6796cad251569d164 @dsamarin dsamarin committed Sep 8, 2012
Showing with 5 additions and 1 deletion.
  1. +5 −1 shared.js
View
6 shared.js
@@ -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 )`.");
@@ -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,

0 comments on commit 808ed52

Please sign in to comment.