Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var irc = require("irc");
- // Create the configuration
- var config = {
- channels: ["#CWI.Network"],
- server: "irc.freenode.net",
- botName: "cwibot",
- password: "&PASSWORD&"
- };
- var recentLotto = [];
- var oneHour = 60000 * 60;
- // Create the bot name
- var bot = new irc.Client(config.server, config.botName, {
- channels: config.channels,
- autoConnect: true
- });
- // Listen for joins
- bot.addListener("join", function(channel, who) {
- // Welcome them in!
- bot.say(channel, who + " Coming Soon -- This will give small amounts of crypto onjoin if authed with nickserv");
- });
- // Add user to recentLotto array, wait one hour, then remove from recentLotto array.
- function userLotto(from, to) {
- recentLotto.push({channel: to, user: from});
- setTimeout(function() {
- recentLotto.splice(recentLotto.indexOf({channel: to, user: from}, 0), 1);
- }, oneHour);
- }
- bot.addListener("notice", function (nick, to, text, message) {
- console.log(nick + ": " + text);
- });
- bot.addListener("message", function(from, to, text, message) {
- console.log(to + " - " + from + ": " + text);
- if(from != config.botName || from != "Tip-A-Bean") {
- if(text === "!lotto") {
- console.log(recentLotto);
- if (recentLotto.indexOf({channel: to, user: from}, 0) > -1) {
- bot.say(to, "You must wait one hour after your last lotto to lotto again.");
- } else {
- bot.say(config.channels[0], "!tip " + from + " 10");
- userLotto(from, to);
- }
- }
- if(text === "!register") {
- bot.say("nickserv", "identify cwibot " + config.password);
- }
- }
- });
- // Say !rain X every hour
- setInterval(function() {
- bot.say(config.channels[0], "!rain X");
- }, oneHour);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement