var lines = [];
function event::onLoad () {
loadDB ();
return;
}
function loadDB () {
var file = openFile ('hotentry_db.txt');
if (file) {
var s;
var i = 0;
while (s = file.readLine()) {
lines[i] = s;
i++;
}
file.close ();
}
return;
}
function checkDB (str) {
var i;
for (i = 0 ; i < lines.length ; i++) {
if ( str == lines[i] ) {
return 1;
}
}
return 0;
}
function sendMsg (channel, str) {
send (channel, " ∧ ∧ /");
send (channel, "~′ ̄§( 'Д')< " + str);
send (channel, " UU ̄ ̄ U U \");
return;
}
function sendMsgN (channel, str) {
send (channel, " ,.-―――、 ");
send (channel, " ヽ / ̄ ̄ ̄ヽ ");
send (channel, " ||■■■■ ");
send (channel, " ||@_,-- _> < " + str + " の巻");
send (channel, " ヽヽ ____ノ ");
return;
}
function event::onChannelText (prefix, channel, text) {
var str = text;
var str2, q, q2;
if (str.match(/^ねこ(\s| )+/)) {
q = RegExp.rightContext;
if (q.match(/^add(\s| )+/)) {
q2 = RegExp.rightContext;
q2 = q2.replace (/(\s| )+$/, "");
if(q2.match(/*/)) {
if (0 == checkDB (q2)) {
var file = openFile ('hotentry_db.txt', false);
if (file) {
file.seekToEnd ();
file.writeLine (q2);
file.close ();
loadDB ();
sendMsg (channel, "『 " + q2 + " 』を" + lines.length + "番目に追加しました");
}
}
else {
sendMsg (channel, "ERROR: 既に登録されてます");
}
}
else {
sendMsg (channel, "ERROR: 文中に『*』が含まれてません");
}
}
else {
var n = Math.floor (Math.random () * lines.length);
str2 = lines[n];
if (q.length > 0) {
q = q.replace (/(\s| )+$/, "");
if ("にんにん" == q) {
sendMsgN (channel, str2.replace(/*/g, prefix.nick + "さん"));
}
else {
sendMsg (channel, str2.replace(/*/g, q));
}
}
else {
sendMsg (channel, str2.replace(/*/g, prefix.nick + "さん"));
}
}
}
else if ("ねこ" == str) {
var n = Math.floor (Math.random () * lines.length);
str2 = lines[n];
sendMsg (channel, str2.replace(/*/g, prefix.nick + "さん"));
}
else {
;
}
return;
}