Futurismobject › bot.user

From Botdom Documentation

Jump to: navigation, search

The bot.user object manages the bot users and privileges and holds the bot user list.

Contents

Properties

  • dict bot.user.list — Holds the bot user list as a dictionary with privclasses in number:name format as key and a list of members as value.

Methods

bool bot.user.add(str username, mixed pc)

Gives a user with username bot priviliges by adding them to the privclass pc (specified as number as int, or str as name or name:number) in the bot username. Removes them from any other privclass they may have been in. Returns True upon success and False if there is no such privclass.

bool bot.user.addprivclass(int number, str name)

Adds a privclass (as key in the user list in "number:name" format) in the bot user list with the inputted number and name. Returns True upon success or False if number was not a digit or if there was spaces in the privclass name (not allowed). A shortcut to this method is bot.user.addpc.

bool bot.user.has(str username, int priv)

Checks if the user with username is in a bot privclass higher than or equal to the privclass number specified in priv. If the user is not on the bot's user list, it has the privilege level 25. The method returns true if the user has the sufficient privileges, False otherwise.

bool bot.user.isreservedpc(mixed pc)

Checks if the inputted privclass pc (specified as number as int, or str as name or name:number) is a reserved privclass, and returns True if it is, and False if it is not. A reserved privclass means that it is non-removable.

void bot.user.load()

Loads the user list from file savedata/users.bsv, and recreates the list from default if malformed.

str bot.user.privclass(mixed priv)

Returns the full name:number format as str from inputted privclass pc (specified as number as int, or str as name or name:number). This is used in many of these methods, to make sure the privclass parameter is flexible, as this method always converts it to something standardized. Method returns bool False if it cannot find a matching privclass. A shortcut to this method is bot.user.pc.

pc = bot.user.privclass("owners")
# pc is: "99:Owners"
pc = bot.user.privclass(50)
# pc is: "50:Members"

bool bot.user.remove(str username)

Removes bot privileges from the user with username by removing them from the user list. Returns True upon success, and False if they weren't present in the user list in the first place.

int bot.user.removeprivclass(mixed pc)

Removes privclass pc (and everyone in it!) from the bot user list, and returns amount users affected (removed) as int, upon success. Method returns bool False if there is no such privclass, or if it is non-removable. A shortcut to this method is bot.user.removepc.

void bot.user.save()

Saves the user list in file savedata/users.bsv, and makes sure the owner of the bot is in the Owners privclass. This method is automatically called at the end of all userlist-manipulating methods, so it does not need to be called manually.

Personal tools