robotirc

Multifonction IRC bot written in Node.js
Log | Files | Refs | README | LICENSE

commit 70fb7f17aabb23602a955454d69e77cd1dfb193d
parent 65dfba0b01b7ae885937254d82be33d00dd07de6
Author: Frederic Cambus <fcambus@users.sourceforge.net>
Date:   Thu,  2 Jan 2014 23:39:47 +0100

Adding a command to get Alexa traffic rank

Diffstat:
Mlib/robotirc.js | 14+++++++++++++-
Mpackage.json | 3++-
2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/lib/robotirc.js b/lib/robotirc.js @@ -11,14 +11,15 @@ /* */ /*****************************************************************************/ +var crypto = require('crypto'); var dns = require('dns'); var net = require('net'); -var crypto = require('crypto'); /**[ NPM Modules ]************************************************************/ +var alexa = require('alexarank'); var irc = require('irc'); var request = require('request'); @@ -49,6 +50,7 @@ client.addListener('message', function(from, to, message) { if (message.match(/^!help/)) { var help = "RobotIRC 0.1.0 supports the following commands :\n" + + "!alexa => Get Alexa traffic rank for a domain or URL\n" + "!date => Display server local time\n" + "!expand => Expand a shortened URL\n" + "!geoip => IP address Geolocation\n" + @@ -60,6 +62,16 @@ client.addListener('message', function(from, to, message) { client.say(to, help); } + /*************************************************************[ !alexa ]**/ + + if (message.match(/^!alexa/)) { + alexa(params, function(error, result) { + if (!error && typeof result.rank != "undefined") { + client.say(to, "Alexa Traffic Rank for " + result.idn.slice(0, -1) + " : " + result.rank); + } + }); + } + /**************************************************************[ !date ]**/ if (message.match(/^!date/)) { diff --git a/package.json b/package.json @@ -28,6 +28,7 @@ }, "dependencies": { "irc": "~0.3.6", - "request": "~2.30.0" + "request": "~2.30.0", + "alexarank": "~0.1.0" } }