Documentation ¶
Index ¶
- Variables
- func AddFriendsToOrganization(platform string, platformID string, uuid string) error
- func AddGuildToOrganization(platform string, platformID string, guild string) error
- func AddPlayerToOrganization(platform string, platformID string, uuid string) error
- func CreateAPIClient(key string) *api.Client
- func DeleteFriendsFromOrganization(platform string, platformID string, uuid string) error
- func DeleteGuildFromOrganization(platform string, platformID string, guild string) error
- func DeletePlayerFromOrganization(platform string, platformID string, uuid string) error
- func DeleteUsernames(username string) error
- func EnsureBucketsExist(bucketList []string) error
- func GetFriends(uuid string) (*json.RawMessage, error)
- func GetFriendsList(uuid string) ([]string, error)
- func GetGuild(name string) (*json.RawMessage, error)
- func GetGuildList(name string) ([]string, error)
- func GetGuildNameWithPlayerUUID(uuid string) (string, error)
- func GetGuildWithPlayerUUID(uuid string) (*json.RawMessage, error)
- func GetPlayerStatus(uuid string) (bool, error)
- func GetTrackedList(platform string, platformKey string) ([]string, []string, []string, error)
- func GetUsernamesUUID(username string) (string, error)
- func GuildCreate(s *discordgo.Session, event *discordgo.GuildCreate)
- func ListExistingTopBuckets() error
- func Notify(platform string, channelID string, uuid string, newStatus bool)
- func PutFriends(uuid string) error
- func PutGuild(name string) error
- func PutPlatformOrganization(org PlatformOrganization) error
- func PutUsernames(username string) error
- func SendStatusNotifications(uuid string, newStatus bool) error
- func SetOrganizationChannel(platform string, platformID string, channelID string) error
- func StartBolt(path string) error
- func StartDiscord()
- func StopBolt()
- func ToggleOrganizationNotifications(platform string, platformID string) (bool, error)
- func UpdateFriendGuildLists()
- func UpdateStatuses() error
- func UpdateTrackedPlayerList() error
- func UsernameToUUID(username string) (string, error)
- type PlatformOrganization
Constants ¶
This section is empty.
Variables ¶
var DiscordToken = os.Getenv("DISCORD_TOKEN")
var Dsession *discordgo.Session
var Hclient *api.Client
var Iron *bolt.DB
Functions ¶
func AddFriendsToOrganization ¶
AddFriendsToOrganization appends a new player uuid to the organizations list of tracked friend lists. First, it Gets the proper organization. Then it appends and Puts the new org structure into BoltDB. Returns an error.
func AddGuildToOrganization ¶
AddGuildToOrganization appends a new guild name to the organizations list of tracked guild lists. First, it Gets the proper organization. Then it appends and Puts the new org structure into BoltDB. Returns an error.
func AddPlayerToOrganization ¶
AddPlayerToOrganization appends a new player uuid to the organizations list of tracked players. First, it Gets the proper organization. Then it appends and Puts the new org structure into BoltDB. Returns an error.
func CreateAPIClient ¶
func DeleteFriendsFromOrganization ¶
DeleteFriendsFromOrganization deletes a friend uuid from an organization's list of tracked friend list. Returns an error.
func DeleteGuildFromOrganization ¶
DeleteGuildFromOrganization deletes a guild from an organization's list of tracked guilds. Returns an error.
func DeletePlayerFromOrganization ¶
DeletePlayerFromOrganization deletes a player uuid from an organization's list of tracked players. Returns an error.
func DeleteUsernames ¶
DeleteUsernames deletes the key matching the given username in the "usernames" bucket. Returns an error if anything goes wrong.
func EnsureBucketsExist ¶
EnsureBucketsExist creates buckets in BoltDB if they do not yet exist. Takes a slice of string bucket names. Returns an error if problem occurs.
func GetFriends ¶
func GetFriends(uuid string) (*json.RawMessage, error)
GetFriends retrieves the raw JSON friends response to a UUID. If the database does not have it, GetFriends calls PutFriends() to add it to the database. Returns maybe the *json.RawMessage and error.
func GetFriendsList ¶
GetFriendsList returns a slice of strings with the UUIDs of one player's friends. Returns maybe a string slice and error.
func GetGuild ¶
func GetGuild(name string) (*json.RawMessage, error)
GetGuild retrieves the raw JSON guild response to a guild name. If the database does not have it, GetGuild calls PutGuild() to add it to the database. Returns maybe the *json.RawMessage and error.
func GetGuildList ¶
GetGuildList returns a slice of strings with the UUIDs of one guild's members. Returns maybe a string slice and error.
func GetGuildNameWithPlayerUUID ¶
GetGuildNameWithPlayerUUID
func GetGuildWithPlayerUUID ¶
func GetGuildWithPlayerUUID(uuid string) (*json.RawMessage, error)
GetGuildWithPlayerUUID
func GetPlayerStatus ¶
func GetTrackedList ¶
func GetUsernamesUUID ¶
GetUsernamesUUID gets a uuid from a username in the "usernames" bucket.
func GuildCreate ¶
func GuildCreate(s *discordgo.Session, event *discordgo.GuildCreate)
GuildCreate will be called (due to AddHandler above) every time a new guild is joined. It adds a new PlatformOrganization to BoltDB if this is a new guild.
func ListExistingTopBuckets ¶
func ListExistingTopBuckets() error
ListExistingTopBuckets lists all the top level buckets in the open database to stdout. Returns an error if
func PutFriends ¶
PutFriends fetches the raw JSON friends from the API and stores it in the "friends" bucket. Returns an error.
func PutGuild ¶
PutGuild fetches the raw JSON guild from the API and stores it in the "guilds" bucket. Returns an error.
func PutPlatformOrganization ¶
func PutPlatformOrganization(org PlatformOrganization) error
PutPlatformOrganization puts a PlatformOrganization struct into BoltDB.
func PutUsernames ¶
PutUsernames fetches the UUID associated with a username from the API and puts it in the "usernames" bucket. Returns an error.
func SendStatusNotifications ¶
SendStatusNotifications takes a uuid and new status and sends notifications to all guilds tracking the player directly, or by virtue of friends or guilds.
func SetOrganizationChannel ¶
func StartDiscord ¶
func StartDiscord()
StartDiscord creates the main Discord session, registers commands, and initializes the router. This function can be supplanted by, e.g. StartIRC(), to use a different (or multiple) bot(s). This will require multiple changes to other functions as well.
func StopBolt ¶
func StopBolt()
StopBolt closes the database. This should be deferred in the main application.
func UpdateFriendGuildLists ¶
func UpdateFriendGuildLists()
func UpdateStatuses ¶
func UpdateStatuses() error
func UpdateTrackedPlayerList ¶
func UpdateTrackedPlayerList() error
func UsernameToUUID ¶
UsernameToUUID guarantees returning a UUID from a username if no error occurs. First, it runs GetUsernamesUUID() to use cache in BoltDB. If the username is not in BoltDB, it will Put it there and then Get it.
Types ¶
type PlatformOrganization ¶
type PlatformOrganization struct { Platform string // e.g. “discord” or “text message” PlatformID string // e.g. discord guild id or phone number ~ unique BoltDB ID DefaultChannel string Notifications bool Players []string // slice of players to be notified of Friends []string // slice of players whose friends are to be notified of Guilds []string // slice of guilds whose members are to be notified of Active bool CreatedAt time.Time UpdatedAt time.Time }
PlatformOrganization is the basic structure for each end point (e.g. a Discord group). It stores the settings for that group as well as lists of its tracked entities (players, friend lists, and guilds).
func GetPlatformOrganization ¶
func GetPlatformOrganization(platform string, platformID string) (*PlatformOrganization, error)
GetPlatformOrganization fetches a PlatformOrganization struct from BoltDB.