Documentation ¶
Index ¶
- Constants
- Variables
- func ASave()
- func AddUser(user User) bool
- func GetUsersWithSettingAndRun(run func(u User), setting string, values ...string)
- func Load()
- func RemoveUser(identifier string) bool
- func Save()
- type Configuration
- type User
- func (u User) AddPermission(permission string) bool
- func (u User) Destination() string
- func (u User) GetLanguage() string
- func (u User) GetSetting(key string) (string, bool)
- func (u User) HasPermission(permission string) bool
- func (u User) HasSetting(key string) bool
- func (u User) RemovePermission(permission string) bool
- func (u User) RemoveSetting(key string)
- func (u User) SetSetting(key string, value string)
Constants ¶
const ConfigFile = "config.json"
ConfigFile is the configuration file to use.
Variables ¶
var Autosave = flag.BoolP("config-autosave", "s", true, "Don't save config when something is changed.")
Autosave determines if the config should be automatically saved when something is changed.
var IndentConfig = false
IndentConfig determines if the config should be pretty-printed
var NilUser = User{}
NilUser is an empty user type.
Functions ¶
func GetUsersWithSettingAndRun ¶
GetUsersWithSettingAndRun gets the users with the given setting and runs a function for them.
func RemoveUser ¶
RemoveUser removes the given user from the whitelist.
Types ¶
type Configuration ¶
type Configuration struct { Whitelist []User `json:"whitelist"` LastReadPost int `json:"last-read-post"` }
Configuration is the container for a config.
type User ¶
type User struct { UID int `json:"uid"` Name string `json:"name"` Year int `json:"year"` Permissions []string `json:"permissions"` Settings map[string]string `json:"settings"` }
User struct that is used for whitelisted user entries
func GetUserWithName ¶
GetUserWithName gets the User struct that has the given name.
func GetUserWithUID ¶
GetUserWithUID gets the User struct that has the given UID.
func GetUsersWithSetting ¶
GetUsersWithSetting get all the users that have the given setting.
func (User) AddPermission ¶
AddPermission adds the given permission to the user.
func (User) Destination ¶
Destination returns the UID for Telebot.
func (User) GetLanguage ¶
GetLanguage gets the user display language
func (User) GetSetting ¶
GetSetting gets the given setting from the user.
func (User) HasPermission ¶
HasPermission checks if the user has the given permission.
func (User) HasSetting ¶
HasSetting checks if the user has the given setting.
func (User) RemovePermission ¶
RemovePermission removes the given permission from the user.
func (User) SetSetting ¶
SetSetting sets a setting