This commit is contained in:
simio 2024-12-03 02:48:30 -03:00
parent df6aa45a73
commit 438f3ff2eb

View File

@ -24,12 +24,24 @@ const client = new irc.Client(settings.server, settings.username, {
client.addListener('registered', () => { client.addListener('registered', () => {
//////////////LISTENERS//////////////////// //////////////LISTENERS////////////////////
client.addListener('error', (message) => { client.addListener('error', (message) => {
console.log('Error: ' + message) console.log('Error: ' + message)
}) })
client.addListener('message', function (from, channel, message) { client.addListener('message', function (from, channel, message) {
if (channel === settings.username) return //DMS SENT TO THE BOT
if (channel === client.nick){
console.log("DM from " + from + ": " + message)
const args = message.split("# ")[1]
if(args){
if(args === "GetInfo") client.say(from, "# HeresInfo: japanese nationalist")
}
return
}
logMessage(from, channel, message) logMessage(from, channel, message)
}); });
@ -37,24 +49,26 @@ client.addListener('registered', () => {
client.addListener('join', (channel, nick) => { client.addListener('join', (channel, nick) => {
logMessage(nick, channel, "Joined the channel") logMessage(nick, channel, "Joined the channel")
//I'M THE ANIME GIRL FAGGOT //I'M THE ANIME GIRL FAGGOT
if (nick === settings.username) sendMessage(channel, "# Appears as Jhenna_Hina.http://www.mermeliz.com/hina/dl/Jhenna_Hina.AVB") if (nick === client.nick){
sendMessage(channel, "# Appears as Jhenna_Hina.http://www.mermeliz.com/hina/dl/Jhenna_Hina.AVB")
}else{
client.say(nick, "# Appears as Jhenna_Hina.http://www.mermeliz.com/hina/dl/Jhenna_Hina.AVB")
}
}) })
client.addListener('part', (channel, nick, reason, _message) => { client.addListener('part', (channel, nick, reason, _message) => {
console.log(channel) logMessage(nick, channel, `Left${reason ? ":" + reason : "."}` )
logMessage(nick, channel, "Parted: " + reason)
}) })
client.addListener('quit', (nick, reason, channels, _message) => { client.addListener('quit', (nick, reason, channels, _message) => {
for(i in channels){ for(i in channels){
logMessage(nick, channels[i], "Left: " + reason) logMessage(nick, channels[i], `Left${reason ? ":" + reason : "."}`)
} }
}) })
client.addListener('kick', (channel, nick, by, reason, _message) => { client.addListener('kick', (channel, nick, by, reason, _message) => {
logMessage(nick, channel, "Kicked by: " + by + ": " + reason) logMessage(nick, channel, "Kicked by: " + by + ": " + reason)
}) })
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
@ -106,7 +120,8 @@ client.addListener('registered', () => {
const prefix = split[0] const prefix = split[0]
if(prefix === "g"){ if(prefix === "g"){
const terminalCommand = split[1].split(' ')[0] const terminalCommand = split[1].split(' ')[0]
const args = split[1].split(' ')[1] ? split[1].split(' ')[1] : "" const splitArgs = split[1].split(' ')
const args = splitArgs[1] ? splitArgs[1] : ""
switch (terminalCommand) { switch (terminalCommand) {
case "switch_channel": case "switch_channel":
if (!args) { if (!args) {
@ -130,6 +145,26 @@ client.addListener('registered', () => {
console.log(user) console.log(user)
} }
break break
case "message":
if(!args){
console.log("Arguments required")
}
const message = getMessageFromArgs(splitArgs)
if (!message) {
console.log("Message required");
break
}
client.say(args, message)
break
case "whois":
if(!args) return console.log("Arguments required")
client.whois(args, (info) => {
console.log(info)
})
break
default:
console.log("Comando inexistente")
break
} }
}else{ }else{
sendMessage(currentChannel, command) sendMessage(currentChannel, command)
@ -148,4 +183,10 @@ function checkIfIsInChannelAndLog(channel){
return false return false
} }
return true return true
}
function getMessageFromArgs(splitArgs){
splitArgs.shift()
splitArgs.shift()
return splitArgs.join(" ")
} }