Documentation ¶
Index ¶
- Variables
- func Connect(host, user, dbname, password string)
- func Count(body, mention string) string
- func FormatCounts(counts map[*Mapper]uint) string
- func GenSecret() string
- func GetCounts(mappers []*Mapper) map[*Mapper]uint
- func GetTokens(input string) []string
- func HasMapper(mappers map[*Mapper]uint, key string) bool
- func HasMapset(mapsets []*Mapset, key *Mapset) bool
- func List(user *User, mention string) string
- func NotificationPlatform(user *User, body, mention string) string
- func NotificationPreference(user *User, body, mention string) string
- func Purge(user *User, mention string) string
- func Subscribe(user *User, body, mention string) string
- func Top(body string) string
- func TopCounts(n int) map[*Mapper]uint
- func Unsubscribe(user *User, body, mention string) string
- type Mapper
- type Mapset
- type Subscription
- type User
Constants ¶
This section is empty.
Variables ¶
var ( // HelpURL is a link to the command reference. HelpURL = "https://github.com/christopher-dG/gosubscribe#command-reference" // ServerURL is an invite to the Discord server. ServerURL = "https://discord.gg/qaUhTKJ" // InviteURL is a link to invite subscription-bot to another server. InviteURL = "https://discordapp.com/oauth2/authorize?client_id=305550679538401280&scope=bot&permissions=3072" // OsuUserURL is a link to the bot's userpage. OsuUserURL = "https://osu.ppy.sh/users/3172543" )
var DB *gorm.DB
DB (the database instance) cannot be used before Connect is called.
Functions ¶
func Connect ¶
func Connect(host, user, dbname, password string)
Connect connects to a given PostreSQL database. PGxxx environment variables must be set.
func FormatCounts ¶
FormatCounts converts a mapper -> subscriber count mapping to an evenly spaced table, ordering the counts in descending order.
func GenSecret ¶
func GenSecret() string
GenSecret generates a "random" string that is guaranteed to not already be used. Note: This is not even remotely cryptographically secure, but it'll do for our needs.
func GetTokens ¶
GetTokens splits a comma-delimited string into tokens and returns the unique ones in sorted order.
func HasMapper ¶
HasMapper determines whether or not the map contains a mapper key with the given name.
func NotificationPlatform ¶
NotificationPlatform sets the user's platform preference for receiving notifications.
func NotificationPreference ¶
NotificationPreference sets the users preference for receiving notifications for map updates that are not new uploads or ranked status changes.
func TopCounts ¶
TopCounts gets the n mappers with the most subscribers and their subscription counts.
func Unsubscribe ¶
Unsubscribe unsubscribes the user from the given mappers.
Types ¶
type Mapper ¶
type Mapper struct { ID uint `json:"user_id,string"` Username string `gorm:"not null" json:"username"` }
Mapper is an osu! user.
func GetMapper ¶
GetMapper gets a mapper from the osu! API and adds it to the database if necessary.
func MapperFromDB ¶
MapperFromDB gets a mapper from the database.
func (*Mapper) GetMapsets ¶
GetMapsets gets all mapsets by the mapper. This will contain duplicates (multiple diffs per set).
type Mapset ¶
type Mapset struct { ID uint `json:"beatmapset_id,string"` MapperID uint `json:"-"` // Need to fill this field manually. Status int `json:"approved,string"` Updated string `json:"last_update"` }
Mapset is an osu! beatmapset.
type Subscription ¶
Subscription is a relationship between a User and Mapper.
type User ¶
type User struct { ID uint DiscordID sql.NullInt64 `gorm:"unique;index"` OsuUsername sql.NullString `gorm:"unique;index"` Secret string `gorm:"unique"` NotifyAll bool MessageOsu bool }
User is a gosubscribe user.
func UserFromSecret ¶
UserFromSecret retrieves a user from their unique secret.
func (*User) ListSubscribed ¶
ListSubscribed gets all mappers that a user is subscribed to.
func (*User) SetMessageOsu ¶
SetMessageOsu sets the user's preference for receiving messages via osu! or via Discord.
func (*User) SetNotifyAll ¶
SetNotifyAll sets the users preference for receiving notifications for map updates that are not new uploads or ranked status changes.
func (*User) Unsubscribe ¶
Unsubscribe unsubscribes a user from a list of mappers.