General whitespace and code style cleanup in ircbot and mingus code. No bug.
r=Silver on IRC (James Ross) ChatZilla Only. git-svn-id: svn://10.0.0.236/trunk@217092 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -47,27 +47,25 @@ bot.prefix = "!js ";
|
||||
|
||||
function loadDeps()
|
||||
{
|
||||
load(LIB_PATH + "utils.js");
|
||||
load(LIB_PATH + "events.js");
|
||||
load(LIB_PATH + "connection.js");
|
||||
load(LIB_PATH + "http.js");
|
||||
load(LIB_PATH + "dcc.js");
|
||||
load(LIB_PATH + "irc.js");
|
||||
load(LIB_PATH + "irc-debug.js");
|
||||
load(LIB_PATH + "message-manager.js");
|
||||
|
||||
load (LIB_PATH + "utils.js");
|
||||
load (LIB_PATH + "events.js");
|
||||
load (LIB_PATH + "connection.js");
|
||||
load (LIB_PATH + "http.js");
|
||||
load (LIB_PATH + "dcc.js");
|
||||
load (LIB_PATH + "irc.js");
|
||||
load (LIB_PATH + "irc-debug.js");
|
||||
load (LIB_PATH + "message-manager.js");
|
||||
|
||||
bot.messageManager = new MessageManager();
|
||||
|
||||
|
||||
if (!connection_init(LIB_PATH))
|
||||
return false;
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
// FIXME: Find somewhere better for these guys. //
|
||||
function toUnicode (msg, charsetOrView)
|
||||
function toUnicode(msg, charsetOrView)
|
||||
{
|
||||
if (!msg)
|
||||
return msg;
|
||||
@@ -81,7 +79,7 @@ function toUnicode (msg, charsetOrView)
|
||||
return bot.messageManager.toUnicode(msg, charset);
|
||||
}
|
||||
|
||||
function fromUnicode (msg, charsetOrView)
|
||||
function fromUnicode(msg, charsetOrView)
|
||||
{
|
||||
if (!msg)
|
||||
return msg;
|
||||
@@ -99,7 +97,6 @@ function fromUnicode (msg, charsetOrView)
|
||||
|
||||
function initStatic()
|
||||
{
|
||||
|
||||
if (jsenv.HAS_RHINO)
|
||||
gc = java.lang.System.gc;
|
||||
|
||||
@@ -113,35 +110,30 @@ function initStatic()
|
||||
CIRCChannel.prototype.onPrivmsg = my_chan_privmsg;
|
||||
CIRCUser.prototype.onDCCChat = my_user_dccchat;
|
||||
CIRCDCCChat.prototype.onRawData = my_dccchat_rawdata;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* One time initilization stuff
|
||||
*/
|
||||
*/
|
||||
function init(obj)
|
||||
{
|
||||
|
||||
obj.eventPump = new CEventPump (100);
|
||||
{
|
||||
obj.eventPump = new CEventPump(100);
|
||||
|
||||
obj.networks = new Object();
|
||||
obj.networks["hybridnet"] =
|
||||
new CIRCNetwork ("hybridnet", [{name: "irc.ssc.net", port: 6667}],
|
||||
obj.eventPump);
|
||||
new CIRCNetwork("hybridnet", [{name: "irc.ssc.net", port: 6667}],
|
||||
obj.eventPump);
|
||||
|
||||
obj.networks["moznet"] =
|
||||
new CIRCNetwork ("moznet", [{name: "irc.mozilla.org", port: 6667}],
|
||||
obj.eventPump);
|
||||
new CIRCNetwork("moznet", [{name: "irc.mozilla.org", port: 6667}],
|
||||
obj.eventPump);
|
||||
|
||||
obj.networks["efnet"] =
|
||||
new CIRCNetwork ("efnet", [
|
||||
{name: "irc.mcs.net", port: 6667},
|
||||
{name: "irc.cs.cmu.edu", port: 6667}],
|
||||
new CIRCNetwork ("efnet", [{name: "irc.mcs.net", port: 6667},
|
||||
{name: "irc.cs.cmu.edu", port: 6667}],
|
||||
obj.eventPump);
|
||||
|
||||
obj.primNet = obj.networks["efnet"];
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -149,15 +141,17 @@ function init(obj)
|
||||
*/
|
||||
function go()
|
||||
{
|
||||
|
||||
if (!loadDeps())
|
||||
return false;
|
||||
|
||||
// The utils.js formatException relies on localization, we can't. Fix:
|
||||
formatException = function formatException(ex)
|
||||
{
|
||||
if (isinstance(ex, Error) || ((typeof ex == "object") && ("filename" in ex)))
|
||||
if (isinstance(ex, Error) ||
|
||||
((typeof ex == "object") && ("filename" in ex)))
|
||||
{
|
||||
return [ex.name, ex.message, ex.fileName, ex.lineNumber].join(", ");
|
||||
}
|
||||
|
||||
return String(ex);
|
||||
};
|
||||
@@ -165,20 +159,21 @@ function go()
|
||||
initStatic();
|
||||
init(bot);
|
||||
if (DEBUG)
|
||||
{
|
||||
/* hook all events EXCEPT server.poll and *.event-end types
|
||||
* (the 4th param inverts the match) */
|
||||
bot.eventPump.addHook ([{type: "poll", set: /^(server|dcc-chat)$/},
|
||||
{type: "event-end"}], event_tracer,
|
||||
"event-tracer", true /* negate */);
|
||||
bot.eventPump.addHook([{type: "poll", set: /^(server|dcc-chat)$/},
|
||||
{type: "event-end"}], event_tracer,
|
||||
"event-tracer", true /* negate */);
|
||||
}
|
||||
|
||||
if (typeof initPersonality == "function")
|
||||
initPersonality();
|
||||
|
||||
|
||||
bot.primNet.connect();
|
||||
rego();
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -188,7 +183,6 @@ function go()
|
||||
*/
|
||||
function rego()
|
||||
{
|
||||
|
||||
/* mainloop */
|
||||
while (bot.eventPump.queue.length > 0)
|
||||
{
|
||||
@@ -203,18 +197,17 @@ function rego()
|
||||
}
|
||||
}
|
||||
}
|
||||
dd ("No events to process.");
|
||||
dd("No events to process.");
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
function addOwner (pattern)
|
||||
function addOwner(pattern)
|
||||
{
|
||||
bot.ownerPatterns.push (pattern);
|
||||
bot.ownerPatterns.push(pattern);
|
||||
}
|
||||
|
||||
function userIsOwner (user)
|
||||
function userIsOwner(user)
|
||||
{
|
||||
if (!user.host)
|
||||
{
|
||||
@@ -223,28 +216,32 @@ function userIsOwner (user)
|
||||
* /whois so we'll know for sure next time.
|
||||
*/
|
||||
if (user.TYPE == "IRCChanUser")
|
||||
user.parent.parent.sendData ("WHOIS " + user.unicodeName + "\n");
|
||||
user.parent.parent.sendData("WHOIS " + user.unicodeName + "\n");
|
||||
else
|
||||
user.parent.sendData ("WHOIS " + user.unicodeName + "\n");
|
||||
user.parent.sendData("WHOIS " + user.unicodeName + "\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
var userString = user.unicodeName + "!" + user.name + "@" + user.host;
|
||||
dd ("userIsOwner: checking userString `" + userString + "' against:");
|
||||
dd("userIsOwner: checking userString `" + userString + "' against:");
|
||||
|
||||
for (var p in bot.ownerPatterns)
|
||||
{
|
||||
if (userString.search(bot.ownerPatterns[p]) != -1)
|
||||
{
|
||||
dd (String(bot.ownerPatterns[p]) + " passed.");
|
||||
dd(String(bot.ownerPatterns[p]) + " passed.");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
dd (String(bot.ownerPatterns[p]) + " fails.");
|
||||
|
||||
{
|
||||
dd(String(bot.ownerPatterns[p]) + " fails.");
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function psn_isAddressedToMe (e)
|
||||
function psn_isAddressedToMe(e)
|
||||
{
|
||||
if (!e.server)
|
||||
return false;
|
||||
@@ -260,12 +257,12 @@ function psn_isAddressedToMe (e)
|
||||
/*
|
||||
dd ("-*- checking to see if message '" + msg + "' is addressed to me.");
|
||||
*/
|
||||
|
||||
var regex = new RegExp ("^\\s*" + e.server.me.unicodeName + "\\W+(.*)", "i");
|
||||
|
||||
var regex = new RegExp("^\\s*" + e.server.me.unicodeName + "\\W+(.*)", "i");
|
||||
var ary = msg.match(regex);
|
||||
|
||||
//dd ("address match: " + ary);
|
||||
|
||||
|
||||
if (ary != null)
|
||||
{
|
||||
e.statement = ary[1];
|
||||
@@ -274,27 +271,24 @@ function psn_isAddressedToMe (e)
|
||||
|
||||
//XXXgijs: Shouldn't this be in mingus.js?
|
||||
bot.personality.dp.addPhrase(msg);
|
||||
return false;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function psn_onAddressedMsg (e)
|
||||
function psn_onAddressedMsg(e)
|
||||
{
|
||||
|
||||
bot.eventPump.onHook (e, bot.personality.hooks);
|
||||
return false;
|
||||
|
||||
bot.eventPump.onHook(e, bot.personality.hooks);
|
||||
return false;
|
||||
}
|
||||
|
||||
bot.personality.addHook =
|
||||
function psn_addhook (pattern, f, name, neg, enabled)
|
||||
function psn_addhook(pattern, f, name, neg, enabled)
|
||||
{
|
||||
if (pattern instanceof RegExp)
|
||||
pattern = {statement: pattern};
|
||||
|
||||
return bot.eventPump.addHook (pattern, f, name, neg, enabled,
|
||||
bot.personality.hooks);
|
||||
|
||||
return bot.eventPump.addHook(pattern, f, name, neg, enabled,
|
||||
bot.personality.hooks);
|
||||
}
|
||||
|
||||
function bot_eval(e, script)
|
||||
@@ -308,22 +302,22 @@ function bot_eval(e, script)
|
||||
e.replyTo.say(e.user.unicodeName + ": " + String(ex));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (typeof (v) != "undefined")
|
||||
{
|
||||
if (v != null)
|
||||
|
||||
if (typeof v != "undefined")
|
||||
{
|
||||
if (v != null)
|
||||
v = String(v);
|
||||
else
|
||||
v = "null";
|
||||
|
||||
|
||||
var rsp = e.user.unicodeName + ", your result is,";
|
||||
|
||||
if (v.indexOf ("\n") != -1)
|
||||
|
||||
if (v.indexOf("\n") != -1)
|
||||
rsp += "\n";
|
||||
else
|
||||
rsp += " ";
|
||||
|
||||
e.replyTo.say (rsp + v);
|
||||
|
||||
e.replyTo.say(rsp + v);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -337,17 +331,18 @@ function bot_eval(e, script)
|
||||
/*
|
||||
* What to do when a privmsg is received on a channel
|
||||
*/
|
||||
function my_chan_privmsg (e)
|
||||
function my_chan_privmsg(e)
|
||||
{
|
||||
var user = e.user;
|
||||
var msg = e.decodeParam(2);
|
||||
if (msg.indexOf(bot.prefix) == 0 && userIsOwner(user))
|
||||
if ((msg.indexOf(bot.prefix) == 0) && userIsOwner(user))
|
||||
{
|
||||
/* if last char is a continuation character, then... */
|
||||
if (msg[msg.length - 1] == '\\') {
|
||||
if (msg[msg.length - 1] == "\\")
|
||||
{
|
||||
user.accumulatedScript = msg.substring(bot.prefix.length,
|
||||
msg.length - 1);
|
||||
return false; // prevent other hooks from processing this...
|
||||
return false; // prevent other hooks from processing this...
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -360,7 +355,7 @@ function my_chan_privmsg (e)
|
||||
/* if we were accumulating a message, add here,
|
||||
* and finish if not ends with '\'. */
|
||||
{
|
||||
var lastLine = (msg[msg.length - 1] != '\\');
|
||||
var lastLine = (msg[msg.length - 1] != "\\");
|
||||
var line = msg.substring(0, msg.length - (lastLine ? 0 : 1));
|
||||
user.accumulatedScript += line;
|
||||
if (lastLine)
|
||||
@@ -375,33 +370,30 @@ function my_chan_privmsg (e)
|
||||
/*
|
||||
* What to do when a dcc chat request reaches a user object
|
||||
*/
|
||||
function my_user_dccchat (e)
|
||||
function my_user_dccchat(e)
|
||||
{
|
||||
|
||||
if (!e.user.canDCC)
|
||||
{
|
||||
e.user.notice ("\01DCC REJECT CHAT chat\01");
|
||||
e.user.notice("\01DCC REJECT CHAT chat\01");
|
||||
return false;
|
||||
}
|
||||
|
||||
var c = new CIRCDCCChat (bot.eventPump);
|
||||
|
||||
if (!c.connect (e.user.host, e.port))
|
||||
|
||||
var c = new CIRCDCCChat(bot.eventPump);
|
||||
|
||||
if (!c.connect(e.user.host, e.port))
|
||||
{
|
||||
e.user.notice ("\01DCC REJECT CHAT chat\01");
|
||||
e.user.notice("\01DCC REJECT CHAT chat\01");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* What to do when our requested nickname is in use
|
||||
*/
|
||||
function my_433 (e)
|
||||
function my_433(e)
|
||||
{
|
||||
|
||||
if (e.params[2] != CIRCNetwork.prototype.INITIAL_NICK)
|
||||
{
|
||||
/* server didn't like the last nick we tried, probably too long.
|
||||
@@ -410,50 +402,46 @@ function my_433 (e)
|
||||
}
|
||||
|
||||
CIRCNetwork.prototype.INITIAL_NICK += "_";
|
||||
e.server.sendData ("nick " + CIRCNetwork.prototype.INITIAL_NICK + "\n");
|
||||
|
||||
e.server.sendData("nick " + CIRCNetwork.prototype.INITIAL_NICK + "\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* What to do when raw data is received on a dcc chat connection
|
||||
*/
|
||||
function my_dccchat_rawdata (e)
|
||||
function my_dccchat_rawdata(e)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
var v = eval(e.data);
|
||||
}
|
||||
catch (ex)
|
||||
{
|
||||
this.say (String(ex));
|
||||
this.say(String(ex));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (typeof (v) != "undefined")
|
||||
{
|
||||
if (v != null)
|
||||
|
||||
if (typeof v != "undefined")
|
||||
{
|
||||
if (v != null)
|
||||
v = String(v);
|
||||
else
|
||||
v = "null";
|
||||
|
||||
this.say (v);
|
||||
this.say(v);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Wrapper around CHTTPDoc to make is simpler to use
|
||||
*/
|
||||
function loadHTTP (host, path, onComplete)
|
||||
function loadHTTP(host, path, onComplete)
|
||||
{
|
||||
var htdoc = new CHTTPDoc (host, path);
|
||||
var htdoc = new CHTTPDoc(host, path);
|
||||
|
||||
htdoc.onComplete = onComplete;
|
||||
htdoc.get (bot.eventPump);
|
||||
htdoc.get(bot.eventPump);
|
||||
|
||||
return htdoc;
|
||||
|
||||
return htdoc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ bot.personality.guessPrefixes = ["I guess ", "maybe ", "probably ", "I think ",
|
||||
bot.personality.guessActionPrefixes = ["guesses ", "postulates ", "figures ",
|
||||
"tries ","pretends ", "", ""];
|
||||
|
||||
function initMingus ()
|
||||
function initMingus()
|
||||
{
|
||||
//XXX You should add the owner(s) of the bot here. You can do so with a
|
||||
// regular expression which matches their hostmask, like so:
|
||||
@@ -50,145 +50,151 @@ function initMingus ()
|
||||
|
||||
bot.primNet = bot.networks["moznet"];
|
||||
|
||||
load ("DP.js");
|
||||
load("DP.js");
|
||||
CIRCNetwork.prototype.INITIAL_NICK = "mingus";
|
||||
CIRCNetwork.prototype.INITIAL_NAME = "mingus";
|
||||
CIRCNetwork.prototype.INITIAL_DESC = "real men do it with prototypes";
|
||||
CIRCNetwork.prototype.INITIAL_CHANNEL = "#chatzilla";
|
||||
|
||||
CIRCChannel.prototype.onJoin =
|
||||
function my_chan_join (e) {
|
||||
function my_chan_join(e)
|
||||
{
|
||||
if (userIsOwner(e.user))
|
||||
e.user.setOp(true);
|
||||
}
|
||||
|
||||
bot.eventPump.addHook (psn_isAddressedToMe, psn_onAddressedMsg,
|
||||
"addressed-to-me-hook");
|
||||
};
|
||||
|
||||
bot.eventPump.addHook(psn_isAddressedToMe, psn_onAddressedMsg,
|
||||
"addressed-to-me-hook");
|
||||
bot.personality.dp = new CDPressMachine();
|
||||
/*
|
||||
bot.personality.dp.addPhrase ("I am " +
|
||||
CIRCNetwork.prototype.INITIAL_NICK +
|
||||
", hear me roar.");
|
||||
*/
|
||||
bot.personality.dp.addPhrase ("\01ACTION is back.");
|
||||
bot.personality.dp.addPhrase("\01ACTION is back.");
|
||||
|
||||
/* dp hooks start */
|
||||
|
||||
var f = function (e)
|
||||
var f = function(e)
|
||||
{
|
||||
var catchall = (e.hooks[e.hooks.length - 1].name == "catchall");
|
||||
var answer = "";
|
||||
|
||||
|
||||
if (catchall)
|
||||
{
|
||||
var ary = e.statement.split(" ");
|
||||
for (var i = 0; i < 3; i++)
|
||||
{
|
||||
answer =
|
||||
bot.personality.dp.getPhraseContaining(getRandomElement(ary));
|
||||
var randomElem = getRandomElement(ary);
|
||||
answer = bot.personality.dp.getPhraseContaining(randomElem);
|
||||
if (answer)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!answer)
|
||||
answer = bot.personality.dp.getPhrase();
|
||||
|
||||
answer = bot.personality.dp.getPhrase();
|
||||
|
||||
if (answer[answer.length - 1] == "\01")
|
||||
{
|
||||
{
|
||||
if (answer[0] != "\01")
|
||||
{
|
||||
if (catchall)
|
||||
answer = "\01ACTION " +
|
||||
getRandomElement(bot.personality.guessActionPrefes) +
|
||||
answer;
|
||||
{
|
||||
var prefes = bot.personality.guessActionPrefes;
|
||||
answer = "\01ACTION " + getRandomElement(prefes) + answer;
|
||||
}
|
||||
else
|
||||
{
|
||||
answer = "\01ACTION " + answer;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!answer)
|
||||
answer = "I don't know anything";
|
||||
answer = "I don't know anything";
|
||||
|
||||
if (catchall)
|
||||
answer = getRandomElement(bot.personality.guessPrefixes) +
|
||||
answer;
|
||||
{
|
||||
answer = getRandomElement(bot.personality.guessPrefixes) +
|
||||
answer;
|
||||
}
|
||||
}
|
||||
|
||||
if (answer[0] != "\01")
|
||||
e.replyTo.say (e.user.unicodeName + ", " + answer);
|
||||
|
||||
if (answer[0] != "\01")
|
||||
e.replyTo.say(e.user.unicodeName + ", " + answer);
|
||||
else
|
||||
e.replyTo.say (answer);
|
||||
e.replyTo.say(answer);
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/* first hook added is last checked */
|
||||
bot.personality.addHook (/.*/i, f, "catchall");
|
||||
bot.personality.addHook (/speak$/i, f, "speak");
|
||||
bot.personality.addHook (/talk$/i, f, "hook");
|
||||
bot.personality.addHook (/say something$/i, f, "say-something");
|
||||
bot.personality.addHook(/.*/i, f, "catchall");
|
||||
bot.personality.addHook(/speak$/i, f, "speak");
|
||||
bot.personality.addHook(/talk$/i, f, "hook");
|
||||
bot.personality.addHook(/say something$/i, f, "say-something");
|
||||
|
||||
f = function (e)
|
||||
f = function(e)
|
||||
{
|
||||
var subject = e.matchresult[1].match(CDPressMachine.WORD_PATTERN);
|
||||
if (subject == null)
|
||||
subject = "";
|
||||
else
|
||||
subject = subject.toString();
|
||||
|
||||
var answer =
|
||||
bot.personality.dp.getPhraseContaining (escape(subject.toLowerCase()));
|
||||
|
||||
var escapedSubject = escape(subject.toLowerCase());
|
||||
var answer = bot.personality.dp.getPhraseContaining(escapedSubject);
|
||||
|
||||
if (!answer)
|
||||
answer = "I don't know anything about " + e.matchresult[1];
|
||||
|
||||
if (answer.charCodeAt (0) != 1)
|
||||
e.replyTo.say (e.user.unicodeName + ", " + answer);
|
||||
if (answer.charCodeAt(0) != 1)
|
||||
e.replyTo.say(e.user.unicodeName + ", " + answer);
|
||||
else
|
||||
e.replyTo.say (answer);
|
||||
e.replyTo.say(answer);
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
}
|
||||
bot.personality.addHook(/speak about (\S+)/i, f);
|
||||
bot.personality.addHook(/talk about (\S+)/i, f);
|
||||
bot.personality.addHook(/say something about (\S+)/i, f);
|
||||
|
||||
bot.personality.addHook (/speak about (\S+)/i, f);
|
||||
bot.personality.addHook (/talk about (\S+)/i, f);
|
||||
bot.personality.addHook (/say something about (\S+)/i, f);
|
||||
|
||||
f = function (e)
|
||||
f = function(e)
|
||||
{
|
||||
var answer = bot.personality.dp.getPhraseContaining ("%01ACTION");
|
||||
var answer = bot.personality.dp.getPhraseContaining("%01ACTION");
|
||||
|
||||
if (!answer)
|
||||
answer = "I can't do a thing.";
|
||||
|
||||
e.replyTo.say (answer);
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
bot.personality.addHook (/do something/i, f);
|
||||
e.replyTo.say(answer);
|
||||
|
||||
f = function (e)
|
||||
return false;
|
||||
};
|
||||
|
||||
bot.personality.addHook(/do something/i, f);
|
||||
|
||||
f = function(e)
|
||||
{
|
||||
var ary = bot.personality.dp.getPhraseWeights (e.matchresult[1]);
|
||||
var c = bot.personality.dp.getPhraseWeight (e.matchresult[1]);
|
||||
var ary = bot.personality.dp.getPhraseWeights(e.matchresult[1]);
|
||||
var c = bot.personality.dp.getPhraseWeight(e.matchresult[1]);
|
||||
|
||||
e.replyTo.say (e.user.unicodeName + ", that phrase weighs " + c + ": " + ary);
|
||||
e.replyTo.say(e.user.unicodeName + ", that phrase weighs " +
|
||||
c + ": " + ary);
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
}
|
||||
bot.personality.addHook(/weigh (.+)/i, f);
|
||||
|
||||
bot.personality.addHook (/weigh (.+)/i, f);
|
||||
|
||||
f = function (e)
|
||||
f = function(e)
|
||||
{
|
||||
var word = e.matchresult[1].toLowerCase();
|
||||
var pivot = bot.personality.dp.getPivot(word);
|
||||
var result = "";
|
||||
|
||||
|
||||
if (pivot)
|
||||
{
|
||||
var list, w, l;
|
||||
@@ -199,16 +205,16 @@ function initMingus ()
|
||||
l = list.getListLinks();
|
||||
|
||||
if (w.length != l.length)
|
||||
e.replyTo.say ("warning: previous list mismatched.");
|
||||
e.replyTo.say("warning: previous list mismatched.");
|
||||
|
||||
for (var i = 0; i < (Math.max(w.length, l.length)); i++)
|
||||
result += ( "`" + l[i] + "'" + w[i] + " " );
|
||||
for (var i = 0; i < Math.max(w.length, l.length); i++)
|
||||
result += ("`" + l[i] + "'" + w[i] + " ");
|
||||
|
||||
if (result.length > 250)
|
||||
result += "\n";
|
||||
result += "\n";
|
||||
|
||||
result += ( "[" + word + "]" );
|
||||
|
||||
|
||||
if (result.length > 250)
|
||||
result += "\n";
|
||||
|
||||
@@ -218,175 +224,172 @@ function initMingus ()
|
||||
l = list.getListLinks();
|
||||
|
||||
if (w.length != l.length)
|
||||
e.replyTo.say ("warning: next list mismatched.");
|
||||
e.replyTo.say("warning: next list mismatched.");
|
||||
|
||||
for (var i = 0; i < (Math.max(w.length, l.length)); i++)
|
||||
result += ( " `" + l[i] + "'" + w[i] );
|
||||
|
||||
for (var i = 0; i < Math.max(w.length, l.length); i++)
|
||||
result += (" `" + l[i] + "'" + w[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = "- [" + word + "] -";
|
||||
}
|
||||
|
||||
e.replyTo.say (result);
|
||||
e.replyTo.say(result);
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
bot.personality.addHook(/pivot (.*)/i, f);
|
||||
|
||||
/* dp hooks end */
|
||||
|
||||
f = function (e)
|
||||
f = function(e)
|
||||
{
|
||||
print ("I can hear you.");
|
||||
e.replyTo.say (e.user.unicodeName + ", yes, I am.");
|
||||
print("I can hear you.");
|
||||
e.replyTo.say(e.user.unicodeName + ", yes, I am.");
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
bot.personality.addHook (/are you alive(\?)?/i, f);
|
||||
bot.personality.addHook(/are you alive(\?)?/i, f);
|
||||
|
||||
|
||||
f = function (e)
|
||||
f = function(e)
|
||||
{
|
||||
if (!userIsOwner(e.user))
|
||||
{
|
||||
e.replyTo.say ("nope.");
|
||||
e.replyTo.say("nope.");
|
||||
return;
|
||||
}
|
||||
|
||||
chan = e.matchresult[1];
|
||||
|
||||
if (chan.charAt (0) != "#")
|
||||
if (chan.charAt(0) != "#")
|
||||
chan = "#" + chan;
|
||||
|
||||
e.server.sendData ("join " + chan + "\n");
|
||||
e.server.sendData("join " + chan + "\n");
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
}
|
||||
bot.personality.addHook(/join\s+(\S+)\.*/i, f);
|
||||
|
||||
bot.personality.addHook (/join\s+(\S+)\.*/i, f);
|
||||
|
||||
f = function (e)
|
||||
f = function(e)
|
||||
{
|
||||
if (!userIsOwner (e.user))
|
||||
if (!userIsOwner(e.user))
|
||||
{
|
||||
e.channel.say ("nope.");
|
||||
e.channel.say("nope.");
|
||||
return false;
|
||||
}
|
||||
|
||||
chan = e.matchresult[1];
|
||||
|
||||
if (chan.charAt (0) != "#")
|
||||
if (chan.charAt(0) != "#")
|
||||
chan = "#" + chan;
|
||||
|
||||
e.server.sendData ("part " + chan + "\n");
|
||||
e.server.sendData("part " + chan + "\n");
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
bot.personality.addHook (/part\s+(\S+)\.*/i, f);
|
||||
bot.personality.addHook (/leave\s+(\S+)\.*/i, f);
|
||||
bot.personality.addHook(/part\s+(\S+)\.*/i, f);
|
||||
bot.personality.addHook(/leave\s+(\S+)\.*/i, f);
|
||||
|
||||
f = function (e)
|
||||
{
|
||||
e.replyTo.say ("mmmmmmm. Thanks " + e.user.unicodeName + ".");
|
||||
e.replyTo.say("mmmmmmm. Thanks " + e.user.unicodeName + ".");
|
||||
return false;
|
||||
};
|
||||
|
||||
}
|
||||
bot.personality.addHook(/botsnack/i, f);
|
||||
|
||||
bot.personality.addHook (/botsnack/i, f);
|
||||
|
||||
f = function (e)
|
||||
f = function(e)
|
||||
{
|
||||
e.replyTo.act ("blushes");
|
||||
e.replyTo.act("blushes");
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
bot.personality.addHook (/you rock/i, f);
|
||||
bot.personality.addHook(/you rock/i, f);
|
||||
|
||||
f = function (e)
|
||||
f = function(e)
|
||||
{
|
||||
if (e.matchresult[1] == "me")
|
||||
e.replyTo.act ("hugs " + e.user.unicodeName);
|
||||
e.replyTo.act("hugs " + e.user.unicodeName);
|
||||
else
|
||||
e.replyTo.act ("hugs " + e.matchresult[1]);
|
||||
e.replyTo.act("hugs " + e.matchresult[1]);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
bot.personality.addHook (/hug (.*)/i, f);
|
||||
bot.personality.addHook(/hug (.*)/i, f);
|
||||
|
||||
f = function (e)
|
||||
f = function(e)
|
||||
{
|
||||
if (e.matchresult[1] == "me")
|
||||
e.replyTo.say (e.user.unicodeName + ", :*");
|
||||
e.replyTo.say(e.user.unicodeName + ", :*");
|
||||
else
|
||||
e.replyTo.say (e.matchresult[1] + ", :*");
|
||||
e.replyTo.say(e.matchresult[1] + ", :*");
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
bot.personality.addHook (/kiss (\w+)/, f);
|
||||
bot.personality.addHook(/kiss (\w+)/, f);
|
||||
|
||||
f = function (e)
|
||||
{
|
||||
e.replyTo.say (e.user.unicodeName + ", I'll try :(");
|
||||
e.replyTo.say(e.user.unicodeName + ", I'll try :(");
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
bot.personality.addHook
|
||||
(/(shut up)|(shaddup)|(be quiet)|(keep quiet)|(sssh)|(stfu)/i, f);
|
||||
|
||||
f = function (e)
|
||||
f = function(e)
|
||||
{
|
||||
if (!userIsOwner (e.user))
|
||||
e.replyTo.say ("No.");
|
||||
if (!userIsOwner(e.user))
|
||||
{
|
||||
e.replyTo.say("No.");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (var n in bot.networks)
|
||||
bot.networks[n].quit("Goodnight.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
bot.personality.addHook (/(go to bed)|(go to sleep)|(sleep)/i, f);
|
||||
bot.personality.addHook(/(go to bed)|(go to sleep)|(sleep)/i, f);
|
||||
|
||||
f = function (e)
|
||||
f = function(e)
|
||||
{
|
||||
e.replyTo.say (":)");
|
||||
e.replyTo.say(":)");
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
bot.personality.addHook
|
||||
(/(smile)|(rotfl)|(lmao)|(rotflmao)|(look happy)|(you(.)?re smart)/i, f);
|
||||
(/(smile)|(rotfl)|(lmao)|(rotflmao)|(look happy)|(you(.)?re smart)/i, f);
|
||||
/* (/(smile)|(rotfl)|(lmao)|(rotflmao)|(you(.)?re funny)|(look happy)|(you(.)?re smart)/i, f); */
|
||||
|
||||
f = function (e)
|
||||
f = function(e)
|
||||
{
|
||||
e.replyTo.say (":(");
|
||||
e.replyTo.say(":(");
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
bot.personality.addHook (/(frown)|(don(.)?t like you)|(look sad)/i, f);
|
||||
bot.personality.addHook(/(frown)|(don(.)?t like you)|(look sad)/i, f);
|
||||
|
||||
f = function (e)
|
||||
f = function(e)
|
||||
{
|
||||
e.replyTo.say (">:|");
|
||||
e.replyTo.say(">:|");
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
bot.personality.addHook (/(look mad)|(beat you up)/i, f);
|
||||
bot.personality.addHook(/(look mad)|(beat you up)/i, f);
|
||||
|
||||
f = function (e)
|
||||
f = function(e)
|
||||
{
|
||||
e.replyTo.say (":/");
|
||||
e.replyTo.say(":/");
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
bot.personality.addHook (/(look confused)|(i like windows)/i, f);
|
||||
|
||||
bot.personality.addHook(/(look confused)|(i like windows)/i, f);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user