-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.js
28 lines (25 loc) · 797 Bytes
/
bot.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
var irc = require('irc');
var moment = require('moment');
var client = new irc.Client('irc.twitch.tv', 'Your-nick', {
channels: ['#channel-name'],
password: 'oauth:'
});
// this is the module that tells you time
var now = moment();
var commands = {
// base name: function (from, to, message){client.say(to, )}
};
// listens to the messages
client.addListener('message',function (from, to, message){
console.log(from + ' => ' + to + ': ' + message);
// If the first chraracter is !
if (message.substr(0,1) == '!'){
var tmp = message.substr(1).split(' ')[0].toLowerCase();
var chan = to.substr(1).split(' ')[0]
// Checks if the command exist
if (commands[chan][tmp]){
//Returns the values that the commands code use
commands[chan][tmp](from, to, message.substr(1))
}
}
});