-
Notifications
You must be signed in to change notification settings - Fork 0
/
botep1.js
44 lines (36 loc) · 965 Bytes
/
botep1.js
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
39
40
41
42
43
// Create the configuration
var nickname = "jotscho"
var config = {
channels: ["#root-me_challenge"],
server: "irc.root-me.org",
botName: "Johbot"
};
// Get the libs
var irc = require("irc");
// Create the bot name
var bot = new irc.Client(config.server, config.botName, {
channels: config.channels
});
bot.addListener('error', function (message) {
console.log('error: ', message)
})
// Listen for any message, PM said user when he posts
bot.addListener("pm", function (nick, text, message) {
if (nick == nickname){
bot.say("Candy", "!ep1");
}
});
var i = 0
bot.addListener("pm", function (nick, text, message) {
if (nick == "Candy"){
console.log(text)
if (i == 0) {
var number = text.split("/");
var x = Math.sqrt(number[0]) * number[1]
var x = x.toFixed(2)
var response = "!ep1 -rep " + x
console.log(response);
bot.say("Candy", response)
i++;
}}
});