Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 14 commits
  • 16 files changed
  • 0 commit comments
  • 5 contributors
3  .jshintrc
View
@@ -0,0 +1,3 @@
+{
+ "asi": true
+}
10 .travis.yml
View
@@ -0,0 +1,10 @@
+language: python
+python:
+ - "2.7"
+install:
+ - pip install flake8 --use-mirrors
+ - sudo apt-get install nodejs
+ - sudo npm install -g jshint
+script:
+ - flake8 .
+ - jshint *.js{,on.dist} services/*.js{,on.dist}
3  AUTHORS.rst
View
@@ -9,6 +9,9 @@ Contributors:
-------------
- Eric Holscher
- Don Park
+- Felipe Delgado
+- Josh Yaganeh
+- Aaron Parecki
Special Thanks
--------------
43 bot.js
View
@@ -2,9 +2,9 @@ var irc = require('irc');
var api = require('./services/lib/api');
var opts = require('nomnom')
.option('config', {
- abbr: 'c',
- default: 'bot.json',
- help: 'config file to use'
+ 'abbr': 'c',
+ 'default': 'bot.json',
+ 'help': 'config file to use'
}).parse()
zenircbot = {
@@ -36,8 +36,8 @@ zenircbot = {
data: {
sender: nick,
channel: to,
- message: text.replace(/^ACTION /, ''),
- },
+ message: text.replace(/^ACTION /, '')
+ }
};
zenircbot.pub.publish('in', JSON.stringify(msg));
});
@@ -53,8 +53,8 @@ zenircbot = {
data: {
sender: nick,
channel: to,
- message: text,
- },
+ message: text
+ }
};
zenircbot.pub.publish('in', JSON.stringify(msg));
});
@@ -74,8 +74,8 @@ zenircbot = {
type: 'join',
data: {
sender: nick,
- channel: channel,
- },
+ channel: channel
+ }
};
zenircbot.pub.publish('in', JSON.stringify(msg));
});
@@ -87,8 +87,8 @@ zenircbot = {
type: 'part',
data: {
sender: nick,
- channel: channel,
- },
+ channel: channel
+ }
};
zenircbot.pub.publish('in', JSON.stringify(msg));
});
@@ -99,8 +99,22 @@ zenircbot = {
version: 1,
type: 'quit',
data: {
+ sender: nick
+ }
+ };
+ zenircbot.pub.publish('in', JSON.stringify(msg));
+ });
+
+ bot.addListener('topic', function(channel, topic, nick, message) {
+ console.log(nick + ' changed the topic in ' + channel + ' to "' + topic + '"');
+ var msg = {
+ version: 1,
+ type: 'topic',
+ data: {
sender: nick,
- },
+ channel: channel,
+ topic: topic
+ }
};
zenircbot.pub.publish('in', JSON.stringify(msg));
});
@@ -110,7 +124,7 @@ zenircbot = {
});
var output_handlers = {
- 1: zenircbot.output_version_1,
+ 1: zenircbot.output_version_1
};
zenircbot.sub.subscribe('out');
@@ -140,7 +154,8 @@ zenircbot = {
break;
case 'privmsg_action':
console.log(' privmsg_action');
- bot.say(message.data.to, "\u0001ACTION " + message.data.message + "\u0001");
+ bot.say(message.data.to, '\u0001ACTION ' + message.data.message +
+ '\u0001');
break;
case 'raw':
console.log(' raw');
2  bot.py
View
@@ -32,6 +32,8 @@ def do_sub(self):
self.pubsub = sub.pubsub()
self.pubsub.subscribe('out')
for msg in self.pubsub.listen():
+ if msg['type'] != 'message':
+ continue
message = json.loads(msg['data'])
print 'Got %s' % message
if message['version'] == 1:
2  docs/conf.py
View
@@ -51,7 +51,7 @@
# The short X.Y version.
version = '2.2'
# The full version, including alpha/beta/rc tags.
-release = '2.2.0'
+release = '2.2.1'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
23 docs/install.rst
View
@@ -9,11 +9,23 @@ platform, and there is a version that is written in Python_. Two of
the services are written in or rely on Python_ the rest are written in
JavaScript.
-If you are on Ubuntu, you should probably build and install Node_ and
-npm_ yourself. The packages that provide binaries of each of these
-names are not the things that you want. apt-get install node gives you
-an amateur packet radio program and npm is provided by a magnetic
-resonence imaging program. Neither of which are what ZenIRCBot needs.
+If you are on Ubuntu, then the quickest and easiest way to get a recent
+version of node is to use a version from a PPA_ (Personal Package Archive).
+This PPA containes the latest stable versions of nodejs.
+
+To install from the PPA make sure you have ``python-software-properties``
+installed first; otherwise, you might be missing the ``add-apt-repository``
+command. (Install ``software-properties-common`` on Quantal).
+
+Then run::
+
+ $ sudo add-apt-repository ppa:chris-lea/node.js
+ $ sudo apt-get update
+ $ sudo apt-get install nodejs npm
+
+If you don't want to use the PPA_ then you can always compile node_ and
+npm_ yourself.
+
Configuring the bot
-------------------
@@ -117,3 +129,4 @@ start up services. You can find information on starting up :doc:`services`.
.. _irckit: https://github.com/coleifer/irc
.. _Clojure: http://clojure.org/
.. _Leiningen: https://github.com/technomancy/leiningen
+.. _PPA: https://launchpad.net/~chris-lea/+archive/node.js/
14 docs/services_devel.rst
View
@@ -121,6 +121,20 @@ The possible ``in`` messages.
}
}
+.. js:data:: "topic"
+
+ Sent whenever a channel's topic is changed::
+
+ {
+ "version": 1,
+ "type": "topic",
+ "data": {
+ "sender": "",
+ "channel": "",
+ "topic": ""
+ }
+ }
+
Out messages
~~~~~~~~~~~~
2  package.json
View
@@ -2,7 +2,7 @@
"author": "Wraithan (http://wraithan.net)",
"name": "zenircbot",
"description": "ZenIRCBot",
- "version": "2.1.3",
+ "version": "2.2.1",
"homepage": "http://github.com/wraithan/zenircbot",
"repository": {
"type": "git",
2  services/admin.js
View
@@ -25,7 +25,7 @@ zen.register_commands("admin.js", [
description: "This will restart the service mentioned if it was started via admin.js."},
{name: "stop <service>",
description: "This will stop the service mentioned if it was started via admin.js."},
- {name: "git pull",
+ {name: "pull",
description: "This will pull down the code for the zenircbot."}]);
sub.subscribe('in');
4 services/lib/colors.js
View
@@ -1,6 +1,6 @@
colors = {
green: '\u000303',
- reset: '\u000f',
-};
+ reset: '\u000f'
+}
module.exports = colors;
41 services/motivate.js
View
@@ -0,0 +1,41 @@
+var ZenIRCBot = require('zenircbot-api').ZenIRCBot
+var zen = new ZenIRCBot()
+var sub = zen.get_redis_client()
+
+
+zen.register_commands(
+ "motivate.js",
+ [
+ {
+ name: "m <target>",
+ description: "Motivates the target."
+ }, {
+ name: "dm <target>",
+ description: "Demotivates the target."
+ }
+ ]
+)
+
+
+sub.subscribe('in');
+sub.on('message', function(channel, message){
+ var msg = JSON.parse(message);
+ if (msg.version == 1) {
+ if (msg.type == 'directed_privmsg') {
+ var motivate = /^m (.*)/i.exec(msg.data.message)
+ var demotivate = /^dm (.*)/i.exec(msg.data.message)
+ var validOne = (motivate || demotivate)
+ if (validOne && validOne[0].trim()) {
+ if (motivate) {
+ zen.send_privmsg(msg.data.channel,
+ "You're doing great work " +
+ motivate[1].trim() + "!");
+ } else if (demotivate) {
+ zen.send_privmsg(msg.data.channel,
+ "You're doing horrible work " +
+ demotivate[1].trim() + "!");
+ }
+ }
+ }
+ }
+});
4 services/semantics.js
View
@@ -12,12 +12,12 @@ sub.on('message', function(channel, message) {
var msg = JSON.parse(message);
if (msg.version == 1 && msg.type == 'privmsg') {
zen.redis.get('zenircbot:nick', function(err, nick) {
- if (msg.data.message.indexOf(nick + ': ') == 0) {
+ if (msg.data.message.indexOf(nick + ': ') === 0) {
directed_message(msg.data.message,
msg.data.message.substr(nick.length+2),
msg.data.sender,
msg.data.channel);
- } else if (msg.data.message.indexOf('!') == 0) {
+ } else if (msg.data.message.indexOf('!') === 0) {
directed_message(msg.data.message,
msg.data.message.substr(1),
msg.data.sender,
54 services/troll.js
View
@@ -1,39 +1,43 @@
-var ZenIRCBot = require('zenircbot-api').ZenIRCBot;
-var zen = new ZenIRCBot;
-var sub = zen.get_redis_client();
+var ZenIRCBot = require('zenircbot-api').ZenIRCBot
+var zen = new ZenIRCBot()
+var sub = zen.get_redis_client()
+var sourceUrl = 'https://github.com/wraithan/zenircbot'
+zen.register_commands(
+ 'troll.js',
+ [
+ {
+ name: 'ls',
+ description: 'Trolls the user for saying ls'
+ }, {
+ name: 'irssi',
+ description: 'When someone mentions irssi, suggests weechat.'
+ }
+ ]
+)
-zen.register_commands("troll.js",
- [{name: "ls",
- description: "Trolls the user for saying ls"},
- {name: "irssi",
- description: "When someone mentions irssi, suggests weechat."}
- ]
- );
-
-sub.subscribe('in');
+sub.subscribe('in')
sub.on('message', function(channel, message){
- var msg = JSON.parse(message);
+ var msg = JSON.parse(message)
if (msg.version == 1) {
if (msg.type == 'privmsg') {
if (/^ls$/.test(msg.data.message)) {
zen.send_privmsg(msg.data.channel,
- msg.data.sender + ': http://is.gd/afolif');
- } else if (/irssi/i.test(msg.data.message)) {
- zen.send_privmsg(msg.data.channel,
- msg.data.sender + ': Use weechat.');
+ msg.data.sender + ': http://is.gd/afolif')
}
} else if (msg.type == 'directed_privmsg') {
var who = ['whoareyou', 'who are you?', 'source']
- if (who.indexOf(msg.data.message) != -1) {
+ if (/^ping$/i.test(msg.data.message)) {
+ zen.send_privmsg(msg.data.channel, msg.data.sender + ': pong!')
+ } else if (who.indexOf(msg.data.message) != -1) {
zen.redis.get('zenircbot:nick', function(err, nick) {
- zen.send_privmsg(
- msg.data.channel,
- 'I am ' + nick + ', an instance of ZenIRCBot. ' +
- 'My source can be found here: https://github.com/wraithan/zenircbot'
- );
- });
+ zen.send_privmsg(msg.data.channel,
+ 'I am ' + nick + ', an instance of ' +
+ 'ZenIRCBot. My source can be found ' +
+ 'here: ' + sourceUrl
+ )
+ })
}
}
}
-});
+})
30 services/web-proxy.js
View
@@ -0,0 +1,30 @@
+var api = require('zenircbot-api');
+var bot_config = api.load_config('../bot.json');
+var zen = new api.ZenIRCBot(bot_config.redis.host,
+ bot_config.redis.port,
+ bot_config.redis.db);
+var redis = zen.get_redis_client();
+var web_config = api.load_config('./web-proxy.json');
+var express = require('express');
+var app = express();
+
+
+zen.register_commands('web-proxy.js', []);
+
+app.use(express.bodyParser());
+
+app.post('/', function(req, res) {
+ console.log(req.body.payload);
+ redis.publish('out', req.body.payload);
+ res.send('ok', 200);
+});
+
+app.post('/:channel', function(req, res) {
+ console.log(req.params.channel + ": " + req.body.message);
+ zen.send_privmsg(req.params.channel, req.body.message);
+ res.send('ok', 200);
+});
+
+app.listen(web_config.port);
+
+console.log("Listening on "+web_config.port);
3  services/web-proxy.json.dist
View
@@ -0,0 +1,3 @@
+{
+ "port": 10000
+}

No commit comments for this range

Something went wrong with that request. Please try again.