Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. // Event librairie IRC disponible sur: https://node-irc.readthedocs.io/en/latest/index.html
  2.  
  3. //Recupération de la librairie IRC
  4. var irc = require('irc');
  5.  
  6. //Recupération de la partie web serveur
  7. var http = require('http');
  8. var url = require('url');
  9.  
  10. // Querystring pour manipuler la chaine
  11. // de l'url
  12. var querystring = require('querystring');
  13.  
  14. //Création du serveur web
  15. var instructionServeur = function(req, res) {
  16. var params = querystring.parse(url.parse(req.url).query);
  17. res.writeHead(200, {"Content-Type": "text/plain"});
  18. res.write(params['pseudo']);
  19. res.end();
  20. }
  21. var server = http.createServer(instructionServeur);
  22.  
  23. //Sélection du port souhaité
  24. server.listen(8080);
  25.  
  26. //Création du client IRC
  27. var client = new irc.Client('irc2.dialova.com', 'raptor', {
  28. port:7000,
  29. userName: "cle1",
  30. password: "XXXXX",
  31. channels: ['#testnode'],
  32. autoConnect:false,
  33. });
  34.  
  35. //Bot connecté à IRC
  36. client.connect(function(input) {
  37. client.send('OPER','autoreg','XXXXX');
  38. console.log('bot connecté');
  39. });
  40.  
  41. //Detection des messages en PV si le message est "bye" le bot deco
  42. client.addListener('pm', function (from, text) {
  43. console.log("[MESSAGE PRIVE] <"+ from + '> ' + text);
  44. client.say(from, text);
  45. if (text.indexOf('bye') !== -1) {
  46. client.disconnect("Aurevoir.", function () {
  47. console.log("[QUIT] Aurevoir.");
  48. });
  49. }
  50. });
  51.  
  52. //Detection de notice NickServ
  53. client.addListener('notice', function (nick, to, text, message) {
  54. if (nick == "NickServ") {
  55. console.log(nick + ' ' + to + ' ' + text + ' ' + message);
  56. }
  57. });
  58.  
  59. //Detection de message dans le salon
  60. client.addListener('message', function (from, to, text) {
  61. console.log("[MESSAGE " + to + '] <' + from + '> ' + text);
  62. });
  63.  
  64. //raw 433 pseudo déjà utilisé
  65. client.addListener('raw', function(raw) {
  66. if (raw.rawCommand == 433) {
  67. console.log("Raw 433 détecté pseudo déjà utilisé.");
  68. }
  69. // console.log(raw);
  70. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement