RE: Chatango BOT commands 12-12-2013, 06:41 PM
#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 0And 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 0Code:
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]](https://i.imgur.com/BXqGARG.png)










![[+]](https://sinister.li/images/modern/collapse_collapsed.png)