I am making an IRC bot I want to make a thing that whenever someone joins the IRC channel with a specific nickname, it will welcome them and say they're a confirmed channel host user and give them ops. But I have no idea what I could do to do this.
I'm using node.js with the irc library.
I have tried:
bot.addListener("join", function(channel, who) {
if((who|user|client).(nick|nickname) = "SlimeDiamond", "JS", "Super" { // The things in the brackets separated by the | are what I have tried there.
bot.say("Welcome, " + who + "!"
} else {
return;
});
==
or ===
not with =
Your conditions needs to be something like if (who.nickname === "Something")
indexOf
if you want to check multiple valuesYou can't do if (someVariable == "value1", "value2", "value3")
: you need to do
if (["value1", "value2", "value3"].indexOf(someVariable) !== -1)
Documentation for indexOf here
so, so far we have if (["SlimeDiamond", "JS", "Super"].indexOf(who.nickname) !== -1)
for the condition
From the documentation here, the join
event can be listened to with a callback that takes these three arguments :
I didn't test but it seems that your second argument (who
) here IS the nickname not an object that contains the nickname. So this should work :
bot.addListener("join", function(channel, who) {
if(["SlimeDiamond", "JS", "Super"].indexOf(who) !== -1) {
bot.say("Welcome, " + who + "!");
} else {
return;
}
});