-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathyour-bot-here.js
More file actions
38 lines (29 loc) · 845 Bytes
/
your-bot-here.js
File metadata and controls
38 lines (29 loc) · 845 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
var Util = require("util");
var Bot = require("./lib/irc");
var YourBot = function(profile) {
Bot.call(this, profile);
this.set_log_level(this.LOG_ALL);
this.set_trigger("!"); // Exclamation
};
Util.inherits(YourBot, Bot);
YourBot.prototype.init = function() {
Bot.prototype.init.call(this);
this.register_command("ping", this.ping);
this.on('command_not_found', this.unrecognized);
};
YourBot.prototype.ping = function(cx, text) {
cx.channel.send_reply (cx.sender, "Pong!");
};
YourBot.prototype.unrecognized = function(cx, text) {
cx.channel.send_reply(cx.sender, "There is no command: "+text);
};
var profile = [{
host: "irc.freenode.net",
port: 6667,
nick: "mybot",
password: "password_to_authenticate",
user: "username",
real: "Real Name",
channels: ["#channels", "#to", "#join"]
}];
(new YourBot(profile)).init();