ctcp response
This commit is contained in:
parent
8c7c147aed
commit
8074efb8a2
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "teemantirc",
|
"name": "teemantirc",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "Web-based IRC client ",
|
"description": "Web-based IRC client",
|
||||||
"main": "teemant.js",
|
"main": "teemant.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
@ -2,6 +2,7 @@ let EventEmitter = require('events').EventEmitter;
|
|||||||
let net = require('net');
|
let net = require('net');
|
||||||
let tls = require('tls');
|
let tls = require('tls');
|
||||||
let configuration = require(__dirname+"/config");
|
let configuration = require(__dirname+"/config");
|
||||||
|
let pkg = require(__dirname+"/../package.json");
|
||||||
let parse = require(__dirname+"/parser");
|
let parse = require(__dirname+"/parser");
|
||||||
let webirc = require(__dirname+"/webirc");
|
let webirc = require(__dirname+"/webirc");
|
||||||
|
|
||||||
@ -74,6 +75,35 @@ class IRCConnectionHandler {
|
|||||||
this.conn.queue.whois[whom][a] = list[a];
|
this.conn.queue.whois[whom][a] = list[a];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ctcpManage(data) {
|
||||||
|
let line = data.trailing.replace(/\x01/g, '').trim().split(' ');
|
||||||
|
if(!line[0]) return;
|
||||||
|
|
||||||
|
let resp = "\x01"+line[0]+" {0}\x01";
|
||||||
|
|
||||||
|
switch(line[0].toLowerCase()) {
|
||||||
|
case "ping":
|
||||||
|
if(line[1] != null && line[1] != '')
|
||||||
|
resp = resp.format(line.slice(1).join(' '));
|
||||||
|
else
|
||||||
|
resp = null;
|
||||||
|
break;
|
||||||
|
case "version":
|
||||||
|
resp = resp.format("TeemantIRC ver. {0} - {1} - https://teemant.icynet.ml/".format(pkg.version, pkg.description));
|
||||||
|
break;
|
||||||
|
case "source":
|
||||||
|
resp = resp.format("https://github.com/DiamondtechDev/TeemantIRC");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
resp = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (resp != null)
|
||||||
|
this.conn.write("NOTICE {0} :{1}".format(data.user.nickname, resp));
|
||||||
|
|
||||||
|
return resp != null;
|
||||||
|
}
|
||||||
|
|
||||||
handleServerLine(line) {
|
handleServerLine(line) {
|
||||||
if(this.conn.queue["supportsmsg"] && line.command != "005") {
|
if(this.conn.queue["supportsmsg"] && line.command != "005") {
|
||||||
|
|
||||||
@ -165,12 +195,8 @@ class IRCConnectionHandler {
|
|||||||
case "PRIVMSG":
|
case "PRIVMSG":
|
||||||
let type = "privmsg";
|
let type = "privmsg";
|
||||||
|
|
||||||
if(line.trailing.indexOf('\x01ACTION') == 0) {
|
if(line.trailing.indexOf('\x01') == 0 && line.trailing.indexOf('\x01ACTION') != 0)
|
||||||
// TODO: remove once proper CTCP handling is done;
|
return this.ctcpManage(line);
|
||||||
} else if(line.trailing.indexOf('\x01') == 0) {
|
|
||||||
// TODO: handle CTCPs
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(line.user.nickname != "")
|
if(line.user.nickname != "")
|
||||||
this.conn.emit('pass_to_client', {type: "message", messageType: type, to: line.arguments[0],
|
this.conn.emit('pass_to_client', {type: "message", messageType: type, to: line.arguments[0],
|
||||||
|
Reference in New Issue
Block a user