Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Event librairie IRC disponible sur: https://node-irc.readthedocs.io/en/latest/index.html
- //Recupération de la librairie IRC
- var irc = require('irc');
- //Recupération de la partie web serveur
- var http = require('http');
- var url = require('url');
- // Querystring pour manipuler la chaine
- // de l'url
- var querystring = require('querystring');
- //Création du serveur web
- var instructionServeur = function(req, res) {
- var params = querystring.parse(url.parse(req.url).query);
- res.writeHead(200, {"Content-Type": "text/plain"});
- res.write(params['pseudo']);
- res.end();
- }
- var server = http.createServer(instructionServeur);
- //Sélection du port souhaité
- server.listen(8080);
- //Création du client IRC
- var client = new irc.Client('irc2.dialova.com', 'raptor', {
- port:7000,
- userName: "cle1",
- password: "XXXXX",
- channels: ['#testnode'],
- autoConnect:false,
- });
- //Bot connecté à IRC
- client.connect(function(input) {
- client.send('OPER','autoreg','XXXXX');
- console.log('bot connecté');
- });
- //Detection des messages en PV si le message est "bye" le bot deco
- client.addListener('pm', function (from, text) {
- console.log("[MESSAGE PRIVE] <"+ from + '> ' + text);
- client.say(from, text);
- if (text.indexOf('bye') !== -1) {
- client.disconnect("Aurevoir.", function () {
- console.log("[QUIT] Aurevoir.");
- });
- }
- });
- //Detection de notice NickServ
- client.addListener('notice', function (nick, to, text, message) {
- if (nick == "NickServ") {
- console.log(nick + ' ' + to + ' ' + text + ' ' + message);
- }
- });
- //Detection de message dans le salon
- client.addListener('message', function (from, to, text) {
- console.log("[MESSAGE " + to + '] <' + from + '> ' + text);
- });
- //raw 433 pseudo déjà utilisé
- client.addListener('raw', function(raw) {
- if (raw.rawCommand == 433) {
- console.log("Raw 433 détecté pseudo déjà utilisé.");
- }
- // console.log(raw);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement