Permalink
Browse files

fix uncaught exception in calcbot abuse checks

  • Loading branch information...
1 parent c3a6007 commit 1fbfc9869bd38c0aa237be63624f2ae4fcf62c49 @auscompgeek committed Mar 13, 2012
Showing with 3 additions and 3 deletions.
  1. +3 −3 calcbot.jsm
View
@@ -5,7 +5,7 @@
if (!run("calc.js")) throw "Could not load calc functions from calc.js";
-module.version = "2.2.1 (8 Mar 2012)";
+module.version = "2.2.2 (10 Mar 2012)";
module.prefs =
{ abuse:
{ log: true, // when triggered with =
@@ -28,7 +28,7 @@ module["cmd_="] = module.cmd_calc = module.cmd_math =
function cmd_calc(dest, msg, nick, host, at, serv, relay)
{ var msg = msg.toLowerCase();
if (msg.match(this.abuse))
- { this.prefs.abuse.warn && !relay && !fromUs && aucgbot.send("NOTICE", nick, ":Whoa! Careful dude!");
+ { this.prefs.abuse.warn && !relay && aucgbot.send("NOTICE", nick, ":Whoa! Careful dude!");
writeln("[WARNING] Abuse detected! ^^^^^");
this.prefs.abuse.log && aucgbot.log(serv, "Calc abuse", nick + (at ? " in " + dest : ""), msg);
return;
@@ -55,7 +55,7 @@ module.cmd_qe =
function cmd_quadraticEquation(dest, msg, nick, host, at, serv, relay)
{ var a, b, c, _2a, pron, resInSqrt, resSqrt, res = [];
const helpMsg = "qe: Evaluates the value of the pronumeral in a quadratic equation in general form i.e. ax**2 + bx + c = 0";
- if (!/^([+-]?\d*) ?\* ?(\w) ?\*\* ?2 ?(?:([+-] ?\d*) ?\* ?\2)? ?([+-]\d+)? ?= ?([+-]\d+)$/.test(msg))
+ if (!/^(?:([+-]?\d*) ?\*? ?)?(\w) ?(?:\*\*|\^) ?2 ?(?:([+-] ?\d*) ?\*? ?\2)? ?([+-] ?\d+)? ?= ?([+-]\d+)$/.test(msg))
{ // not a quadratic equation, bail
aucgbot.msg(dest, at + helpMsg);
return true;

0 comments on commit 1fbfc98

Please sign in to comment.