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

  1. function Channel(name) {
  2. this.name = name
  3. this.userlist = []
  4. this.join = function(user) {
  5. let channel = this
  6. this.userlist.push(user)
  7. this.userlist.forEach(function(item) {
  8. item.sendRaw(`:${user.nickname} JOIN ${channel.name}`)
  9. })
  10. }
  11. this.part = function(user) {
  12. let channel = this
  13. let userIndex = this.userlist.indexOf(user)
  14. if (userIndex >= 0) {
  15. this.userlist.forEach(function(item) {
  16. item.sendRaw(`:${user.nickname} PART ${channel.name}`)
  17. })
  18. this.userlist.splice(index, 1)
  19. }
  20. }
  21. }
  22. module.exports = Channel