Advertisement
Z90-1

Untitled

Mar 12th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. var irc = require("irc");
  2.  
  3. // Create the configuration
  4. var config = {
  5. channels: ["#CWI.Network"],
  6. server: "irc.freenode.net",
  7. botName: "cwibot",
  8. password: "&PASSWORD&"
  9. };
  10.  
  11. var recentLotto = [];
  12. var oneHour = 60000 * 60;
  13.  
  14. // Create the bot name
  15. var bot = new irc.Client(config.server, config.botName, {
  16. channels: config.channels,
  17. autoConnect: true
  18. });
  19.  
  20.  
  21. // Listen for joins
  22. bot.addListener("join", function(channel, who) {
  23. // Welcome them in!
  24. bot.say(channel, who + " Coming Soon -- This will give small amounts of crypto onjoin if authed with nickserv");
  25. });
  26.  
  27. // Add user to recentLotto array, wait one hour, then remove from recentLotto array.
  28. function userLotto(from, to) {
  29. recentLotto.push({channel: to, user: from});
  30. setTimeout(function() {
  31. recentLotto.splice(recentLotto.indexOf({channel: to, user: from}, 0), 1);
  32. }, oneHour);
  33. }
  34. bot.addListener("notice", function (nick, to, text, message) {
  35. console.log(nick + ": " + text);
  36. });
  37.  
  38. bot.addListener("message", function(from, to, text, message) {
  39. console.log(to + " - " + from + ": " + text);
  40. if(from != config.botName || from != "Tip-A-Bean") {
  41. if(text === "!lotto") {
  42. console.log(recentLotto);
  43. if (recentLotto.indexOf({channel: to, user: from}, 0) > -1) {
  44. bot.say(to, "You must wait one hour after your last lotto to lotto again.");
  45. } else {
  46. bot.say(config.channels[0], "!tip " + from + " 10");
  47. userLotto(from, to);
  48. }
  49.  
  50. }
  51. if(text === "!register") {
  52. bot.say("nickserv", "identify cwibot " + config.password);
  53. }
  54. }
  55. });
  56.  
  57. // Say !rain X every hour
  58. setInterval(function() {
  59. bot.say(config.channels[0], "!rain X");
  60. }, oneHour);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement