Hey I'm trying to make it to that people can't change my (Kase) and Neos auth below what its currently at. Other than at the the command should other normally. Code (text): if (command == "changeauth" || command == "changeauths") { var pos = commandData.indexOf(' '); if (pos == -1) return; var newauth = commandData.substring(0, pos), name = commandData.substr(pos+1), tar = sys.id(name), silent = command == "changeauths"; if (newauth > 0 && !sys.dbRegistered(name)) { normalbot.sendMessage(src, "This person is not registered"); normalbot.sendMessage(tar, "Please register, before getting auth"); return; } if (sys.dbIp(tar) === "Kase", "Neos") { var newauth = commandData.substring(0, pos), name = commandData.substr(pos+1), tar = sys.id(name), silent = command == "changeauths"; if (newauth < sys.auth(name)) { normalbot.sendMessage(src, "You do not have permission to change the auth of " + name + "."); else sys.changeDbAuth(name, newauth); if (!silent) normalbot.sendAll("" + sys.name(src) + " changed auth of " + name + " to " + newauth); else normalbot.sendAll("" + sys.name(src) + " changed auth of " + name + " to " + newauth, staffchannel); return; } if (tar !== undefined) sys.changeAuth(tar, newauth); else sys.changeDbAuth(name, newauth); if (!silent) normalbot.sendAll("" + sys.name(src) + " changed auth of " + name + " to " + newauth); else normalbot.sendAll("" + sys.name(src) + " changed auth of " + name + " to " + newauth, staffchannel); return; } This is what I have tried to do. When I try to change auth it says "You do not have permission to change the auth of " + name + "." It happens with everyone I try to change the auth off. Also, how can you make commands only usable by some people, using IP or name to Identity them?
The if (sys.dbIp tar line is completely wrong. I don't know what you're attempting there. For the latter question, just look at eval in the po server scripts
Thanks for the reply Moogle. On that line I'm trying to see if the target of the changeauth commands is Kase or Neos. It the someone is trying to change the auth to lower than its what is now, it stops the event, if its higer, it continues with the event. That whole part is there to stop people trying to change our auth to lower than what its is. How can I fix that line? And is that the only thing wrong with the code?
I made some changes to the code. I don't the the error I got before, but "if (sys.ip(tar) === "Kase", "Neos")" is wrong because it fails to recognize that function. Code (text): if (command == "changeauth" || command == "changeauths") { var pos = commandData.indexOf(' '); if (pos == -1) return; var newauth = commandData.substring(0, pos), name = commandData.substr(pos+1), tar = sys.id(name), silent = command == "changeauths"; if (newauth > 0 && !sys.dbRegistered(name)) { normalbot.sendMessage(src, "This person is not registered"); normalbot.sendMessage(tar, "Please register, before getting auth"); return; } if (sys.ip(tar) === "Kase", "Neos") { var newauth = commandData.substring(0, pos), name = commandData.substr(pos+1), tar = sys.id(name), silent = command == "changeauths"; if (newauth < sys.auth(name)) { normalbot.sendMessage(src, "You do not have permission to change the auth of " + name + "."); return; } if (tar !== undefined) sys.changeAuth(tar, newauth); else sys.changeDbAuth(name, newauth); if (!silent) normalbot.sendAll("" + sys.name(src) + " changed auth of " + name + " to " + newauth); else normalbot.sendAll("" + sys.name(src) + " changed auth of " + name + " to " + newauth, staffchannel); return; } if (tar !== undefined) sys.changeAuth(tar, newauth); else sys.changeDbAuth(name, newauth); if (!silent) normalbot.sendAll("" + sys.name(src) + " changed auth of " + name + " to " + newauth); else normalbot.sendAll("" + sys.name(src) + " changed auth of " + name + " to " + newauth, staffchannel); return; } *Note Its more likely to be something like commandData instead of sys.ip(tar) Tried this code as well. It more likely to be something like this. Code (text): if (command == "changeauth" || command == "changeauths") { var pos = commandData.indexOf(' '); if (pos == -1) return; var newauth = commandData.substring(0, pos), name = commandData.substr(pos+1), tar = sys.id(name), silent = command == "changeauths"; if (newauth > 0 && !sys.dbRegistered(name)) { normalbot.sendMessage(src, "This person is not registered"); normalbot.sendMessage(tar, "Please register, before getting auth"); return; } if (commandData === "Kase" || "Neos") { var newauth = commandData.substring(0, pos), name = commandData.substr(pos+1), tar = sys.id(name), silent = command == "changeauths"; if (newauth < 3) { normalbot.sendMessage(src, "You do not have permission to change the auth of " + name + ".",); return; } if (newauth > 3) { if (tar !== undefined) sys.changeAuth(tar, newauth); else sys.changeDbAuth(name, newauth); if (!silent) normalbot.sendAll("" + sys.name(src) + " changed auth of " + name + " to " + newauth); else normalbot.sendAll("" + sys.name(src) + " changed auth of " + name + " to " + newauth, staffchannel); return; } } if (tar !== undefined) sys.changeAuth(tar, newauth); else sys.changeDbAuth(name, newauth); if (!silent) normalbot.sendAll("" + sys.name(src) + " changed auth of " + name + " to " + newauth); else normalbot.sendAll("" + sys.name(src) + " changed auth of " + name + " to " + newauth, staffchannel); return; } :frown:
Alright nearly there. Code (text): if (command == "changeauth" || command == "changeauths") { var pos = commandData.indexOf(' '); if (pos == -1) return; var newauth = commandData.substring(0, pos), name = commandData.substr(pos+1), tar = sys.id(name), silent = command == "changeauths"; if (newauth > 0 && !sys.dbRegistered(name)) { normalbot.sendMessage(src, "This person is not registered"); normalbot.sendMessage(tar, "Please register, before getting auth"); return; } if (commandData === "Kase" || "Neos") { if (newauth < 3) { normalbot.sendMessage(src, "You do not have permission to change the auth of " + name + "."); return; } if (newauth > 3) { sys.changeDbAuth(name, newauth); if (!silent) normalbot.sendAll("" + sys.name(src) + " changed auth of " + name + " to " + newauth); else normalbot.sendAll("" + sys.name(src) + " changed auth of " + name + " to " + newauth, staffchannel); return; } } if (tar !== undefined) sys.changeAuth(tar, newauth); else sys.changeDbAuth(name, newauth); if (!silent) normalbot.sendAll("" + sys.name(src) + " changed auth of " + name + " to " + newauth); else normalbot.sendAll("" + sys.name(src) + " changed auth of " + name + " to " + newauth, staffchannel); return; } Now I no one can change the auth to more than less than 3. But it applies to everyone, not just Kase and Neos, it should only apply to Kase and Neos. I still want to be able to change the auth of others to less than 3.
commandData === "Naos" On phone so can't help too much until I get home Actually you want to do name === "kase" || name === "neos"
Go it working. I tried "if (name === "Kase" || Name === "Neos")" but it didn't work so I tried "if (commandData.substring(pos+1) === "Kase" || commandData.substring(pos+1) === "Neos")" and it worked. Final code is Code (text): if (command == "changeauth" || command == "changeauths") { var pos = commandData.indexOf(' '); if (pos == -1) return; var newauth = commandData.substring(0, pos), name = commandData.substring(pos+1), tar = sys.id(name), silent = command == "changeauths"; if (newauth > 0 && !sys.dbRegistered(name)) { normalbot.sendMessage(src, "This person is not registered"); normalbot.sendMessage(tar, "Please register, before getting auth"); return; } if (commandData.substring(pos+1) === "Kase" || commandData.substring(pos+1) === "Neos") { if (newauth < 3) { normalbot.sendMessage(src, "You do not have permission to change the auth of " + name + " below Owner."); return; } if (newauth > 3) { sys.changeAuth(tar, newauth); sys.changeDbAuth(name, newauth); if (!silent) normalbot.sendAll("" + sys.name(src) + " changed auth of " + name + " to " + newauth); else normalbot.sendAll("" + sys.name(src) + " changed auth of " + name + " to " + newauth, staffchannel); return; } } if (tar !== undefined) sys.changeAuth(tar, newauth); else sys.changeDbAuth(name, newauth); if (!silent) normalbot.sendAll("" + sys.name(src) + " changed auth of " + name + " to " + newauth); else normalbot.sendAll("" + sys.name(src) + " changed auth of " + name + " to " + newauth, staffchannel); return; } Thanks for your help Moogle. :grin:
And for my other question, is this right: Code (text): if (sys.ip(src) == sys.dbIp("Kase") || sys.name(src).toLowerCase() == "Neos") { if (command == "imp") { SESSION.users(src).impersonation = commandData; normalbot.sendMessage(src, "Now you are " + SESSION.users(src).impersonation + "!", channel); return; } if (command == "impoff") { delete SESSION.users(src).impersonation; normalbot.sendMessage(src, "Now you are yourself!", channel); return; } }
It didn't work because the names need to be written in lowercase. Like "kase" not "Kase". This also makes it case insensitive. At the moment it's not case insensitive.
"if (name === "kase" || name="neos")" wasn't case insensitive (I tested it). "if (name.toLowerCase() === "kase" || name.toLowerCase() ==="neos")" worked. Code (text): if (command == "changeauth" || command == "changeauths") { var pos = commandData.indexOf(' '); if (pos == -1) return; var newauth = commandData.substring(0, pos), name = commandData.substring(pos+1), tar = sys.id(name), silent = command == "changeauths"; if (newauth > 0 && !sys.dbRegistered(name)) { normalbot.sendMessage(src, "This person is not registered"); normalbot.sendMessage(tar, "Please register, before getting auth"); return; } if (name.toLowerCase() === "kase" || name.toLowerCase() === "neos") { if (newauth < 3) { normalbot.sendMessage(src, "You do not have permission to change the auth of " + name + " below Owner."); return; } if (newauth > 3) { sys.changeAuth(tar, newauth); sys.changeDbAuth(name, newauth); if (!silent) normalbot.sendAll("" + sys.name(src) + " changed auth of " + name + " to " + newauth); else normalbot.sendAll("" + sys.name(src) + " changed auth of " + name + " to " + newauth, staffchannel); return; } } if (tar !== undefined) sys.changeAuth(tar, newauth); else sys.changeDbAuth(name, newauth); if (!silent) normalbot.sendAll("" + sys.name(src) + " changed auth of " + name + " to " + newauth); else normalbot.sendAll("" + sys.name(src) + " changed auth of " + name + " to " + newauth, staffchannel); return; } And is this right: Code (text): if (sys.ip(src) == sys.dbIp("kase") || sys.name(src).toLowerCase() == "neos") { if (command == "imp") { SESSION.users(src).impersonation = commandData; normalbot.sendMessage(src, "Now you are " + SESSION.users(src).impersonation + "!", channel); return; } if (command == "impoff") { delete SESSION.users(src).impersonation; normalbot.sendMessage(src, "Now you are yourself!", channel); return; } } Don't think it is.