services.js 1000 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. 'serverDelete': [],
  16. 'serverCreate': [],
  17. 'serverDesc': [],
  18. 'uplinkLost': [],
  19. 'userDelete': [],
  20. 'userCreate': [],
  21. 'userVHost': [],
  22. 'userVIdent': [],
  23. 'userRealname': [],
  24. 'userNick': [],
  25. 'userUmode': [],
  26. 'userMetadata': [],
  27. 'doEvent': function(event, args){
  28. if(event in events){
  29. for(var i=0; i<events[event].length; i++){
  30. args = events[event][i](args);
  31. }
  32. } else {
  33. console.log('Called unknown event '+event);
  34. }
  35. return args;
  36. }
  37. };
  38. irc.setEvents(events);
  39. irc.setConnection('localhost', 6667, 'unrealircd');
  40. var myUser = irc.makeUser('TestServ', 'pirc', 'serwisy.pirc.pl', 'Użytkownik testowy');
  41. var myChannel = irc.getChannel('#test');
  42. myChannel.joinUser(myUser);