init
This commit is contained in:
commit
4c1f24143c
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
logs
|
||||
node_modules
|
80
index.js
Normal file
80
index.js
Normal file
@ -0,0 +1,80 @@
|
||||
const fs = require('fs')
|
||||
const irc = require('irc');
|
||||
const settings = JSON.parse(fs.readFileSync('settings.json'));
|
||||
const readline = require('readline')
|
||||
const model = 'user,date,message'
|
||||
|
||||
let currentChannel = settings.channels[0]
|
||||
|
||||
const client = new irc.Client(settings.server, settings.username, {
|
||||
channels: settings.channels,
|
||||
autoRejoin: true,
|
||||
retryCount: 100000000,
|
||||
retryDelay: 2*60*1000,
|
||||
// secure: true,
|
||||
// certExpired: true,
|
||||
// selfSigned: true
|
||||
});
|
||||
|
||||
client.addListener('registered', () => {
|
||||
|
||||
client.addListener('error', (message) => {
|
||||
console.log('Error: ' + message)
|
||||
})
|
||||
|
||||
client.addListener('message', function (from, channel, message) {
|
||||
if (channel === settings.username) return
|
||||
logMessage(from, channel, message)
|
||||
});
|
||||
|
||||
client.addListener('join', (channel, nick) => {
|
||||
logMessage(nick, channel, "Joined the channel")
|
||||
if (nick === settings.username) sendMessage(channel, "# Appears as Jhenna_Hina.http://www.mermeliz.com/hina/dl/Jhenna_Hina.AVB")
|
||||
})
|
||||
|
||||
client.addListener('quit', (channel, nick, by, reason) => {
|
||||
logMessage(nick, channel, "Kicked by: " + by + ": " + reason)
|
||||
})
|
||||
|
||||
const rl = readline.createInterface({
|
||||
input: process.stdin,
|
||||
output: process.stdout
|
||||
});
|
||||
|
||||
function messagePrompt(){
|
||||
rl.question(settings.username + ': ', (command) => {
|
||||
sendMessage(currentChannel, command)
|
||||
messagePrompt()
|
||||
});
|
||||
}
|
||||
|
||||
function logMessage(from, channel, message){
|
||||
const currentDate = new Date();
|
||||
////////////////////////////////////////////////////////////////DATE FORMAT
|
||||
const year = currentDate.getFullYear();
|
||||
const month = String(currentDate.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(currentDate.getDate()).padStart(2, '0');
|
||||
const hours = String(currentDate.getHours()).padStart(2, '0');
|
||||
const minutes = String(currentDate.getMinutes()).padStart(2, '0');
|
||||
const seconds = String(currentDate.getSeconds()).padStart(2, '0');
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
const formattedDate = `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
||||
const filename = 'logs/' + channel + '.csv'
|
||||
|
||||
if (!fs.existsSync(filename)){
|
||||
fs.writeFileSync(filename, model)
|
||||
}
|
||||
|
||||
fs.appendFileSync(filename, `\n${from},${formattedDate},"${message}"`)
|
||||
if(from !== settings.username)console.log(`${from}: ${message}`)
|
||||
}
|
||||
|
||||
function sendMessage(channel, message){
|
||||
logMessage(settings.username, channel, message)
|
||||
client.say(channel, message)
|
||||
}
|
||||
|
||||
rl.prompt();
|
||||
messagePrompt()
|
||||
})
|
82
package-lock.json
generated
Normal file
82
package-lock.json
generated
Normal file
@ -0,0 +1,82 @@
|
||||
{
|
||||
"name": "true-irc-logger",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "true-irc-logger",
|
||||
"version": "1.0.0",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"irc": "^0.5.2",
|
||||
"readline": "^1.3.0"
|
||||
}
|
||||
},
|
||||
"node_modules/iconv": {
|
||||
"version": "2.2.3",
|
||||
"resolved": "https://registry.npmjs.org/iconv/-/iconv-2.2.3.tgz",
|
||||
"integrity": "sha512-evIiYeKdt5nEGYKNkQcGPQy781sYgbBKi3gEkt1s4CwteCdOHSjGGRyyp6lP8inYFZwvzG3lgjXEvGUC8nqQ5A==",
|
||||
"hasInstallScript": true,
|
||||
"license": "ISC",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"nan": "^2.3.5"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/irc": {
|
||||
"version": "0.5.2",
|
||||
"resolved": "https://registry.npmjs.org/irc/-/irc-0.5.2.tgz",
|
||||
"integrity": "sha512-KnrvkV05Y71SWmRWHtnlWEIH7LA/YeDul6l7tncCGLNEw4B6Obtmkatb3ACnSLj0kOJ6UBiuhss9e+eRG3zlxw==",
|
||||
"license": "GPL-3.0",
|
||||
"dependencies": {
|
||||
"irc-colors": "^1.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"iconv": "~2.2.1",
|
||||
"node-icu-charset-detector": "~0.2.0"
|
||||
}
|
||||
},
|
||||
"node_modules/irc-colors": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/irc-colors/-/irc-colors-1.5.0.tgz",
|
||||
"integrity": "sha512-HtszKchBQTcqw1DC09uD7i7vvMayHGM1OCo6AHt5pkgZEyo99ClhHTMJdf+Ezc9ovuNNxcH89QfyclGthjZJOw==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/nan": {
|
||||
"version": "2.22.0",
|
||||
"resolved": "https://registry.npmjs.org/nan/-/nan-2.22.0.tgz",
|
||||
"integrity": "sha512-nbajikzWTMwsW+eSsNm3QwlOs7het9gGJU5dDZzRTQGk03vyBOauxgI4VakDzE0PtsGTmXPsXTbbjVhRwR5mpw==",
|
||||
"license": "MIT",
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/node-icu-charset-detector": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/node-icu-charset-detector/-/node-icu-charset-detector-0.2.0.tgz",
|
||||
"integrity": "sha512-DYOFJ3NfKdxEi9hPbmoCss6WydGhJsxpSleUlZfAWEbZt3AU7JuxailgA9tnqQdsHiujfUY9VtDfWD9m0+ThtQ==",
|
||||
"hasInstallScript": true,
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"nan": "^2.3.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/readline": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/readline/-/readline-1.3.0.tgz",
|
||||
"integrity": "sha512-k2d6ACCkiNYz222Fs/iNze30rRJ1iIicW7JuX/7/cozvih6YCkFZH+J6mAFDVgv0dRBaAyr4jDqC95R2y4IADg==",
|
||||
"license": "BSD"
|
||||
}
|
||||
}
|
||||
}
|
15
package.json
Normal file
15
package.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "true-irc-logger",
|
||||
"version": "1.0.0",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"description": "",
|
||||
"dependencies": {
|
||||
"irc": "^0.5.2",
|
||||
"readline": "^1.3.0"
|
||||
}
|
||||
}
|
6
process.json
Normal file
6
process.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"script": "index.js",
|
||||
"name": "irc-logger",
|
||||
"watch": true,
|
||||
"ignore_watch": ["public", "node_modules", "package.json", "package-lock.json", ".git", "logs"]
|
||||
}
|
5
settings.json
Normal file
5
settings.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"username": "G0R-D0WN",
|
||||
"server": "irc.koshka.love",
|
||||
"channels": ["#niggarts"]
|
||||
}
|
5
settings_example.json
Normal file
5
settings_example.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"username": "G0R-D0WN",
|
||||
"server": "irc.koshka.love",
|
||||
"channels": ["#niggarts"]
|
||||
}
|
Loading…
Reference in New Issue
Block a user