-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathchannel.js
49 lines (39 loc) · 1.03 KB
/
channel.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
44
45
46
47
48
49
var Channel = exports.Channel = function(irc, name) {
this.irc = irc;
this.name = name;
this.users = [];
this.joinChannel();
}
Channel.prototype.joinChannel = function() {
this.irc.raw('JOIN', this.name);
}
Channel.prototype.send = function(msg) {
this.irc.send(this.name, msg);
}
Channel.prototype.userJoin = function(nick) {
if (this.users.indexOf(nick) >= 0) { // The user is already in the channel
return;
}
this.users.push(nick);
}
Channel.prototype.userKick = function(nick) {
if (this.users.indexOf(nick) > -1) {
this.users.splice(this.users.indexOf(nick), 1);
}
}
Channel.prototype.userPart = function(nick) {
if (this.users.indexOf(nick) > -1) {
this.users.splice(this.users.indexOf(nick), 1);
}
}
Channel.prototype.userNickChange = function(nick, newNick) {
if (this.users.indexOf(nick) > -1) {
this.users.splice(this.users.indexOf(nick), 1);
this.users.push(newNick);
}
}
Channel.prototype.userQuit = function(nick) {
if (this.users.indexOf(nick) > -1) {
this.users.splice(this.users.indexOf(nick), 1);
}
}