Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Create the configuration
- var config = {
- channel: ["#logtoipfs"],
- server: "irc.freenode.net",
- botName: "logtoipfs"
- };
- // Get the lib for IRC
- var irc = require("irc");
- // Get the lib for filesystem writing
- const fs = require('fs');
- const CreateFiles = fs.createWriteStream('./' + config.channel, {
- flags: 'a' //flags: 'a' preserved old data
- })
- // Create the bot
- var bot = new irc.Client(config.server, config.botName, {
- channels: config.channel
- });
- // Listen for any channel message, write it to a file
- bot.addListener("message" + config.channel, function(nick, text, message) {
- console.log(nick + ' => ' + ': ' + text);
- CreateFiles.write("{\r\n \"channel\": \"" + config.channel +"\",\r\n \"nick\": \"" + nick +"\",\r\n \"text\": \"" + text +"\"\r\n}\r\n")
- });
- // Write errors to the console
- bot.addListener('error', function(message) {
- console.log('error: ', message);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement