|
@@ -206,6 +206,17 @@ IrcConnection.prototype.chanCompat = function(chanId) {
|
|
|
return '#' +chan.name.replace(/\s/g, '') +'@' +ctx.team.name;
|
|
return '#' +chan.name.replace(/\s/g, '') +'@' +ctx.team.name;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+IrcConnection.prototype.writeMsg = function(msg, chanCompatId) {
|
|
|
|
|
+ var pretext = ":" +(msg.user ? this.userCompat(msg.user) : msg.username) +" PRIVMSG " +chanCompatId +" :";
|
|
|
|
|
+ if (msg.isMeMessage)
|
|
|
|
|
+ pretext += String.fromCharCode(0x01) +"ACTION ";
|
|
|
|
|
+ this.write(pretext +msg.text);
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+IrcConnection.prototype.writeNotice = function(msg) {
|
|
|
|
|
+ this.write(":" +SERVER_CONFIG.hostname +" NOTICE " +SERVER_CONFIG.hostname +" :" +msg);
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
IrcConnection.prototype.sendLiveUpdate = function(live) {
|
|
IrcConnection.prototype.sendLiveUpdate = function(live) {
|
|
|
for (var chanId in live) {
|
|
for (var chanId in live) {
|
|
|
let chanCompatId = this.chanCompat(chanId, this);
|
|
let chanCompatId = this.chanCompat(chanId, this);
|
|
@@ -219,10 +230,7 @@ IrcConnection.prototype.sendLiveUpdate = function(live) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- var pretext = ":" +(msg.user ? this.userCompat(msg.user) : msg.username) +" PRIVMSG " +chanCompatId +" :";
|
|
|
|
|
- if (msg.isMeMessage)
|
|
|
|
|
- pretext += String.fromCharCode(0x01) +"ACTION ";
|
|
|
|
|
- this.write(pretext +msg.text);
|
|
|
|
|
|
|
+ this.writeMsg(msg, chanCompatId);
|
|
|
}, this);
|
|
}, this);
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
@@ -336,6 +344,42 @@ IrcConnection.prototype.parse = function(str) {
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
|
|
+ case "HISTO":
|
|
|
|
|
+ case "HISTORY":
|
|
|
|
|
+ if (cmd.args[0].toUpperCase() === "HELP") {
|
|
|
|
|
+ this.writeNotice("Usage: /histo #channel [count=50]");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ var target = cmd.args[0].split('@', 2),
|
|
|
|
|
+ found = false;
|
|
|
|
|
+
|
|
|
|
|
+ if (target[0][0] === '#')
|
|
|
|
|
+ target[0] = target[0].substr(1);
|
|
|
|
|
+ ctxLoop: for (let i =0, nbCtx = this.chatContext.contexts.length; i < nbCtx; i++) {
|
|
|
|
|
+ let ctx = this.chatContext.contexts[i];
|
|
|
|
|
+ if (ctx.getChatContext().team && ctx.getChatContext().team.name === target[1]) {
|
|
|
|
|
+ for (let chanId in ctx.getChatContext().channels) {
|
|
|
|
|
+ let chan = ctx.getChatContext().channels[chanId];
|
|
|
|
|
+ if (chan.name === target[0] || (chan.user && chan.user.getName() === target[0])) {
|
|
|
|
|
+ found = true;
|
|
|
|
|
+ ctx.fetchHistory(chan, (msgs) => {
|
|
|
|
|
+ msgs.sort((a, b) => {
|
|
|
|
|
+ return a.ts -b.ts;
|
|
|
|
|
+ });
|
|
|
|
|
+ msgs.forEach((msg) => {
|
|
|
|
|
+ msg.user = msg.user || msg.userId;
|
|
|
|
|
+ this.writeMsg(msg, cmd.args[0]);
|
|
|
|
|
+ });
|
|
|
|
|
+ }, Math.max(5, Math.min(150, cmd.args[1] || 50)));
|
|
|
|
|
+ break ctxLoop;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!found)
|
|
|
|
|
+ this.writeNotice("Chan not found: " +cmd.args[0]);
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+
|
|
|
default:
|
|
default:
|
|
|
if (DEBUG)
|
|
if (DEBUG)
|
|
|
console.log(cmd);
|
|
console.log(cmd);
|