Documentation
¶
Overview ¶
Package model holds types and constants that don't fit in any other specific package, or are DAO functions
Index ¶
- Constants
- Variables
- func LessString(s1, s2 string) bool
- func ParseItemQualityString(q string) int
- func RedactToken(message string) string
- type APIConfig
- type AccessTypeTag
- type AlertByChannelID
- type AucBotContext
- type AucData
- type AucEntries
- type AucEntry
- type AucItem
- type AucMathResult
- type AucMathResults
- type BonusRankResult
- type BuyersGuideResult
- type ChoiceResult
- type GroupResult
- type GroupTreeEntry
- type HTTPAuth
- type Item
- type MultiItemResult
- type OrchestrationPriceResponse
- type OrchestratorPriceAlert
- type OrchestratorPriceMessage
- type PriceAlert
- type PriceResult
- type PriceTreeNode
- type RankedItem
- type Reagent
- type RealmCacheEntry
- type Recipe
- type RecipeResult
- type RecipeVersion
- type SearchableItemCollection
- type ServerMessages
- type ShoppingList
- type ShoppingListOptions
- type SingleItemResult
- type SinglePriceAlert
- type SortableChoiceResultCollection
- type SortableResultCollection
- type ValuationFunctionEntry
- type ValuationOptions
Constants ¶
const ( // AlertTypeLowest is if the price is below the lowest selling price AlertTypeLowest = "LOWEST" // AlertTypePct12 is if the price is below the 12th percent average AlertTypePct12 = "PCT12" )
const BlizzTimeFormatStr = "Mon, 2 Jan 2006 15:04:05 MST"
BlizzTimeFormatStr is the time format used by battle.net in its Last-Modified headers
Variables ¶
var ( NoPendingChoiceErr = fmt.Errorf("no pending choice") HasPendingChoiceErr = fmt.Errorf("has pending choice") )
Functions ¶
func LessString ¶
LessString is an implementation of sort.Less for strings
func ParseItemQualityString ¶
ParseItemQualityString returns the int for a given quality string
func RedactToken ¶
RedactToken removes a token query string from a URI
Types ¶
type AccessTypeTag ¶
type AccessTypeTag string
const ( // GuildTag signifies the bot is in a guild (discord server) GuildTag AccessTypeTag = "g" // ChannelTag signifies the bot is in a channel (discord DM) ChannelTag AccessTypeTag = "c" // APITag signifies the bot is being called from an API APITag AccessTypeTag = "a" )
type AlertByChannelID ¶
type AlertByChannelID map[string][]OrchestratorPriceAlert
type AucBotContext ¶
type AucBotContext struct { Logger *log.Entry RecipeVersion RecipeVersion ContextID string // contains filtered or unexported fields }
AucBotContext holds a request-scoped logger and other config values
func GetMockLogger ¶
func GetMockLogger() *AucBotContext
GetMockLogger returns a logger safe for use in tests that discards all logs
func NewCtx ¶
func NewCtx(recipeVersion RecipeVersion) *AucBotContext
NewCtx creates a new ctx with a new randomized guid
func (*AucBotContext) AcknowledgeQuery ¶
func (a *AucBotContext) AcknowledgeQuery()
AcknowledgeQuery counts a query done in a request. This function is threadsafe.
func (*AucBotContext) GetNumQueries ¶
func (a *AucBotContext) GetNumQueries() int
GetNumQueries returns the number of queries currently counted
type AucData ¶
type AucData struct { Data map[int]AucEntries Realm *RealmCacheEntry LastModified time.Time }
AucData contains auction data from a particular realm and time
func (*AucData) FindItemResult ¶
FindItemResult returns a new AucData filtered to just the given list of itemIDs
func (*AucData) NumActiveItems ¶
NumActiveItems counts the number of individual items (stacks are expanded) currently active in the AucData
type AucEntries ¶
type AucEntries []AucEntry
AucEntries is a sortable collection of Entry
func (AucEntries) Less ¶
func (a AucEntries) Less(i, j int) bool
func (AucEntries) Swap ¶
func (a AucEntries) Swap(i, j int)
type AucEntry ¶
type AucEntry struct { AuctionID int `json:"id"` BidCopper int `json:"bid"` BuyoutCopper int `json:"buyout"` // See: https://us.forums.blizzard.com/en/blizzard/t/world-of-warcraft-api-update-visions-of-nzoth/3461/3 // Unit price is buyout price for commodities // This field should be scanned into and the value migrated to buyout price UnitPriceCopper int `json:"unit_price"` Item AucItem Quantity int TimeLeft string `json:"time_left"` }
AucEntry contains data for one auction.
type AucMathResult ¶
AucMathResult is a single calculation result It contains a printable title, and a pre-formatted value string
type AucMathResults ¶
type AucMathResults struct { TotalQuantity int ActiveAuctions int Results []*AucMathResult }
AucMathResults contain calculations done on a set of auctions
type BonusRankResult ¶
BonusRankResult contains bonus rank information. If the user requested a bonus rank in their result, and if the item has ranks at all.
type BuyersGuideResult ¶
type BuyersGuideResult struct { Root *PriceTreeNode DataLastRefreshed time.Time Extended bool Realm *RealmCacheEntry BonusRank *BonusRankResult }
BuyersGuideResult is the resulting recipe tree of a buyer's guide query, and an extended flag for formatting
type ChoiceResult ¶
type ChoiceResult struct { Item *Item Rank int PriceThreshold int ProfFilter string ActiveAuctions int // used for sorting TotalQuantity int // used for display Token string // used for dynamic editing }
ChoiceResult is choice query information for a single item
type GroupResult ¶
type GroupResult struct { Trees map[string]*GroupTreeEntry DataLastRefreshed time.Time }
GroupResult is the result of a group query, that returns trees keyed by item name
type GroupTreeEntry ¶
type GroupTreeEntry struct {
Node *PriceTreeNode
}
GroupTreeEntry is a nullable PriceTreeNode for a GroupResult
type Item ¶
type Item struct { ID int `json:"id"` Description string `json:"description"` Name string `json:"name"` Icon string `json:"icon"` Stackable int `json:"stackable,omitempty"` ItemBind int `json:"itemBind,omitempty"` BonusStats []interface{} `json:"bonusStats,omitempty"` ItemSpells []interface{} `json:"itemSpells,omitempty"` BuyPrice int `json:"buyPrice,omitempty"` ItemClass int `json:"itemClass,omitempty"` ItemSubClass int `json:"itemSubClass,omitempty"` ContainerSlots int `json:"containerSlots,omitempty"` InventoryType int `json:"inventoryType,omitempty"` Equippable bool `json:"equippable"` ItemLevel int `json:"itemLevel,omitempty"` MaxCount int `json:"maxCount,omitempty"` MaxDurability int `json:"maxDurability,omitempty"` MinFactionID int `json:"minFactionId,omitempty"` MinReputation int `json:"minReputation,omitempty"` Quality int `json:"quality,omitempty"` SellPrice int `json:"sellPrice,omitempty"` RequiredSkill int `json:"requiredSkill,omitempty"` RequiredLevel int `json:"requiredLevel,omitempty"` RequiredSkillRank int `json:"requiredSkillRank,omitempty"` ItemSource struct { SourceID int `json:"sourceId,omitempty"` SourceType string `json:"sourceType,omitempty"` } `json:"itemSource,omitempty"` BaseArmor int `json:"baseArmor,omitempty"` HasSockets bool `json:"hasSockets"` IsAuctionable bool `json:"isAuctionable"` Armor int `json:"armor,omitempty"` DisplayInfoID int `json:"displayInfoId,omitempty"` NameDescription string `json:"nameDescription,omitempty"` NameDescriptionColor string `json:"nameDescriptionColor,omitempty"` Upgradable bool `json:"upgradable"` HeroicTooltip bool `json:"heroicTooltip"` Context string `json:"context,omitempty"` BonusLists []interface{} `json:"bonusLists,omitempty"` AvailableContexts []string `json:"availableContexts,omitempty"` BonusSummary struct { DefaultBonusLists []interface{} `json:"defaultBonusLists,omitempty"` ChanceBonusLists []interface{} `json:"chanceBonusLists,omitempty"` BonusChances []interface{} `json:"bonusChances,omitempty"` } `json:"bonusSummary,omitempty"` ArtifactID int `json:"artifactId,omitempty"` // custom fields IsVendored bool // Rank corresponds to either Shadowlands or Dragonflight+ rank Rank uint8 }
Item is all information known about an item
func (*Item) RarityColor ¶
RarityColor returns the hex value for the item's ingame rarity color (green for uncommon etc)
type MultiItemResult ¶
type MultiItemResult struct { NumItemsQueried int DidTruncate bool TruncatedResults SortableChoiceResultCollection }
MultiItemResult is the result of a query that returned multiple possible items
type OrchestrationPriceResponse ¶
type OrchestrationPriceResponse struct {
Messages []ServerMessages `json:"messages"`
}
OrchestrationPriceResponse contains all messages sent by a single shopping list push
type OrchestratorPriceAlert ¶
type OrchestratorPriceAlert struct { DiscordChannelID string DiscordUserID string AlertType string PriceThreshold int PriceResult *SingleItemResult // these will be duplicated for every item in a db shopping list // but since this is a flat representation of a grouped structure, // we can just use the first one PreviousMessages []string }
OrchestratorPriceAlert is a renderable price alert
type OrchestratorPriceMessage ¶
type OrchestratorPriceMessage struct { Alerts []OrchestratorPriceAlert Message string }
OrchestratorPriceMessage contains a list of alerts to send, and a text message to display instructions
type PriceAlert ¶
type PriceAlert struct { PriceAlertID int ItemID int Rank int PriceThreshold int CreatedOn time.Time LastAlerted time.Time }
PriceAlert represents a single price threshold alert
type PriceResult ¶
type PriceResult struct { Name string Icon string ID int Color int BonusRank *BonusRankResult Results *AucMathResults }
PriceResult is price query information for a single item
type PriceTreeNode ¶
type PriceTreeNode struct { Item *RankedItem Quantity int AHPrice int BGPrice int // cheapest of AHPrice or CheapestRecipe.ComponentPrice, OR the valuation price BGRecommendation string MissingReason string CheapestRecipe *RecipeResult }
PriceTreeNode is a node in a recipe tree each node records its going price on the AH, and also the price of its components ComponentPrice is the sum of all prices in the Components array, and is computed recursively
type RankedItem ¶
RankedItem is an item including a shadowlands legendary rank This rank is derived from bonusIDs/context values TODO this is probably broken, why even support shadowlands anymore...
type Reagent ¶
type Reagent struct { ItemID int `json:"itemID" yaml:"itemID"` Name string `json:"name" yaml:"name"` Count int `json:"count" yaml:"count"` }
Reagent is a single component in a Recipe
type RealmCacheEntry ¶
RealmCacheEntry maps a discord DM or guild to a realm
type Recipe ¶
type Recipe struct { SpellID int `json:"spellID" yaml:"spellID"` ItemID int `json:"itemID" yaml:"itemID"` Name string `json:"name" yaml:"name"` Profession string `json:"profession" yaml:"profession"` Rank int `json:"rank" yaml:"rank"` QuantityCreated int `json:"count" yaml:"count"` Reagents []Reagent `json:"reagents" yaml:"reagents"` // Shadowlands legendary item ilvl rank BonusRank int `json:"bonusRank" yaml:"bonusRank"` }
Recipe contains information about a single item recipe
func (*Recipe) QuantityInRecipe ¶
QuantityInRecipe counts the number of item id found in the recipe.
type RecipeResult ¶
type RecipeResult struct { SpellID int RecipeName string ComponentPrice int RecipeMakes int Profession string Components []*PriceTreeNode ProcModifier bool // true if all components can be acquired, else false CanBeMade bool }
RecipeResult is a subtree that includes recipe information
type RecipeVersion ¶
RecipeVersion are recipes for a patch and iterative version
type SearchableItemCollection ¶
type SearchableItemCollection map[int]struct{}
SearchableItemCollection is a list of items with convenience methods for querying
func (SearchableItemCollection) InCollection ¶
func (h SearchableItemCollection) InCollection(id int) bool
type ServerMessages ¶
ServerMessages contains messageIDs of messages sent as part of a shopping list alert
type ShoppingList ¶
type ShoppingList struct { ShoppingListID int `db:"shopping_list_id"` GuildRealmID int `db:"guild_realm_id"` DiscordChannelID string `db:"discord_channel_id"` DiscordUserID string `db:"discord_user_id"` DiscordUsername string `db:"discord_username"` ActiveMessages []string `db:"active_messages"` Alerts []PriceAlert Options ShoppingListOptions }
type ShoppingListOptions ¶
type ShoppingListOptions struct {
AlertOnly bool
}
type SingleItemResult ¶
type SingleItemResult struct { PriceResult *PriceResult Realm *RealmCacheEntry DataLastRefreshed time.Time }
SingleItemResult is the result of a query that returned a single item
type SinglePriceAlert ¶
type SinglePriceAlert struct { DiscordChannelID string DiscordUserID string ItemID int Rank *int PriceThreshold *int ActiveMessages []string AlertHourly bool }
SinglePriceAlert represents a single price alert for a server and item
type SortableChoiceResultCollection ¶
type SortableChoiceResultCollection []ChoiceResult
SortableChoiceResultCollection is a collection of ChoiceResult sorted by the number of datapoints
func (SortableChoiceResultCollection) Len ¶
func (scr SortableChoiceResultCollection) Len() int
implement sort.Interface
func (SortableChoiceResultCollection) Less ¶
func (scr SortableChoiceResultCollection) Less(i, j int) bool
func (SortableChoiceResultCollection) Swap ¶
func (scr SortableChoiceResultCollection) Swap(i, j int)
type SortableResultCollection ¶
type SortableResultCollection []PriceResult
SortableResultCollection is a collection of PriceResults sorted by the number of datapoints
func (SortableResultCollection) Len ¶
func (sr SortableResultCollection) Len() int
implement sort.Interface
func (SortableResultCollection) Less ¶
func (sr SortableResultCollection) Less(i, j int) bool
func (SortableResultCollection) Swap ¶
func (sr SortableResultCollection) Swap(i, j int)
type ValuationFunctionEntry ¶
ValuationFunctionEntry is a tuple of itemID -> valuation function name
type ValuationOptions ¶
ValuationOptions tell the bgTree how to treat an item involved in valuation If ZeroValue is true, return zero value and nil recipe If craftValue is true, return the item's normal craft ignoring valuation.