You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
611 B

function Channel(name) {
this.name = name
this.userlist = []
this.join = function(user) {
let channel = this
this.userlist.push(user)
this.userlist.forEach(function(item) {
item.sendRaw(`:${user.nickname} JOIN ${channel.name}`)
})
}
this.part = function(user) {
let channel = this
let userIndex = this.userlist.indexOf(user)
if (userIndex >= 0) {
this.userlist.forEach(function(item) {
item.sendRaw(`:${user.nickname} PART ${channel.name}`)
})
this.userlist.splice(index, 1)
}
}
}
module.exports = Channel