Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add some mediocre factoid quoting support; Fixes #6

  • Loading branch information...
commit 808ed5226ff7fa9e0e58c5e6796cad251569d164 1 parent 9920870
@dsamarin dsamarin authored
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,
Please sign in to comment.
Something went wrong with that request. Please try again.