Giter Site home page Giter Site logo

node-irc-bot's Introduction

IRC bot made with NodeJS

Hacked this thing together just for the fun of it. Built on top of Node-IRC-module.

Features

  • Send commands to the bot with !-prefix (e.g. !google NodeJS)
  • Attach observers that react to certain situations (such as specific keywords in conversations etc)
  • Add new functionality (commands and observers) on the fly without rebooting the bot!
  • Bot can have 1 or many admins
  • Auto-op bot admin(s). Requires the bot to have +o of course.
  • Auto-op users defined in ./autoop.json. WARNING: Auto-op is nick based so use cautiously (if at all)!
  • Optional per channel greetings for newly joined user defined in ./greetings.json
  • Admin can send basic IRC commands like /mode, /join, /part and make the bot say things

Core commands

  • !help - prints list of available commands
  • !reload - Reloads commands, observeres, greeting lists and auto-op lists (admin only)
  • !quit - (admin only)

IRC commands

Admin only.

The usage of the bot mostly requires the admin to be on the same IRC channel as the bot. Commands work mostly the same way as their "native" IRC counterparts, meaning !command matches the IRC /command... mostly :)

  • !join <channel> or !join <channel> <password> if it has one
  • !part if on a channel or !part <channel> if called elsewhere
  • !say <something> if on a channel or !say <channel> <something> if called elsewhere
  • !ban <someone>
  • !unban <someone>
  • !kick <someone>
  • !op <someone>
  • !deop <someone>
  • !mode <command> or !mode <command> <nick>

Configurable/Example commands

Found in ./commands-folder.

  • !google - returns links to top 3 google results
  • !wiki - returns links to top 3 wikipedia results
  • !so - returns links to top 3 stackoverflow results

(message) Observers

These are the fun things!

  • URL title resolver: When an (http/https) URL is pasted into a channel, the bot will fetch the URL and display the page title (great for youtube links especially)
  • Jallu wisdom: When someone mentions "jallu", the great liquor from Finland, also known as "cut brandy" the bot will make a wise remark!

Install

  1. git clone https://github.com/aripalo/node-irc-bot.git
  2. node-irc-bot
  3. npm install
  4. cp example-configurations/example-config.json config-json
  5. Edit the config-json
  6. node index.js

Adding functionality

Commands

  1. Add functionality wrapped into CommonJS module.exports funcion into JavaScript-file and place it to ./commands-folder
  2. Important: The filename will be the command, e.g. foo.js will become command !foo
  3. Run !reload-command on as a bot admin
  4. Profit...?

Observers

... basically the same process as with commands, but observers aren't activated by !command, but instead they're meant for monitoring conversation and act on them.

TODO

  • Features
    • Add "spam-protection", basically a timeout for non-bot-admin users
    • Error messages to IRC commands: such as "missing argument etc"
  • Docs/Examples
    • Improve docs
    • Add another observer example
  • Refactor
    • !google, !so and !wiki-commands share quite much logic, maybe refactor that logic into separate module etc?
    • Refactor the commandHandler module
    • There's quite many synchronous functions in the code, consider refactoring to asynchronous
    • After everything's cleaned up and so, consider bundling as npm module
    • Unit tests?

node-irc-bot's People

Contributors

aripalo avatar cbcercas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

node-irc-bot's Issues

URL listener parses line breaks

https://twitter.com/J_Weech/status/598180597966741504

If you paste this the channel which the bot is on it starts to manually type it out

<BOT> James Weech su Twitter: "Testing
<BOT> line
<BOT> breaks
* ANTIFLOOD.SOMETHING.EXAMPLE.COM has kicked BOT from #BotTestingLab (Channel flood triggered (limit is 4 lines in 2 secs))
* BOT () has joined

we have the antiflood in place at the moment to stop the bot going ape but it would be nice if this could be fixed

Thank you

bot admins

I set up myself as the bot admin, using 'nick!username@vhost' have also tried using a wild card (*) and still unable to have it recognize me as its admin

google search

Hi there

Whenever someone triggers !google and adds 4 spaces... the bot will just crash and quits without any message

[05:42:12 PM] @g
[05:42:13 PM] * sparkz ([email protected]) has quit IRC (Client exited)

Is there a way to fix this?

regards

Demo

Log which users request which URL from observer

I have this joined on a medium size IRC,

Sadly once in a while people flood this IRC with unwanted URLs which the bot which goes off and fetches the title too (You can see where i'm getting to here)

Sadly in the case of the law unless I can prove otherwise it would be assumed that I requested these potentially illegial URLs trolls keep on pasting in the chat, It would be ideal to have a log file which outputs in the format of username & domain name requested (with maybe an option in the config to turn it off for privacy?)

Thank you very much for your help

URL listener - Issue if file

If I paste in a file URL: (e.g http://i.imgur.com/yiNa01J.jpg ) in the chat i get

/home/ircbot/node-irc-bot/node_modules/irc/lib/irc.js:748 throw err; ^ SyntaxError: Invalid regular expression: /(https?:\/\/[^\s]+/: Unterminated group at new RegExp (<anonymous>) at urlify (/home/ircbot/node-irc-bot/observers/url.js:19:5) at module.exports (/home/ircbot/node-irc-bot/observers/url.js:49:15) at /home/ircbot/node-irc-bot/modules/observer-handler.js:17:51 at Array.forEach (native) at module.exports (/home/ircbot/node-irc-bot/modules/observer-handler.js:16:36) at Client.<anonymous> (/home/ircbot/node-irc-bot/index.js:47:3) at Client.EventEmitter.emit (events.js:106:17) at Client.<anonymous> (/home/ircbot/node-irc-bot/node_modules/irc/lib/irc.js:517:22) at Client.EventEmitter.emit (events.js:95:17)

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.