Socket
Socket
Sign inDemoInstall

tmi.js

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tmi.js - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

4

gruntfile.js

@@ -20,4 +20,4 @@ module.exports = function(grunt) {

options: {
exclude: ["irc"],
ignore: ["irc"]
exclude: ["irc", "cron", "locallydb"],
ignore: ["irc", "cron", "locallydb"]
}

@@ -24,0 +24,0 @@ }

var bunyan = require("bunyan");
var cron = require("cron");
var eventEmitter = require("events").EventEmitter;
var irc = require("irc");
var locallydb = require("locallydb");
var parse = require("irc-message").parse;

@@ -545,2 +547,6 @@ var timer = require("./timer");

break;
case "WHISPER":
self.log.info("[WHISPER] <" + message.prefix.split("!")[0] + ">: " + message.args[1]);
self.emit("whisper", message.prefix.split("!")[0], message.args[1]);
break;
case "PRIVMSG":

@@ -739,2 +745,6 @@ message.tags = {};

if (this.protocol === "irc") {
return this._sendCommandIRC(channel, command);
}
// Promise a result..

@@ -778,2 +788,6 @@ return new vow.Promise(function(resolve, reject, notify) {

if (this.protocol === "irc") {
return this._sendMessageIRC(channel, message);
}
// Promise a result..

@@ -909,15 +923,15 @@ return new vow.Promise(function(resolve, reject, notify) {

message = "\u0001ACTION " + message + "\u0001";
return this.protocol === "websocket" ? this._sendMessage(channel, message) : this._sendMessageIRC(channel, message);
return this._sendMessage(channel, message);
};
client.prototype.ban = function ban(channel, username) {
return this.protocol === "websocket" ? this._sendCommand(channel, "/ban " + utils.normalizeUsername(username)) : this._sendCommandIRC(channel, "/ban " + utils.normalizeUsername(username));
return this._sendCommand(channel, "/ban " + utils.normalizeUsername(username));
};
client.prototype.clear = function clear(channel) {
return this.protocol === "websocket" ? this._sendCommand(channel, "/clear") : this._sendCommandIRC(channel, "/clear");
return this._sendCommand(channel, "/clear");
};
client.prototype.color = function color(channel, color) {
return this.protocol === "websocket" ? this._sendCommand(channel, "/color " + color) : this._sendCommandIRC(channel, "/color " + color);
return this._sendCommand(channel, "/color " + color);
};

@@ -927,43 +941,43 @@

seconds = typeof seconds !== 'undefined' ? seconds : 30;
return this.protocol === "websocket" ? this._sendCommand(channel, "/commercial " + seconds) : this._sendCommandIRC(channel, "/commercial " + seconds);
return this._sendCommand(channel, "/commercial " + seconds);
};
client.prototype.host = function host(channel, target) {
return this.protocol === "websocket" ? this._sendCommand(channel, "/host " + utils.normalizeUsername(target)) : this._sendCommandIRC(channel, "/host " + utils.normalizeUsername(target));
return this._sendCommand(channel, "/host " + utils.normalizeUsername(target));
};
client.prototype.join = function join(channel) {
return this.protocol === "websocket" ? this._sendCommand(null, "JOIN " + utils.normalizeChannel(channel)) : this._sendCommandIRC(null, "JOIN " + utils.normalizeChannel(channel));
return this._sendCommand(null, "JOIN " + utils.normalizeChannel(channel));
};
client.prototype.mod = function mod(channel, username) {
return this.protocol === "websocket" ? this._sendCommand(channel, "/mod " + utils.normalizeUsername(username)) : this._sendCommandIRC(channel, "/mod " + utils.normalizeUsername(username));
return this._sendCommand(channel, "/mod " + utils.normalizeUsername(username));
};
client.prototype.mods = function mods(channel) {
return this.protocol === "websocket" ? this._sendCommand(channel, "/mods") : this._sendCommandIRC(channel, "/mods");
return this._sendCommand(channel, "/mods");
};
client.prototype.part = client.prototype.leave = function part(channel) {
return this.protocol === "websocket" ? this._sendCommand(null, "PART " + utils.normalizeChannel(channel)) : this._sendCommandIRC(null, "PART " + utils.normalizeChannel(channel));
return this._sendCommand(null, "PART " + utils.normalizeChannel(channel));
};
client.prototype.ping = function ping() {
return this.protocol === "websocket" ? this._sendCommand(null, "PING") : this._sendCommandIRC(null, "PING");
return this._sendCommand(null, "PING");
};
client.prototype.r9kbeta = client.prototype.r9kmode = function r9kbeta(channel) {
return this.protocol === "websocket" ? this._sendCommand(channel, "/r9kbeta") : this._sendCommandIRC(channel, "/r9kbeta");
return this._sendCommand(channel, "/r9kbeta");
};
client.prototype.r9kbetaoff = client.prototype.r9kmodeoff = function r9kbetaoff(channel) {
return this.protocol === "websocket" ? this._sendCommand(channel, "/r9kbetaoff") : this._sendCommandIRC(channel, "/r9kbetaoff");
return this._sendCommand(channel, "/r9kbetaoff");
};
client.prototype.raw = function raw(message) {
return this.protocol === "websocket" ? this._sendCommand(null, message) : this._sendCommandIRC(null, message);
return this._sendCommand(null, message);
};
client.prototype.say = function say(channel, message) {
return this.protocol === "websocket" ? this._sendMessage(channel, message) : this._sendMessageIRC(channel, message);
return this._sendMessage(channel, message);
};

@@ -974,15 +988,15 @@

return this.protocol === "websocket" ? this._sendCommand(channel, "/seconds " + seconds) : this._sendCommandIRC(channel, "/seconds " + seconds);
return this._sendCommand(channel, "/seconds " + seconds);
};
client.prototype.slowoff = client.prototype.slowmodeoff = function slowoff(channel) {
return this.protocol === "websocket" ? this._sendCommand(channel, "/slowoff") : this._sendCommandIRC(channel, "/slowoff");
return this._sendCommand(channel, "/slowoff");
};
client.prototype.subscribers = function subscribers(channel) {
return this.protocol === "websocket" ? this._sendCommand(channel, "/subscribers") : this._sendCommandIRC(channel, "/subscribers");
return this._sendCommand(channel, "/subscribers");
};
client.prototype.subscribersoff = function subscribersoff(channel) {
return this.protocol === "websocket" ? this._sendCommand(channel, "/subscribersoff") : this._sendCommandIRC(channel, "/subscribersoff");
return this._sendCommand(channel, "/subscribersoff");
};

@@ -994,21 +1008,225 @@

return this.protocol === "websocket" ? this._sendCommand(channel, "/timeout " + username + " " + seconds) : this._sendCommandIRC(channel, "/timeout " + username + " " + seconds);
return this._sendCommand(channel, "/timeout " + username + " " + seconds);
};
client.prototype.unban = function unban(channel, username) {
return this.protocol === "websocket" ? this._sendCommand(channel, "/unban " + utils.normalizeUsername(username)) : this._sendCommandIRC(channel, "/unban " + utils.normalizeUsername(username));
return this._sendCommand(channel, "/unban " + utils.normalizeUsername(username));
};
client.prototype.unhost = function unhost(channel) {
return this.protocol === "websocket" ? this._sendCommand(channel, "/unhost") : this._sendCommandIRC(channel, "/unhost");
return this._sendCommand(channel, "/unhost");
};
client.prototype.unmod = function unmod(channel, username) {
return this.protocol === "websocket" ? this._sendCommand(channel, "/unmod " + utils.normalizeUsername(username)) : this._sendCommandIRC(channel, "/unmod " + utils.normalizeUsername(username));
return this._sendCommand(channel, "/unmod " + utils.normalizeUsername(username));
};
client.prototype.whisper = function whisper(username, message) {
return this.protocol === "websocket" ? this._sendMessage("#jtv", "/w " + utils.normalizeUsername(username) + " " + message) : this._sendMessageIRC("#jtv", "/w " + utils.normalizeUsername(username) + " " + message);
return this._sendMessage("#jtv", "/w " + utils.normalizeUsername(username) + " " + message);
};
client.prototype.utils = {
cronjobs: function cronjobs(time, fn) {
return new cron.CronJob(time, function () {
fn();
}, null, false);
},
levenshtein: function levenshtein(s1, s2, caseSensitive) {
var cost_ins = 1;
var cost_rep = 1;
var cost_del = 1;
caseSensitive = typeof caseSensitive !== 'undefined' ? caseSensitive : false;
if (!caseSensitive) {
s1 = s1.toLowerCase();
s2 = s2.toLowerCase();
}
if (s1 == s2) { return 0; }
var l1 = s1.length;
var l2 = s2.length;
if (l1 === 0) { return l2 * cost_ins; }
if (l2 === 0) { return l1 * cost_del; }
var split = false;
try {
split = !('0')[0];
} catch (e) {
split = true;
}
if (split) {
s1 = s1.split('');
s2 = s2.split('');
}
var p1 = new Array(l2 + 1);
var p2 = new Array(l2 + 1);
var i1, i2, c0, c1, c2, tmp;
for (i2 = 0; i2 <= l2; i2++) {
p1[i2] = i2 * cost_ins;
}
for (i1 = 0; i1 < l1; i1++) {
p2[0] = p1[0] + cost_del;
for (i2 = 0; i2 < l2; i2++) {
c0 = p1[i2] + ((s1[i1] == s2[i2]) ? 0 : cost_rep);
c1 = p1[i2 + 1] + cost_del;
if (c1 < c0) {
c0 = c1;
}
c2 = p2[i2] + cost_ins;
if (c2 < c0) {
c0 = c2;
}
p2[i2 + 1] = c0;
}
tmp = p1;
p1 = p2;
p2 = tmp;
}
c0 = p1[l2];
return c0;
},
raffle: {
init: function init(channel) {
if (!this.raffleChannels) { this.raffleChannels = {}; }
if (!this.raffleChannels[utils.normalizeChannel(channel)]) { this.raffleChannels[utils.normalizeChannel(channel)] = []; }
},
enter: function enter(channel, username) {
this.init(channel);
this.raffleChannels[utils.normalizeChannel(channel)].push(username.toLowerCase());
},
leave: function leave(channel, username) {
this.init(channel);
var index = this.raffleChannels[utils.normalizeChannel(channel)].indexOf(utils.normalizeUsername(username));
if (index >= 0) {
this.raffleChannels[utils.normalizeChannel(channel)].splice(index, 1);
return true;
}
return false;
},
pick: function pick(channel) {
this.init(channel);
var count = this.raffleChannels[utils.normalizeChannel(channel)].length;
if (count >= 1) {
return this.raffleChannels[utils.normalizeChannel(channel)][Math.floor((Math.random() * count))];
}
return null;
},
reset: function reset(channel) {
this.init(channel);
this.raffleChannels[utils.normalizeChannel(channel)] = [];
},
count: function count(channel) {
this.init(channel);
if (this.raffleChannels[utils.normalizeChannel(channel)]) {
return this.raffleChannels[utils.normalizeChannel(channel)].length;
}
return 0;
},
isParticipating: function isParticipating(channel, username) {
this.init(channel);
if (this.raffleChannels[utils.normalizeChannel(channel)].indexOf(utils.normalizeUsername(username)) >= 0) {
return true;
}
return false;
}
},
symbols: function symbols(line) {
var count = 0;
for (var i = 0; i < line.length; i++) {
var charCode = line.substring(i, i+1).charCodeAt(0);
if ((charCode <= 30 || charCode >= 127) || charCode === 65533) {
count++;
}
}
return Math.ceil((count / line.length) * 100) / 100;
},
uppercase: function uppercase(line) {
var chars = line.length;
var u_let = line.match(/[A-Z]/g);
if (u_let !== null) {
return (u_let.length / chars);
}
return 0;
}
};
client.prototype.nosql = {
database: function database() {
return this.database;
},
path: function path(database) {
this.database = new locallydb(database);
},
insert: function insert(collection, elements) {
var self = this;
if (typeof this.database === "undefined") { this.path("./database"); }
return new vow.Promise(function(resolve) {
resolve(self.database.collection(collection).insert(elements));
});
},
where: function where(collection, query) {
var self = this;
if (typeof this.database === "undefined") { this.path("./database"); }
return new vow.Promise(function(resolve) {
resolve(self.database.collection(collection).where(query));
});
},
get: function get(collection, cid) {
var self = this;
if (typeof this.database === "undefined") { this.path("./database"); }
return new vow.Promise(function(resolve) {
resolve(self.database.collection(collection).get(cid) || null);
});
},
list: function list(collection) {
var self = this;
if (typeof this.database === "undefined") { this.path("./database"); }
return new vow.Promise(function(resolve) {
resolve(self.database.collection(collection).items);
});
},
update: function update(collection, cid, object) {
var self = this;
if (typeof this.database === "undefined") { this.path("./database"); }
return new vow.Promise(function(resolve) {
resolve(self.database.collection(collection).update(cid, object));
});
},
replace: function replace(collection, cid, object) {
var self = this;
if (typeof this.database === "undefined") { this.path("./database"); }
return new vow.Promise(function(resolve) {
resolve(self.database.collection(collection).replace(cid, object));
});
},
remove: function remove(collection, cid) {
var self = this;
if (typeof this.database === "undefined") { this.path("./database"); }
return new vow.Promise(function(resolve) {
resolve(self.database.collection(collection).remove(cid));
});
}
};
// Expose everything, for browser and Node.js / io.js

@@ -1015,0 +1233,0 @@ if (typeof window !== "undefined") {

{
"name": "tmi.js",
"version": "0.0.3",
"version": "0.0.4",
"description": "Javascript library for the Twitch Messaging Interface.",

@@ -13,4 +13,6 @@ "main": "index.js",

"bunyan": "^1.4.0",
"cron": "^1.0.9",
"irc": "^0.3.12",
"irc-message": "^3.0.1",
"locallydb": "0.0.9",
"vow": "^0.4.10",

@@ -33,4 +35,6 @@ "ws": "^0.7.2"

"browserify-shim": {
"irc": "global:irc"
"irc": "global:irc",
"cron": "global:cron",
"locallydb": "global:locallydb"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc