lib package - github.com/World-of-Cryptopups/cordy/lib - Go Packages

lib

package
v0.0.0-...-25ca9aa Latest Latest
Warning

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

Go to latest
Published: May 1, 2023 License: MIT Imports: 15 Imported by: 1

Documentation

Index

Constants

View Source
const (
	LogTypeError = "error"
	LogTypeInfo  = "info"
)
View Source
const (
	LogErrorColor = 15548997
	LogInfoColor  = 3447003
)
View Source
const PupsAboveAll = 35000
View Source
const PupsApocalypse = 20000
View Source
const PupsDoggosOfEternity = 100000
View Source
const PupsDoggosOfInfinity = 60000
View Source
const PupsKnight = 5000
View Source
const PupsOverlord = 10000
View Source
const PupsWarrior = 3000

Variables

View Source
var (
	GUILD      = strings.Split(os.Getenv("GUILD"), ",")
	TOKEN      = os.Getenv("TOKEN")
	DEV        = os.Getenv("DEV") == "true"
	IS_TESTNET = os.Getenv("IS_TESTNET") == "true"

	ADVENTURE_ROLE    = os.Getenv("ADVENTURE_ROLE")
	InitRoles         = strings.Split(os.Getenv("ROLES"), ",")
	ALL_ROLES         = append(InitRoles, ADVENTURE_ROLE)
	MOD_ROLE          = os.Getenv("MOD_ROLE")
	ADMIN_ROLE        = os.Getenv("ADMIN_ROLE")
	VERIFIED_ROLE     = os.Getenv("VERIFIED_ROLE")
	WHITELIST_API     = os.Getenv("GALLERY_WHITELIST_API")
	WHITELIST_API_KEY = os.Getenv("GALLERY_WHITELIST_KEY")
	WEBHOOKLOGS_API   = os.Getenv("WEBHOOK_LOGS")
)
View Source
var AllRoles = []string{
	"Warrior Pups",
	"Knight Pups",
	"Overlord Pups",
	"Pups of the Apocalypse",
	"Pups Above All",
	"Doggos of Infinity",
	"Doggos of Eternity",
}

AllRoles is the list of all available roles for ranking.

View Source
var Atom, _ = atomicassets.NewCustom("https://wax-aa.eosdac.io/atomicassets/v1", &http.Client{})
View Source
var Colors = map[string]string{
	"purple": "#a652bb",
	"blue":   "#3b6fff",
	"cyan":   "#00c09a",
	"green":  "#00d166",
	"gold":   "#fff000",
	"red":    "#e61616",
	"orange": "#ffa500",
	"white":  "#ffffff",
	"grey":   "#95a5a6",
}
View Source
var Roles = map[int]DPSStats{
	PupsWarrior: {
		Title:  "Warrior Pups",
		RoleID: InitRoles[0],
		Color:  "green",
	},
	PupsKnight: {
		Title:  "Knight Pups",
		RoleID: InitRoles[1],
		Color:  "blue",
	},
	PupsOverlord: {
		Title:  "Overlord Pups",
		RoleID: InitRoles[2],
		Color:  "purple",
	},
	PupsApocalypse: {
		Title:  "Pups of the Apocalypse",
		RoleID: InitRoles[3],
		Color:  "red",
	},
	PupsAboveAll: {
		Title:  "Pups Above All",
		RoleID: InitRoles[4],
		Color:  "orange",
	},
	PupsDoggosOfInfinity: {
		Title:  "Doggos of Infinity",
		RoleID: InitRoles[5],
		Color:  "gold",
	},
	PupsDoggosOfEternity: {
		Title:  "Doggos of Eternity",
		RoleID: InitRoles[6],
		Color:  "white",
	},
}

Roles is the roles and

Functions

func Deta

func Deta() *deta.Deta

create new deta instance

func GetBlacklists

func GetBlacklists() ([]string, error)

func GetWhitelists

func GetWhitelists() ([]string, error)

func HandleRole

func HandleRole(session *discordgo.Session, userid string, guildId string, dps int) error

promotes the user with his/her dps stats

func SendLog

func SendLog(sendlog *LogProps)

func StopUser

func StopUser(userid string, wallet string) error

update the user's data from database

func UnlinkUser

func UnlinkUser(userid string, wallet string, userSession UserSession, reason string) error

remove the user from the whitelist remove `Linked Pup` role of user params:

  • userid: user's discord id
  • wallet: users' wallet
  • userExists: checker if user exists or not and use
  • reason: reason user is unlinked, useful for admin dashboard

func UpdateUserData

func UpdateUserData(userid string) error

update the main user's data

func UpdateUserDps

func UpdateUserDps(userid string, dps DPSProps, wallet string) error

updates the user's dps

func UsersBase

func UsersBase() *base.Base

create / fetch the deta base

func UsersDpsBase

func UsersDpsBase() *base.Base

dps info deta base

func WebLoginBase

func WebLoginBase() *base.Base

base on the web login

Types

type DPSItemsProps

type DPSItemsProps struct {
	Real int `json:"real"`
	Raw  int `json:"raw"`
}

type DPSProps

type DPSProps struct {
	PupSkinCards int           `json:"pupskincards"`
	PuppyCards   int           `json:"puppycards"`
	PupItems     DPSItemsProps `json:"pupitems"`
}

type DPSStats

type DPSStats struct {
	Title  string
	RoleID string
	Color  string
}

func GetDPSRoleInfo

func GetDPSRoleInfo(dps int) DPSStats

GetDPSRoleInfo gets the role info for a specific DPS.

type LogProps

type LogProps struct {
	Type        LogType
	Title       string
	Description string
	Message     string
}

type LogType

type LogType string

type User

type User struct {
	Key                  string `json:"key"`
	ID                   string `json:"id"`
	Wallet               string `json:"wallet"`
	Token                string `json:"token"`
	IsStopped            bool   `json:"is_stopped"`
	IsWhitelisted        bool   `json:"is_whitelisted"`
	NotWhitelistedReason string `json:"not_whitelisted_reason"`
}

func GetAllUser

func GetAllUser() ([]User, error)

gets all of the users in db

func GetUser

func GetUser(userid string) (User, bool)

fetch a user, returns a user struct and bool if the user exists

func GetUserWallet

func GetUserWallet(wallet string) ([]User, error)

fetch wallet

type UserDpsProps

type UserDpsProps struct {
	Key       string   `json:"key"`
	ID        string   `json:"id"`
	Dps       DPSProps `json:"dps"`
	Wallet    string   `json:"wallet"`
	IsStopped bool     `json:"is_stopped"`
}

func GetUserDps

func GetUserDps(userid string) (UserDpsProps, error)

get the user's dpds

type UserSession

type UserSession struct {
	Session    *discordgo.Session
	UserExists bool
	GuildID    string
}

type WebLoginUserProps

type WebLoginUserProps struct {
	Key    string `json:"key"`
	Token  string `json:"token"`
	Type   string `json:"type"`
	Wallet string `json:"wallet"`
	Linked bool   `json:"linked,omitempty"`
}

func FetchWebLoginToken

func FetchWebLoginToken(token string) WebLoginUserProps

gets the wallet with the token

type WhitelistResponseProps

type WhitelistResponseProps struct {
	Wallet        string `json:"wallet"`
	TransactionId string `json:"transaction_id"`
}

func AddWhitelist

func AddWhitelist(wallet string) (WhitelistResponseProps, error)

func RemoveWhitelist

func RemoveWhitelist(wallet string) (WhitelistResponseProps, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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