services.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. var irc = require('./irc');
  2. var events = {
  3. 'botMessage': [],
  4. 'botNotice': [],
  5. 'channelMessage': [],
  6. 'channelNotice': [],
  7. 'channelModes': [],
  8. 'channelListMode': [],
  9. 'channelStatusMode': [],
  10. 'channelJoin': [],
  11. 'channelLeave': [],
  12. 'channelMetadata': [],
  13. 'channelCreate': [],
  14. 'netSynced': [],
  15. 'newTagMessage': [],
  16. 'serverDelete': [],
  17. 'serverCreate': [],
  18. 'serverDesc': [],
  19. 'uplinkLost': [],
  20. 'userDelete': [],
  21. 'userCreate': [],
  22. 'userVHost': [],
  23. 'userVIdent': [],
  24. 'userRealname': [],
  25. 'userNick': [],
  26. 'userUmode': [],
  27. 'userMetadata': [],
  28. 'doEvent': function(event){
  29. var args = new Array(arguments.length - 1);
  30. for(var i=1; i<arguments.length; i++){
  31. args[i-1] = arguments[i];
  32. }
  33. if(event in events){
  34. for(var i=0; i<events[event].length; i++){
  35. args = events[event][i].apply(null, args);
  36. }
  37. } else {
  38. console.log('Called unknown event '+event);
  39. }
  40. return args;
  41. }
  42. };
  43. irc.setEvents(events);
  44. irc.setConnection('localhost', 6667, 'unrealircd');
  45. var myUser = irc.makeUser('TestServ', 'pirc', 'serwisy.pirc.pl', 'Użytkownik testowy');
  46. var myChannel = irc.getChannel('#test');
  47. myChannel.joinUser(myUser);
  48. /*
  49. setTimeout(function(){
  50. irc.uplink.changeUmodes(myUser, { 'NOCTCPMESSAGES': true, 'BOT': false }); // setting umodes test
  51. }, 10000);
  52. */