channel.js 997 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. var channel = function(){
  2. this.name = null;
  3. this.TS = null;
  4. this.topic = null;
  5. this.modes = {};
  6. this.statusModes = {};
  7. this.users = [];
  8. this.setTS = function(TS){
  9. this.TS = TS;
  10. };
  11. this.addModes = function(modes){
  12. console.log(modes);
  13. // TODO
  14. };
  15. this.joinUser = function(user){
  16. if(this.users.indexOf(user) >= 0) return;
  17. this.users.push(user);
  18. };
  19. this.setStatusModes = function(user, modes){
  20. console.log(user);
  21. console.log(modes);
  22. this.statusModes[user.uid] = modes;
  23. // TODO
  24. };
  25. this.addBan = function(ban){
  26. // TODO
  27. };
  28. this.addExcept = function(except){
  29. // TODO
  30. };
  31. this.addInvex = function(invex){
  32. // TODO
  33. };
  34. this.removeUser = function(user){
  35. var index = this.statusModes.indexOf(user);
  36. if(index >= 0){
  37. this.statusModes.splice(index, 1); // remove status modes for this user
  38. }
  39. for(var i=0; i<this.users.length; i++){
  40. if(this.users[i] == user){
  41. this.users.splice(i, 1);
  42. break;
  43. }
  44. }
  45. };
  46. }
  47. module.exports = channel;