forked from GitHub/dbot
Correct other people [#154]
This commit is contained in:
parent
d8c133a7b3
commit
400d215734
@ -4,11 +4,18 @@ var regex = function(dbot) {
|
|||||||
this.last = {};
|
this.last = {};
|
||||||
this.listener = function(event) {
|
this.listener = function(event) {
|
||||||
var q = event.message.valMatch(/^s\/(.+)\/(.+)\/$/, 3);
|
var q = event.message.valMatch(/^s\/(.+)\/(.+)\/$/, 3);
|
||||||
|
var otherQ = event.message.valMatch(/^([\d\w\s]*): s\/(.+)\/(.+)\/$/, 4);
|
||||||
if(q) {
|
if(q) {
|
||||||
var toMatch = new RegExp(q[1]);
|
var toMatch = new RegExp(q[1]);
|
||||||
var replaceWith = q[2];
|
var replaceWith = q[2];
|
||||||
var last = this.last[event.channel.name][event.user];
|
var last = this.last[event.channel.name][event.user];
|
||||||
event.reply(event.user + " meant: " + last.replace(toMatch, replaceWith));
|
event.reply(event.user + " meant: " + last.replace(toMatch, replaceWith));
|
||||||
|
} else if(otherQ) {
|
||||||
|
var user = otherQ[1];
|
||||||
|
var toMatch = new RegExp(otherQ[2]);
|
||||||
|
var replaceWith = otherQ[3];
|
||||||
|
var last = this.last[event.channel.name][user];
|
||||||
|
event.reply(event.user + " thinks " + user + " meant: " + last.replace(toMatch, replaceWith));
|
||||||
} else {
|
} else {
|
||||||
if(_.has(this.last, event.channel.name)) {
|
if(_.has(this.last, event.channel.name)) {
|
||||||
this.last[event.channel.name][event.user] = event.message;
|
this.last[event.channel.name][event.user] = event.message;
|
||||||
|
Loading…
Reference in New Issue
Block a user