08-27-2018, 06:05 AM
What is she? Technically she's an IRC bot, but conceptually she's a 4'7" neko-vampire half-pint of terror!
The codes:
As you can see, she doesn't do too much right now. I'm not going to provide constant updates of her code here, this is just the first initial beta code of her to test functionality. Some debug code is in there. :P Should be fun!
The codes:
Content Hidden
Code:
console.log("sinBot starting up...");
// IRC Configuration
var config = {
server: "irc.chatspike.net",
botName: "sinBot",
userName: "sinBot",
realName: "sinBot IRC Bot v0.0.1",
port: 6667,
autoRejoin: true,
autoConnect: true,
channels: ['#save-point'],
secure: false,
selfSigned: false,
certExpired: false,
floodProtection: true,
floodProtectionDelay: 1000,
stripColors: true
};
// IRC library
var irc = require("irc");
// Create bot name
var bot = new irc.Client(config.server, config.botName, {
userName: config.userName,
realName: config.realName,
port: config.port,
autoRejoin: config.autoRejoin,
autoConnect: config.autoConnect,
channels: config.channels,
secure: config.secure,
selfSigned: config.selfSigned,
certExpired: config.certExpired,
floodProtection: config.floodProtection,
floodProtectionDelay: config.floodProtectionDelay,
stripColors: config.stripColors,
debug: true
});
blackList = [];
hasVoice = [];
hasHelper = [];
botInfo = {};
admin = [];
var isMe = function(nick) {
return (nick === config.botName);
};
var isAdmin = function(host) {
return (admin.includes(host));
};
var canSpeak = function(channel) {
return (hasVoice.includes(channel));
};
var canVoice = function(channel) {
return (hasHelper.includes(channel));
};
var speak = function(channel, message) {
if (canSpeak(channel)) {
bot.say(channel, message);
}
};
var action = function(channel, message) {
if (canSpeak(channel)) {
bot.action(channel, message)
}
};
var voice = function(channel, nick) {
if (canVoice(channel)) {
bot.send('MODE', channel, '+v', nick);
}
};
bot.addListener('raw', function(message) {
if (message['command'] === 'ERROR') {
console.log(message['args']);
console.log(config.botName + ' exiting.');
bot.disconnect();
}
});
bot.addListener('registered', function(message) {
console.log('sinBot is connected!');
botInfo['server'] = message['server'];
});
bot.addListener('message', function(nick, to, text, message) {
if (isAdmin(message['host']) && ! isMe(nick)) {
// todo
console.log(message);
console.log(text);
}
});
bot.addListener('action', function (nick, to, text, message) {
text = text.trim();
params = text.split(" ",2);
console.log('params')
// if (params[1] === 'hugs' && params[2] === config.botName) {
// if (isAdmin(message['host'])) {
// action(to, 'squeezes ' + nick + ' tightly!');
// speak(to, 'Sempai noticed me! ٩(♡ε♡ )۶');
// } else {
// action(to, 'hugs ' + nick + ' back');
// }
// }
if (text === 'hugs sinBot') {
if (isAdmin(message['host'])) {
action(to, 'squeezes ' + nick + ' tightly!');
speak(to, 'Sempai noticed me! ٩(♡ε♡ )۶');
} else {
action(to, 'hugs ' + nick + ' back');
}
}
});
bot.addListener("join", function(channel, who, message) {
if (isMe(who)) {
console.log("I have joined " + channel + "!");
botInfo['host'] = message['host'];
} else {
console.log(who + ' joined ' + channel + '.');
if (isAdmin(message['host'])) {
speak(channel, "Welcome back, " + who + "-sempai!");
} else {
speak(channel, "Welcome back, " + who);
}
if (! blackList.includes(who) && ! isMe(who)) {
console.log("Gave voice to " + who + " on " + channel + "!");
speak(channel, 'You seem nice, nyaa~');
speak(channel, 'With the power of love, I grant you speech ' + who + '-nyan!');
// MODE #save-point +v sinBot
voice(channel, who);
} else {
console.log(who + ' is on my naughty list! Bad-nyaa~');
speak(channel, "Senpai says that you've been bad, " + who + "!");
speak(channel, "I can't give you voice until he says it's okay again, nyan~~ TT__TT");
}
}
});
bot.addListener('+mode', function(channel, by, mode, argument, message) {
if (isMe(argument)) {
if (mode === 'v') {
console.log(by + ' gave me voice in ' + channel + '! ^_^');
hasVoice.push(channel);
if (isAdmin(message['host'])) {
speak(channel, "Thank you, sempai!");
}
}
if (mode === 'h') {
console.log(by + ' said I can help in ' + channel + '! ^_^');
hasHelper.push(channel);
if (isAdmin(message['host'])) {
speak(channel, "I will do my very best, sempai!")
}
}
}
});
bot.addListener('-mode', function(channel, by, mode, argument, message) {
if (isMe(argument)) {
if (mode === 'v') {
console.log('Help, ' + by + ' took away my voice in ' + channel + '! ;_;');
hasVoice.splice(hasVoice.indexOf(channel), 1);
}
if (mode === 'h') {
console.log('Help, ' + by + "won't let me help in " + channel + ' anymore! ;_;');
hasHelper.splice(hasHelper.indexOf(channel), 1);
}
}
});
bot.addListener("invite", function(channel, from, message) {
console.log("Recieved an invite from " + from + " to join " + channel + '.');
console.log("It sounds like so much fun!");
bot.say(from, "I can't join that channel!");
bot.say(from, "Senpai says this is not allowed!");
bot.say(from, "I'm still beta ^_~");
});
bot.addListener("ctcp-version", function(from, to, message) {
console.log("Version information requested by " + from + '.');
bot.say(from, "sinBot v0.0.1-beta");
});
As you can see, she doesn't do too much right now. I'm not going to provide constant updates of her code here, this is just the first initial beta code of her to test functionality. Some debug code is in there. :P Should be fun!