Giter VIP home page Giter VIP logo

icarus-bot's Introduction

##ICARUS BOT Icarus

This is a very simple IRC bot that I built from scratch because I wanted to learn about RFC 2813

##Creating a bot:

  • npm install icarusbot

  • npm install any plugins you want.

  • Copy node_modules/icarusbot/config.dist.json to node_modules/icarusbot/config.json TODO: Fix that, updates break config.

  • Fill out all the stuff in config.json

  • Write a bot consumer:

    var bot = require('icarusbot')
    var pluginFoo = require('icarubot-plugin-foo')(bot)
    var pluginBar = require('icarubot-plugin-bar')(bot)
  • Run your bot node whatever-you-name-your-bot.js

##Creating a plugin: The bot currently emits various events that you can listen to, most notably the msg event.

Here is a simple plugin:

module.exports = function(bot) {
  bot.on('msg',function(msg) {
    console.log(msg) // {sender: 'a_nick', chan: '##foo', msg: 'foo bar baz'}

    // bot.msg() supports writing messages in a sane way.
    if (msg.msg === 'wow') {
      bot.msg(['#channel1', '#channel2'], 'mom')
    }
  })
}

#Current plugins (PR to add yours!):

  • icarusbot-lysergix:

    • Adds a handler for a !face message that posts a random face from lysergix-api
  • icarusbot-reddit:

  • Adds a !r command that accepts a subreddit and optionally an nth latest post and returns the title and link of the post.

  • icarusbot-twitter:

  • Adds !tw command with various subcommands to interact with twitter.

  • icarusbot-coinflip:

  • Adds a !flip command for when you just can't make up your mind.

icarus-bot's People

Contributors

kid-icarus avatar void-- avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

davr sagax

icarus-bot's Issues

API Suggestions

My suggestion is to have this be a module that is consumed rather than run separately.

This will make a plugin api significantly easier to use, e.g. the consumer would write a small piece of code like so:

brycebot.js

var bot = require("icarus-bot")("./path/to/config.json")

// bot returns an objectMode Duplex stream interface

// That way the modules could be Transform streams that do something
//    and then (maybe) provide a message to send back to IRC
bot.pipe(require("icarus-bot-faces")()).pipe(bot)
bot.pipe(require("icarus-bot-twitter")()).pipe(bot)

// or the module could simply be an endpoint (Writable stream)
//    and not say stuffs back to IRC
bot.pipe(require("icarus-bot-some-other-cool-stuffs")())

The modules would then simply be Transform or Writable objectMode streams which take some sort of format that this provides e.g. {message: "lol wut m8?", user: "kid_icarus", ...}

Which that stream module could then look at the message to decide if something should be done. It could then save it to a log, send a tweet, etc and stop there, or if it sends something back (format tbd) to the bot, the bot could send it out over IRC.

In terms of using prototype vs functional-style for the most part do what makes sense to you. If you find you need to eventually do some inheritance it won't be hard to convert it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.