Login Register






Tutorial Chatango BOT commands filter_list
Author
Message
RE: Chatango BOT commands #4
(12-12-2013, 07:15 AM)Satan Wrote: Is it possible to adapt something like this, built with py, for use with multiple people, such as users with different levels of permissions on what they can use? And how would one set that up?

Above the onMessage you would put

Code:
def getAccess(self, user): if user.name.lower() == "username here": return 1 if user.name.lower() == "username here": return 1 else: return 0

And if you want to make a command permission specific you would put

Code:
elif used_prefix and cmd=="cmdhere": if self.getAccess(user) == 1: ~stuffs here~ else: room.message("No permission.")

Here's a few examples from my bot:

Code:
def getAccess(self, user): if user.name in blacklist: return 3 if user.name.lower() == "duubz": return 2 if user.name.lower() == "fecks": return 2 if user.name in whitelist: return 1 else: return 0
Code:
elif used_prefix and cmd=="kill": if self.getAccess(user) == 2: print("[INFO][DATA][CMD]Saved data: Nicknames") f= open("nicks.txt","w") for user in nicks: nick = json.loads(nicks[user]) f.write(json.dumps([user,nick])+"\n") f.close f = open("whitelist.txt", "w") f.write("\n".join(whitelist)) f.close() f = open("blacklist.txt","w") f.write("\n".join(blacklist)) f.close() time.sleep(1) self.stop() f = open("rooms.txt","w") f.write("\n".join(rooms)) f.close() else: room.message("Kill command failed. Insufficient permissions.")
[Image: BXqGARG.png]






Messages In This Thread
Chatango BOT commands - by Equinox - 11-24-2013, 05:09 PM
RE: Chatango BOT commands - by Equinox - 12-12-2013, 07:12 AM
RE: Chatango BOT commands - by Satan - 12-12-2013, 07:15 AM
RE: Chatango BOT commands - by Equinox - 12-12-2013, 06:41 PM
RE: Chatango BOT commands - by Satan - 12-12-2013, 06:44 PM
RE: Chatango BOT commands - by Equinox - 12-12-2013, 07:02 PM
RE: Chatango BOT commands - by Equinox - 12-13-2013, 04:55 AM