framework

package
v0.0.0-...-168ccef Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 12, 2021 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const ImgurEndpoint = "https://api.imgur.com/3"

Variables

View Source
var (
	AwsSession       *session.Session
	DynamoDBInstance *dynamodb.DynamoDB
	MQDB             MusicQuizDatabase
	PDB              PrefixDatabase
	GBD              GifDatabase
	ImgurToken       string
	ImgurUsername    string
)
View Source
var HttpClient *http.Client

Functions

func AnilistAnimeIDQuery

func AnilistAnimeIDQuery(id int) map[string]string

func AnilistAnimeSearchQuery

func AnilistAnimeSearchQuery(query string) map[string]string

func AnilistMangaSearchQuery

func AnilistMangaSearchQuery(query string) map[string]string

func GetStringValidation

func GetStringValidation(answers []string, guess string) bool

GetStringValidation checks if string is correct

func Getuser

func Getuser(ctx *exrouter.Context) *discordgo.User

func Index

func Index(arr []string, str string) int

Index returns index of str in arr

func LoadImage

func LoadImage(url string) (image.Image, error)

LoadImage from url

func ParseDate

func ParseDate(year, month, day int) string

func RandomString

func RandomString(n int) string

RandomString returns random string at fixed length

func UrlToStruct

func UrlToStruct(url string, target interface{}) error

UrlToStruct loads url json to struct target

Types

type AniListAnimeSearchResponse

type AniListAnimeSearchResponse struct {
	Data struct {
		Media struct {
			IDMal int `json:"idMal"`
			Title struct {
				Romaji        string `json:"romaji"`
				English       string `json:"english"`
				Native        string `json:"native"`
				UserPreferred string `json:"userPreferred"`
			} `json:"title"`
			Type        string `json:"type"`
			Format      string `json:"format"`
			Status      string `json:"status"`
			Description string `json:"description"`
			StartDate   struct {
				Year  int `json:"year"`
				Month int `json:"month"`
				Day   int `json:"day"`
			} `json:"startDate"`
			EndDate struct {
				Year  int `json:"year"`
				Month int `json:"month"`
				Day   int `json:"day"`
			} `json:"endDate"`
			Season     string `json:"season"`
			SeasonYear int    `json:"seasonYear"`
			Episodes   int    `json:"episodes"`
			Source     string `json:"source"`
			CoverImage struct {
				ExtraLarge string `json:"extraLarge"`
				Color      string `json:"color"`
			} `json:"coverImage"`
			Genres       []string `json:"genres"`
			AverageScore int      `json:"averageScore"`
			Studios      struct {
				Edges []struct {
					Node struct {
						IsAnimationStudio bool   `json:"isAnimationStudio"`
						Name              string `json:"name"`
					} `json:"node"`
				} `json:"edges"`
			} `json:"studios"`
			Rankings []struct {
				Rank    int    `json:"rank"`
				Type    string `json:"type"`
				AllTime bool   `json:"allTime"`
			} `json:"rankings"`
			SiteURL string `json:"siteUrl"`
		} `json:"Media"`
	} `json:"data"`
}

type AniListMangaSearchResponse

type AniListMangaSearchResponse struct {
	Data struct {
		Media struct {
			IDMal int `json:"idMal"`
			Title struct {
				Romaji        string `json:"romaji"`
				English       string `json:"english"`
				Native        string `json:"native"`
				UserPreferred string `json:"userPreferred"`
			} `json:"title"`
			Type        string `json:"type"`
			Format      string `json:"format"`
			Status      string `json:"status"`
			Description string `json:"description"`
			StartDate   struct {
				Year  int `json:"year"`
				Month int `json:"month"`
				Day   int `json:"day"`
			} `json:"startDate"`
			EndDate struct {
				Year  int `json:"year"`
				Month int `json:"month"`
				Day   int `json:"day"`
			} `json:"endDate"`
			Volumes    int    `json:"volumes"`
			Chapters   int    `json:"chapters"`
			Source     string `json:"source"`
			CoverImage struct {
				ExtraLarge string `json:"extraLarge"`
				Color      string `json:"color"`
			} `json:"coverImage"`
			Staff struct {
				Edges []struct {
					Node struct {
						Name struct {
							Full string `json:"full"`
						} `json:"name"`
					} `json:"node"`
				} `json:"edges"`
			} `json:"staff"`
			Genres       []string `json:"genres"`
			AverageScore int      `json:"averageScore"`
			Rankings     []struct {
				Rank    int    `json:"rank"`
				Type    string `json:"type"`
				AllTime bool   `json:"allTime"`
			} `json:"rankings"`
			SiteURL string `json:"siteUrl"`
		} `json:"Media"`
	} `json:"data"`
}

type DynamoDBMusicQuizDatabase

type DynamoDBMusicQuizDatabase struct {
	TableName      string
	MusicQuizCache *sync.Map
}

func (*DynamoDBMusicQuizDatabase) CreateScore

func (db *DynamoDBMusicQuizDatabase) CreateScore(id string, score, attempts int)

func (*DynamoDBMusicQuizDatabase) GetScore

func (db *DynamoDBMusicQuizDatabase) GetScore(id string) (int, int)

func (*DynamoDBMusicQuizDatabase) GetScores

func (*DynamoDBMusicQuizDatabase) SetScores

func (db *DynamoDBMusicQuizDatabase) SetScores()

func (*DynamoDBMusicQuizDatabase) UpdateScore

func (db *DynamoDBMusicQuizDatabase) UpdateScore(id string, score, attempts int)

type DynamoDBPrefixDatabase

type DynamoDBPrefixDatabase struct {
	TableName   string
	PrefixCache *sync.Map
}

func (*DynamoDBPrefixDatabase) CheckGuild

func (db *DynamoDBPrefixDatabase) CheckGuild(id string) bool

func (*DynamoDBPrefixDatabase) CreateGuild

func (db *DynamoDBPrefixDatabase) CreateGuild(id, prefix string)

func (*DynamoDBPrefixDatabase) GetGuilds

func (db *DynamoDBPrefixDatabase) GetGuilds() map[string]string

func (*DynamoDBPrefixDatabase) GetPrefix

func (db *DynamoDBPrefixDatabase) GetPrefix(id string) string

func (*DynamoDBPrefixDatabase) RemoveGuild

func (db *DynamoDBPrefixDatabase) RemoveGuild(id string)

func (*DynamoDBPrefixDatabase) SetGuilds

func (db *DynamoDBPrefixDatabase) SetGuilds()

func (*DynamoDBPrefixDatabase) UpdateGuild

func (db *DynamoDBPrefixDatabase) UpdateGuild(id, prefix string)

type GifCacheDatabase

type GifCacheDatabase struct {
	GifCache *sync.Map
}

func (*GifCacheDatabase) CheckDup

func (db *GifCacheDatabase) CheckDup(guildId, hash string) bool

func (*GifCacheDatabase) GetGif

func (db *GifCacheDatabase) GetGif(guildId string) (string, string)

func (*GifCacheDatabase) SetAlbums

func (db *GifCacheDatabase) SetAlbums()

func (*GifCacheDatabase) UploadGif

func (db *GifCacheDatabase) UploadGif(guildId, userId, imgUrl, hash string) error

type GifDatabase

type GifDatabase interface {
	GetGif(string) (string, string)
	UploadGif(string, string, string, string) error
	SetAlbums()
	CheckDup(string, string) bool
}

type GifImage

type GifImage struct {
	ID          string `json:"id"`
	Title       string `json:"title"`
	Description string `json:"description"`
	Link        string `json:"link"`
}

type GifItem

type GifItem struct {
	Data struct {
		ID string `json:"id"`
	} `json:"data"`
	Success bool `json:"success"`
}

type GifItemList

type GifItemList struct {
	ID      string
	Data    []GifImage `json:"data"`
	Success bool       `json:"success"`
}

type GifUpload

type GifUpload struct {
	Data    GifImage `json:"data"`
	Success bool     `json:"success"`
}

type MALAnime

type MALAnime struct {
	URL           string   `json:"url"`
	ImageURL      string   `json:"image_url"`
	OpeningThemes []string `json:"opening_themes"`
	EndingThemes  []string `json:"ending_themes"`
}

type MusicQuizDatabase

type MusicQuizDatabase interface {
	GetScore(string) (int, int)
	UpdateScore(string, int, int)
	CreateScore(string, int, int)
	SetScores()
	GetScores() map[string]MusicQuizEntryTuple
}

type MusicQuizEntry

type MusicQuizEntry struct {
	UserId        string
	MusicScore    int
	TotalAttempts int
}

type MusicQuizEntryTuple

type MusicQuizEntryTuple struct {
	MusicScore    int
	TotalAttempts int
}

type PrefixDatabase

type PrefixDatabase interface {
	CreateGuild(string, string)
	UpdateGuild(string, string)
	RemoveGuild(string)
	GetPrefix(string) string
	CheckGuild(string) bool
	SetGuilds()
	GetGuilds() map[string]string
}

type PrefixEntry

type PrefixEntry struct {
	GuildId string
	Prefix  string
}

type TraceSearchResult

type TraceSearchResult struct {
	Data struct {
		Media struct {
			Title struct {
				UserPreferred string `json:"userPreferred"`
			} `json:"title"`
			CoverImage struct {
				ExtraLarge string `json:"extraLarge"`
				Color      string `json:"color"`
			} `json:"coverImage"`
		} `json:"Media"`
	} `json:"data"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL