Documentation ¶
Overview ¶
Package bouncerbot implements the bouncer bot.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("user info not found")
ErrNotFound is returned by a Decrypter if the key did not decrypt any info.
Functions ¶
This section is empty.
Types ¶
type Bot ¶
type Bot struct { *discordgo.Session // If left blank, this info is set when the first user joins the server. Currently the bot does // not support serving more than one guild. Guild *GuildInfo // contains filtered or unexported fields }
Bot assigns roles to users once they send the correct code to the bot in a DM. The correct code is determined by attempting to decrypt the names in the database using the code as the key. If the decryption is successful, the user is given the name as a server nickname and the appropriate roles are assigned.
func New ¶
New creates a new bouncer bot using the provided bot token, backed by the provided UserTable.
func NewWithDecrypter ¶
NewWithDecrypter sets up the bot using the provided Decrypter, instead of the default Decrypter backed with a db.UserTable.
func (*Bot) AddGuildInfoCallback ¶
AddGuildInfoCallback ensures f will be called when the b.Guild is filled in.
type Decrypter ¶
type Decrypter interface { // Decrypt attempts to decrypt any user info using the key provided. It returns ErrNotFound if // the key did not decrypt anything. Decrypt(key string) (*db.User, error) // Delete removes the user info after it's been decrypted and used. It should be called only // after the successful use of data returned by Decrypt. Delete(id int) error }
Decrypter provides user information conditioned on receiving the decryption key for it.
type GuildInfo ¶
type GuildInfo struct { GuildID string `json:"guild_id"` ProfessorRole string `json:"professor_role"` TARole string `json:"ta_role"` StudentLeadershipRole string `json:"student_leadership_role"` AlumniBoardRole string `json:"alumni_board_role"` NewbieRole string `json:"newbie_role"` PreACMERole string `json:"preacme_role"` RolesByYear map[int]string `json:"roles_by_year"` }
GuildInfo contains IDs necessary for the bot to interact with roles and users in the guild.
func GetGuildInfo ¶
GetGuildInfo collects the guild information using the discordgo session.
type TableDecrypter ¶
TableDecrypter implements Decrypter by using the key to attempt to decrypt all the users in the database.
func (TableDecrypter) Delete ¶ added in v0.1.2
func (d TableDecrypter) Delete(id int) error