Advertisement
metalx1000

Basic Node IRC bot

Mar 7th, 2015
767
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //npm install irc
  2. // Create the configuration
  3. var config = {
  4.   channels: ["#filmsbykris"],
  5.   server: "irc.freenode.net",
  6.   botName: "megabot"
  7. };
  8.  
  9. // Get the lib
  10. var irc = require("irc");
  11.  
  12. // Create the bot name
  13. var bot = new irc.Client(config.server, config.botName, {
  14.   channels: config.channels
  15. });
  16.  
  17. // Listen for joins
  18. bot.addListener("join", function(channel, who) {
  19.   // Welcome them in!
  20.   bot.say(channel, who + ", my circuits welcome you!");
  21. });
  22.  
  23. // Listen for any message, say to him/her in the room
  24. bot.addListener("message", function(from, to, text, message) {
  25.   var msg=text.toLowerCase();
  26.   if(msg.indexOf("megacool")>=0){
  27.     bot.say(config.channels[0], "Heck yeah I am!");
  28.   }
  29.  
  30.   if(msg.indexOf("linux sucks")>=0){
  31.     bot.say(config.channels[0], "You SUCK, " + from);
  32.   }
  33.  
  34. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement