Documentation ¶
Index ¶
- type ArgParser
- func (a *ArgParser) AsFloat(index int) (float64, error)
- func (a *ArgParser) AsInt(index int) (int, error)
- func (a *ArgParser) AsIntArray(index int) (arr []int, err error)
- func (a *ArgParser) AsLocation(latIdx, lonIdx int) (l pogo.Location, err error)
- func (a *ArgParser) AsLocationRadius(latIdx, lonIdx, radiusIdx int) (lr pogo.LocationRadius, err error)
- func (a *ArgParser) AsString(index int) (string, error)
- func (a *ArgParser) Count() int
- type Chatter
- type Command
- type CommandCallback
- type Context
- type FilterChange
- type MainController
- type Persister
- type PokemonFilter
- type Poster
- func (p *Poster) ChangeRoomConfig(roomID string, rcChange *RoomConfigChange, newValues *RoomConfig) (err error)
- func (p *Poster) DeleteFilters(roomID string) (deleted bool)
- func (p *Poster) GetRoomConfig(roomID string) (*RoomConfig, bool)
- func (p *Poster) ParseMessage(msg string, context Context) (handled bool, err error)
- func (p *Poster) Run()
- func (p *Poster) UpdateRoomConfig(rcUpdate *RoomConfig) (created bool)
- type RaidState
- type RoomConfig
- type RoomConfigChange
- type RoomConfigOperation
- type RoomState
- type SpawnState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ArgParser ¶
type ArgParser struct {
// contains filtered or unexported fields
}
ArgParser parses elements of an arg list as different types
func NewArgParser ¶
NewArgParser takes an arg list like a string split at every space.
func (*ArgParser) AsIntArray ¶
AsIntArray returns the single value or comma separated values as an array
func (*ArgParser) AsLocation ¶
AsLocation returns a pogo.Location from the given indices
func (*ArgParser) AsLocationRadius ¶
func (a *ArgParser) AsLocationRadius(latIdx, lonIdx, radiusIdx int) (lr pogo.LocationRadius, err error)
AsLocationRadius returns a pogo.LocationRadius from the given indices
type Chatter ¶
type Chatter interface { SendText(roomID, text string) SendFormattedText(roomID, text, formattedText string) }
Chatter posts messages into a chatroom
type Command ¶
type Command struct { // Command without / or ! prefix Command string Callback CommandCallback // accessible by everyone? false=admin only Public bool }
Command is triggered by a line starting with the keyword
type CommandCallback ¶
CommandCallback contains the line triggering it and room context
type Context ¶
type Context struct { Cli *gomatrix.Client // Client pointer Chatter Chatter Poster *Poster Sender string `json:"sender"` // The user ID of the sender of the event Type string `json:"type"` // The event type Timestamp int64 `json:"origin_server_ts"` // The unix timestamp when this message was sent by the origin server ID string `json:"event_id"` // The unique ID of this event RoomID string `json:"room_id"` // The room the event was sent to. May be nil (e.g. for presence) }
Context is the room state description
type FilterChange ¶
type FilterChange int
FilterChange is used to describe what should be done with the existing Filter
const ( // FilterChangeAddPokemon adds pokemon to list FilterChangeAddPokemon FilterChange = iota // FilterChangeRemovePokemon removes pokemon from list FilterChangeRemovePokemon // FilterChangeArea replaces the area FilterChangeArea )
type MainController ¶
type MainController interface {
Stop()
}
MainController stops main when Stop is called
type Persister ¶
type Persister interface { SaveRoomConfig(roomID string, roomConfig *RoomConfig) SaveRoomConfigs(roomConfigs map[string]*RoomConfig) ReadRoomConfigs(roomConfigs map[string]*RoomConfig) SaveRoomState(roomID string, roomState *RoomState) SaveRoomStates(roomStates map[string]*RoomState) ReadRoomStates(roomStates map[string]*RoomState) }
Persister persists states and configs between runs
type PokemonFilter ¶
type PokemonFilter struct { Area pogo.LocationRadius // area to include ListRaids bool // true if this filter only matches raids, false for only spawns ListWanted bool // true if only wanted pokemon ids are in the list, false for unwanted pokemon PokemonIDs []int // pokedex numbers }
PokemonFilter specifies which pokemon in an area should be posted
type Poster ¶
type Poster struct { // data input channels GymUpdates chan pogo.Gym SpawnUpdates chan pogo.Spawn RaidUpdates chan pogo.Raid // control channels Quit chan bool MainControl MainController // pokedex Pokedex *pogo.Pokedex // geodex GeoDex *geodex.GeoDex // read RoomConfigs and States from disk before starting the main loop in Run() ResumeStateOnStartup bool // remove expired spawns and raids from memory ExpiryCheckPeriod time.Duration // contains filtered or unexported fields }
Poster is an agent that posts info from various datasources without user interaction
func (*Poster) ChangeRoomConfig ¶
func (p *Poster) ChangeRoomConfig(roomID string, rcChange *RoomConfigChange, newValues *RoomConfig) (err error)
ChangeRoomConfig edits an existing RoomConfig with the given changeset
func (*Poster) DeleteFilters ¶
DeleteFilters deletes all pokemon filters for a room if a RoomConfig exists
func (*Poster) GetRoomConfig ¶
func (p *Poster) GetRoomConfig(roomID string) (*RoomConfig, bool)
GetRoomConfig returns a copy of the room configuration if there is one
func (*Poster) ParseMessage ¶
ParseMessage processes a single line and calls the callback if it contains a command
func (*Poster) UpdateRoomConfig ¶
func (p *Poster) UpdateRoomConfig(rcUpdate *RoomConfig) (created bool)
UpdateRoomConfig overwrites or adds the RoomConfig and appends the Filter
type RoomConfig ¶
type RoomConfig struct { RoomID string AcceptCommands bool // parse commands from users in this room (admin privileges are checked seperately) FormatText bool Filter []PokemonFilter }
RoomConfig contains settings for a room with one or more people
func (RoomConfig) ToString ¶
func (r RoomConfig) ToString() string
ToString converts RoomConfig into a human-readable string
type RoomConfigChange ¶
type RoomConfigChange struct { ChangeAcceptCommands bool // update RC with value from given RoomConfig ChangeFormatText bool // same as above Operation RoomConfigOperation FilterIndex int // only when UpdateFilter=true FilterChange FilterChange // only when UpdateFilter=true }
RoomConfigChange describes an update operation for an existing RoomConfig
type RoomConfigOperation ¶
type RoomConfigOperation int
RoomConfigOperation describes what should be done in a RoomConfigChange
const ( RoomConfigOperationNone RoomConfigOperation = iota RoomConfigOperationAppendFilter RoomConfigOperationUpdateFilter RoomConfigOperationRemoveFilter )
this flag says what you want to do with the roomconfig
type RoomState ¶
type RoomState struct { // EncounterID -> SpawnState Spawns map[string]*SpawnState // Raid hash -> RaidState Raids map[string]*RaidState }
RoomState keeps track of posted mons
type SpawnState ¶
SpawnState tracks if a spawn was already posted as long as it has not elapsed