Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 109 lines (69 sloc) 3.102 kb
73ebc5b7 »
2011-05-09 Added docs
1 # wobot
66870165 »
2011-05-05 Initial commit.
2
3 A plugin-based HipChat bot written in Node.js.
4
73ebc5b7 »
2011-05-09 Added docs
5 # Installation
66870165 »
2011-05-05 Initial commit.
6
1995e937 »
2011-05-05 Added dependencies
7 The easiest way to obtain Wobot is through [npm](http://npmjs.org/):
8
babc54b9 »
2011-05-05 Fixed indents
9 npm install wobot
1995e937 »
2011-05-05 Added dependencies
10
4fe27ced »
2011-05-05 More depends
11 Keep in mind this module depends on `node-xmpp` which cannot be built without:
12
13 - libexpat1-dev: `apt-get install libexpat1-dev`
14 - libicu-dev: `apt-get install libicu-dev`
66870165 »
2011-05-05 Initial commit.
15
73ebc5b7 »
2011-05-09 Added docs
16 # Your First Bot
17
18 Instantiate the `wobot.Bot` class by passing it a hash containing:
19
758fc571 »
2011-05-09 Docs
20 - `jid`: Jabber ID followed by `/bot`
21 - `password`: The account's password
22 - `name`: The name of the bot as it appears in HipChat. This is usually `firstname + lastname[0]`.
73ebc5b7 »
2011-05-09 Added docs
23
336755c3 »
2011-05-09 Docs
24 ```javascript
25 var wobot = require('wobot');
73ebc5b7 »
2011-05-09 Added docs
26
336755c3 »
2011-05-09 Docs
27 var bot = new wobot.Bot({
28 jid: '????_????@chat.hipchat.com/bot',
29 password: '??????',
30 name: '???? ????'
31 });
73ebc5b7 »
2011-05-09 Added docs
32
336755c3 »
2011-05-09 Docs
33 bot.connect();
34 ```
73ebc5b7 »
2011-05-09 Added docs
35
36 # Events
37
1906509a »
2011-05-29 Updated docs
38 The following events can be binded to:
73ebc5b7 »
2011-05-09 Added docs
39
1906509a »
2011-05-29 Updated docs
40 ## onConnect(callback)
73ebc5b7 »
2011-05-09 Added docs
41 Emitted whenever the bot connects to the server.
42
1906509a »
2011-05-29 Updated docs
43 ## onMessage(condition, callback)
73ebc5b7 »
2011-05-09 Added docs
44 Emitted whenever a message is sent to a channel the bot is in.
45
1906509a »
2011-05-29 Updated docs
46 - `condition` is either a RegExp or a string which must match the message for the callback to be triggered.
47 - `callback` in the form of `function(channel, from, message[, matches])`.
48
49 `condition` can also be omitted i.e. `onMessage(callback)`.
50
51 ## onPrivateMessage(condition, callback)
73ebc5b7 »
2011-05-09 Added docs
52 Emitted whenever a message is sent privately to the bot.
53
1906509a »
2011-05-29 Updated docs
54 - `condition` is either a RegExp or a string which must match the message for the callback to be triggered.
55 - `callback` in the form of `function(from, message[, matches])`.
56
57 `condition` can also be omitted i.e. `onPrivateMessage(callback)`.
58
59 ## onPing(callback)
73ebc5b7 »
2011-05-09 Added docs
60 Emitted everytime the bot pings the server (roughly every 30 seconds.)
61
1906509a »
2011-05-29 Updated docs
62 ## onError(callback)
e089f241 »
2011-05-15 Added new error event and handling HipChat see-other-host error - clo…
63 Emitted whenever an error occurs. `disconnect` will be emitted afterwards.
64
1906509a »
2011-05-29 Updated docs
65 - `callback` in the form of `function(message[, stanza])`
66 - `message` is a string representation of the error.
67 - `stanza` is an instance of `xmpp.Element`, when available.
e089f241 »
2011-05-15 Added new error event and handling HipChat see-other-host error - clo…
68
1906509a »
2011-05-29 Updated docs
69 ## disconnect(callback)
73ebc5b7 »
2011-05-09 Added docs
70 Emitted whenever the bot disconnects from the server.
71
72 # Public API
73
74 Instances of `wobot.Bot` have the following methods:
75
78ad6d62 »
2011-05-09 docs..
76 ## join(roomJid)
73ebc5b7 »
2011-05-09 Added docs
77 Join a channel.
f3b78f36 »
2011-05-09 docs..
78
758fc571 »
2011-05-09 Docs
79 - `roomJid` is in the following format: `????_????@conf.hipchat.com`.
73ebc5b7 »
2011-05-09 Added docs
80
78ad6d62 »
2011-05-09 docs..
81 ## part(roomJid)
73ebc5b7 »
2011-05-09 Added docs
82 Part a channel.
83
1906509a »
2011-05-29 Updated docs
84 ## message(targetJid, message)
85 Send a message to either a channel or a user.
f3b78f36 »
2011-05-09 docs..
86
1906509a »
2011-05-29 Updated docs
87 - `targetJid` is in the following format:
88 - `????_????@chat.hipchat.com` for a private message.
89 - `????_????@conf.hipchat.com` for a channel message.
73ebc5b7 »
2011-05-09 Added docs
90
78ad6d62 »
2011-05-09 docs..
91 ## connect()
73ebc5b7 »
2011-05-09 Added docs
92 Connect to the server.
93
78ad6d62 »
2011-05-09 docs..
94 ## disconnect()
73ebc5b7 »
2011-05-09 Added docs
95 Disconnect from the server.
96
78ad6d62 »
2011-05-09 docs..
97 ## loadPlugin(identifier, plugin, options)
73ebc5b7 »
2011-05-09 Added docs
98 Load a plugin.
f3b78f36 »
2011-05-09 docs..
99
758fc571 »
2011-05-09 Docs
100 - `identifier`: A unique string that identifies the plugin. This will be used to unload it.
a66bba92 »
2011-05-29 Updated loadPlugin doc
101 - `plugin`: Object with a `load` function as so: `function load (bot)`.
758fc571 »
2011-05-09 Docs
102 - `options`: Will be passed as the second argument to `load`.
73ebc5b7 »
2011-05-09 Added docs
103
17139a59 »
2011-05-05 Renamed header
104 # Legal stuff
66870165 »
2011-05-05 Initial commit.
105
106 Copyright (c) 2011 Christian Joudrey. See LICENSE for details.
107
108 Node.js is an official trademark of Joyent. This module is not formally related to or endorsed by the official Joyent Node.js open source or commercial project.
Something went wrong with that request. Please try again.