Documentation
¶
Overview ¶
Package amebas é o SDK oficial do bot de sala do Amebas Arena: o cliente do WebSocket /v1/rooms/{roomId}/bot, com auth pela primeira mensagem, eventos tipados (OnChatMessage, OnPlayerJoined...), comandos que esperam o result e reconexão com espera crescente. Os tipos saem de protocol/bot-protocol.schema.json (go generate).
Index ¶
- Constants
- Variables
- func BotURL(baseURL, roomID string) (string, error)
- func FormatWait(d time.Duration) string
- type AdminCommand
- type Arg
- type AuthMessage
- type AutoCommand
- type BanCommand
- type BanCommandScope
- type Bot
- func (b *Bot) Admin(ctx context.Context, cmd AdminCommand) error
- func (b *Bot) Auto(ctx context.Context, cmd AutoCommand) error
- func (b *Bot) Ban(ctx context.Context, cmd BanCommand) error
- func (b *Bot) Bot(ctx context.Context, cmd BotCommand) error
- func (b *Bot) Bots(ctx context.Context, cmd BotsCommand) error
- func (b *Bot) Captain(ctx context.Context, cmd CaptainCommand) error
- func (b *Bot) Chat(ctx context.Context, cmd ChatCommand) error
- func (b *Bot) Command(name string, define Cmd, handler Handler)
- func (b *Bot) Config(ctx context.Context, cmd ConfigCommand) error
- func (b *Bot) Confirm(ctx context.Context, cmd ConfirmCommand) error
- func (b *Bot) Finish(ctx context.Context, cmd FinishCommand) error
- func (b *Bot) Kick(ctx context.Context, cmd KickCommand) error
- func (b *Bot) Knockout(ctx context.Context, cmd KnockoutCommand) error
- func (b *Bot) Lock(ctx context.Context, cmd LockCommand) error
- func (b *Bot) Move(ctx context.Context, cmd MoveCommand) error
- func (b *Bot) Mute(ctx context.Context, cmd MuteCommand) error
- func (b *Bot) OnChatMessage(fn func(ChatMessageEvent))
- func (b *Bot) OnError(fn func(ErrorMessage))
- func (b *Bot) OnEvent(fn func(eventType string, raw json.RawMessage))
- func (b *Bot) OnMatchEnded(fn func(MatchEndedEvent))
- func (b *Bot) OnMatchEvent(fn func(MatchEventEvent))
- func (b *Bot) OnMatchStarted(fn func(MatchStartedEvent))
- func (b *Bot) OnPlayerJoined(fn func(PlayerJoinedEvent))
- func (b *Bot) OnPlayerLeft(fn func(PlayerLeftEvent))
- func (b *Bot) OnReady(fn func(ReadyMessage))
- func (b *Bot) OnRoomConfig(fn func(RoomConfigEvent))
- func (b *Bot) OnRoomLive(fn func(RoomLiveEvent))
- func (b *Bot) OnRoomOff(fn func(RoomOffEvent))
- func (b *Bot) OnRuleFired(fn func(RuleFiredEvent))
- func (b *Bot) OnScriptLog(fn func(ScriptLogEvent))
- func (b *Bot) OnScriptStopped(fn func(ScriptStoppedEvent))
- func (b *Bot) Pause(ctx context.Context, cmd PauseCommand) error
- func (b *Bot) Pick(ctx context.Context, cmd PickCommand) error
- func (b *Bot) Ready() bool
- func (b *Bot) Restart(ctx context.Context, cmd RestartCommand) error
- func (b *Bot) Run(ctx context.Context) error
- func (b *Bot) Say(ctx context.Context, text string) error
- func (b *Bot) Send(ctx context.Context, cmd any) error
- func (b *Bot) SetCommandDefaults(d Defaults)
- func (b *Bot) Shuffle(ctx context.Context, cmd ShuffleCommand) error
- func (b *Bot) Start(ctx context.Context, cmd StartCommand) error
- func (b *Bot) Stop(ctx context.Context, cmd StopCommand) error
- func (b *Bot) Team(ctx context.Context, cmd TeamCommand) error
- type BotCommand
- type BotCommandTeam
- type BotsCommand
- type BotsCommandAction
- type CaptainCommand
- type CaptainCommandTeam
- type ChatCommand
- type ChatMessageEvent
- type ChatMessageEventPlayer
- type ChatMessageEventPlayer_0
- type ChatMessageEventRole
- type ClientMessage
- type Cmd
- type CommandPlayer
- type Commands
- func (c *Commands) Add(name string, define Cmd, handler Handler) error
- func (c *Commands) Dispatch(ctx context.Context, in MatchInput, reply func(string)) (bool, error)
- func (c *Commands) Match(in MatchInput) *Decision
- func (c *Commands) SetDefaults(d Defaults)
- func (c *Commands) Triggers() []string
- type ConfigCommand
- type ConfigCommandPassword_0
- type ConfirmCommand
- type Ctx
- func (c *Ctx) Bool(name string) bool
- func (c *Ctx) Has(name string) bool
- func (c *Ctx) Int(name string) int
- func (c *Ctx) Number(name string) float64
- func (c *Ctx) Person(name string) *Person
- func (c *Ctx) Reply(text string)
- func (c *Ctx) Team(name string) string
- func (c *Ctx) Text(name string) string
- type Decision
- type Defaults
- type Error
- type ErrorMessage
- type FinishCommand
- type Handler
- type HostBot
- type HostBotAfk
- type HostBotAfkAction
- type HostBotChatRules
- type HostBotChatRulesAction
- type HostBotNotices
- type HostBotWelcome
- type HostedRoom
- type HostedRoomConfig
- type HostedRoomConfigFormat
- type HostedRoomConfigFormatParams
- type HostedRoomConfigGameplay
- type HostedRoomConfigInput
- type HostedRoomConfigInputFormat
- type HostedRoomConfigInputFormatParams
- type HostedRoomConfigInputGameplay
- type HostedRoomConfigInputMode
- type HostedRoomConfigInputModeParams
- type HostedRoomConfigMode
- type HostedRoomConfigModeParams
- type HostedRoomDesired
- type HostedRoomHostBot
- type HostedRoomHostBot_0
- type HostedRoomLive
- type HostedRoomLive_0
- type HostedRoomLive_0Address
- type HostedRoomPaidUntil_0
- type HostedRoomPlan
- type HostedRoomRules
- type HostedRoomRules_0
- type HostedRoomScript
- type HostedRoomScript_0
- type HostedRoomStatus
- type HostedRoomTeams
- type HostedRoomTeams_0
- type KickCommand
- type KnockoutCommand
- type KnockoutCommandAction
- type LivePlayer
- type LivePlayerAccountID
- type LivePlayerConnection
- type LivePlayerPlace
- type LiveRoom
- type LiveRoomAddress
- type LiveRoomPhase
- type LiveRoomScore
- type LockCommand
- type Match
- type MatchEndedEvent
- type MatchEventEvent
- type MatchEventEventEvent
- type MatchEventEventPlayer
- type MatchEventEventPlayer_0
- type MatchEventEventTeam_0
- type MatchFormat
- type MatchHostedRoomID
- type MatchInput
- type MatchMap
- type MatchPlayersElem
- type MatchPlayersElemAccountID
- type MatchPlayersElemOutcome_0
- type MatchPlayersElemStats
- type MatchPlayersElemTeam
- type MatchStartedEvent
- type Messages
- type MoveCommand
- type MoveCommandTo
- type MuteCommand
- type Options
- type ParseInput
- type PauseCommand
- type Permission
- type Person
- type PickCommand
- type PickCommandKeyword
- type PlayerJoinedEvent
- type PlayerLeftEvent
- type PlayerLeftEventReason
- type PlayerRef
- type PlayerRefAccountID
- type ReadyMessage
- type ReadyMessageLive
- type ReadyMessageLive_0
- type RestartCommand
- type ResultMessage
- type Role
- type RoomCommand
- type RoomConfigEvent
- type RoomEvent
- type RoomLiveEvent
- type RoomLiveEventAddress
- type RoomOffEvent
- type RoomOffEventReason
- type RoomRules
- type RoomScript
- type RoomTeams
- type Rule
- type RuleAction
- type RuleCondition
- type RuleFiredEvent
- type RuleFiredEventActionsElem
- type RuleFiredEventPlayer
- type RuleFiredEventPlayer_0
- type RuleFiredEventRule
- type RuleTrigger
- type ScriptLogEvent
- type ScriptStoppedEvent
- type ScriptStoppedEventReason
- type ServerMessage
- type ShuffleCommand
- type StartCommand
- type StopCommand
- type TeamCommand
- type TeamCommandColors
- type TeamCommandTeam
- type TeamStyle
- type TeamStyleColors
- type UsageError
Constants ¶
const ( // AuthTimeoutMs: sem auth nesse prazo, o servidor fecha com CloseUnauthorized. AuthTimeoutMs = 10000 // RateLimitBurst e RateLimitPerSecond: o balde de comandos por conexão. RateLimitBurst = 20 RateLimitPerSecond = 5 CloseInvalidRoom = 4004 )
As regras do canal (x-amebas-bot do schema).
const NoCooldown time.Duration = -1
NoCooldown no Cooldown (ou no RoomCooldown) tira a espera que veio dos padrões. Zero herda o padrão.
Variables ¶
var ErrNotCounted = errors.New("amebas: comando não contou")
ErrNotCounted: o handler não "usou" o comando, então o cooldown não começa.
Functions ¶
func BotURL ¶
BotURL monta a URL do WebSocket a partir do endereço da API (http vira ws, https vira wss; o prefixo /api fica).
func FormatWait ¶
FormatWait: 9s, 1min, 1min 5s (sempre arredondando pra cima: "espere 1s" e não "0s").
Types ¶
type AdminCommand ¶
type AdminCommand struct {
// Admin corresponds to the JSON schema field "admin".
Admin bool `json:"admin"`
// O id do jogador nesta sala, informado nos eventos e no estado ao vivo. O id
// muda se o jogador sair e voltar.
PlayerID int `json:"playerId"`
// Type corresponds to the JSON schema field "type".
Type string `json:"type"`
}
type Arg ¶
type Arg struct {
Name string
Spec string
// por extenso (quando Spec está vazio)
Type string // int, number, text, rest, bool, player, team ou choice
Min, Max *float64
Choices []string
Optional bool
Default any
}
Arg é um argumento do comando. O caso simples é A("n", "int:1..20"); o por extenso usa Type, Min, Max...
Forma curta: tipo[:faixa][?|=padrão]. int, int:1..20, int:1.., int:..10, number:0..1, text, text:3..16, rest (o resto da linha, por último), bool, player (#id, @nick, nick ou começo do nick), team (a ou b) e opções como azul|vermelho. "?" deixa opcional (vem nil); "=5" dá o padrão.
type AuthMessage ¶
type AutoCommand ¶
type AutoCommand struct {
// Type corresponds to the JSON schema field "type".
Type string `json:"type"`
}
type BanCommand ¶
type BanCommand struct {
// O id do jogador nesta sala, informado nos eventos e no estado ao vivo. O id
// muda se o jogador sair e voltar.
PlayerID int `json:"playerId"`
// Scope corresponds to the JSON schema field "scope".
Scope BanCommandScope `json:"scope,omitempty,omitzero"`
// Type corresponds to the JSON schema field "type".
Type string `json:"type"`
}
type BanCommandScope ¶
type BanCommandScope string
const BanCommandScopeCommunity BanCommandScope = "community"
const BanCommandScopeRoom BanCommandScope = "room"
type Bot ¶
type Bot struct {
// Commands é o sistema de comandos do chat (!gols...): Command e SetCommandDefaults usam este.
Commands *Commands
// contains filtered or unexported fields
}
Bot é a conexão de um bot com uma sala. Os handlers rodam na goroutine de leitura, um de cada vez: handler que demora segura os próximos eventos (mande comandos de outra goroutine se precisar esperar o result).
func (*Bot) Admin ¶
func (b *Bot) Admin(ctx context.Context, cmd AdminCommand) error
Admin manda o comando "admin" e espera o result (o Type é preenchido aqui).
func (*Bot) Auto ¶
func (b *Bot) Auto(ctx context.Context, cmd AutoCommand) error
Auto manda o comando "auto" e espera o result (o Type é preenchido aqui).
func (*Bot) Ban ¶
func (b *Bot) Ban(ctx context.Context, cmd BanCommand) error
Ban manda o comando "ban" e espera o result (o Type é preenchido aqui).
func (*Bot) Bot ¶
func (b *Bot) Bot(ctx context.Context, cmd BotCommand) error
Bot manda o comando "bot" e espera o result (o Type é preenchido aqui).
func (*Bot) Bots ¶
func (b *Bot) Bots(ctx context.Context, cmd BotsCommand) error
Bots manda o comando "bots" e espera o result (o Type é preenchido aqui).
func (*Bot) Captain ¶
func (b *Bot) Captain(ctx context.Context, cmd CaptainCommand) error
Captain manda o comando "captain" e espera o result (o Type é preenchido aqui).
func (*Bot) Chat ¶
func (b *Bot) Chat(ctx context.Context, cmd ChatCommand) error
Chat manda o comando "chat" e espera o result (o Type é preenchido aqui).
func (*Bot) Command ¶
Command registra um comando do chat. O caso simples cabe numa linha; arg errado, cooldown e permissão respondem sozinhos:
bot.Command("regras", amebas.Cmd{}, func(c *amebas.Ctx) error { c.Reply("Sem xingar."); return nil })
bot.Command("gols", amebas.Cmd{Args: amebas.Args("n", "int:1..20"), Cooldown: 10 * time.Second, Permission: amebas.PermissionStaff}, ...)
Erro de define (tipo que não existe, faixa torta) dá panic na hora, com o que está errado e o jeito certo.
func (*Bot) Config ¶
func (b *Bot) Config(ctx context.Context, cmd ConfigCommand) error
Config manda o comando "config" e espera o result (o Type é preenchido aqui).
func (*Bot) Confirm ¶
func (b *Bot) Confirm(ctx context.Context, cmd ConfirmCommand) error
Confirm manda o comando "confirm" e espera o result (o Type é preenchido aqui).
func (*Bot) Finish ¶
func (b *Bot) Finish(ctx context.Context, cmd FinishCommand) error
Finish manda o comando "finish" e espera o result (o Type é preenchido aqui).
func (*Bot) Kick ¶
func (b *Bot) Kick(ctx context.Context, cmd KickCommand) error
Kick manda o comando "kick" e espera o result (o Type é preenchido aqui).
func (*Bot) Knockout ¶
func (b *Bot) Knockout(ctx context.Context, cmd KnockoutCommand) error
Knockout manda o comando "knockout" e espera o result (o Type é preenchido aqui).
func (*Bot) Lock ¶
func (b *Bot) Lock(ctx context.Context, cmd LockCommand) error
Lock manda o comando "lock" e espera o result (o Type é preenchido aqui).
func (*Bot) Move ¶
func (b *Bot) Move(ctx context.Context, cmd MoveCommand) error
Move manda o comando "move" e espera o result (o Type é preenchido aqui).
func (*Bot) Mute ¶
func (b *Bot) Mute(ctx context.Context, cmd MuteCommand) error
Mute manda o comando "mute" e espera o result (o Type é preenchido aqui).
func (*Bot) OnChatMessage ¶
func (b *Bot) OnChatMessage(fn func(ChatMessageEvent))
OnChatMessage escuta o evento "chat.message".
func (*Bot) OnError ¶
func (b *Bot) OnError(fn func(ErrorMessage))
OnError escuta o error que o servidor manda (auth recusada, JSON inválido).
func (*Bot) OnEvent ¶
func (b *Bot) OnEvent(fn func(eventType string, raw json.RawMessage))
OnEvent escuta todo evento da sala, cru: o type e o JSON inteiro (os que o SDK ainda não conhece também chegam).
func (*Bot) OnMatchEnded ¶
func (b *Bot) OnMatchEnded(fn func(MatchEndedEvent))
OnMatchEnded escuta o evento "match.ended".
func (*Bot) OnMatchEvent ¶
func (b *Bot) OnMatchEvent(fn func(MatchEventEvent))
OnMatchEvent escuta o evento "match.event".
func (*Bot) OnMatchStarted ¶
func (b *Bot) OnMatchStarted(fn func(MatchStartedEvent))
OnMatchStarted escuta o evento "match.started".
func (*Bot) OnPlayerJoined ¶
func (b *Bot) OnPlayerJoined(fn func(PlayerJoinedEvent))
OnPlayerJoined escuta o evento "player.joined".
func (*Bot) OnPlayerLeft ¶
func (b *Bot) OnPlayerLeft(fn func(PlayerLeftEvent))
OnPlayerLeft escuta o evento "player.left".
func (*Bot) OnReady ¶
func (b *Bot) OnReady(fn func(ReadyMessage))
OnReady escuta a auth aceita (a cada conexão, inclusive depois de reconectar), com a sala e o estado ao vivo.
func (*Bot) OnRoomConfig ¶
func (b *Bot) OnRoomConfig(fn func(RoomConfigEvent))
OnRoomConfig escuta o evento "room.config".
func (*Bot) OnRoomLive ¶
func (b *Bot) OnRoomLive(fn func(RoomLiveEvent))
OnRoomLive escuta o evento "room.live".
func (*Bot) OnRoomOff ¶
func (b *Bot) OnRoomOff(fn func(RoomOffEvent))
OnRoomOff escuta o evento "room.off".
func (*Bot) OnRuleFired ¶
func (b *Bot) OnRuleFired(fn func(RuleFiredEvent))
OnRuleFired escuta o evento "rule.fired".
func (*Bot) OnScriptLog ¶
func (b *Bot) OnScriptLog(fn func(ScriptLogEvent))
OnScriptLog escuta o evento "script.log".
func (*Bot) OnScriptStopped ¶
func (b *Bot) OnScriptStopped(fn func(ScriptStoppedEvent))
OnScriptStopped escuta o evento "script.stopped".
func (*Bot) Pause ¶
func (b *Bot) Pause(ctx context.Context, cmd PauseCommand) error
Pause manda o comando "pause" e espera o result (o Type é preenchido aqui).
func (*Bot) Pick ¶
func (b *Bot) Pick(ctx context.Context, cmd PickCommand) error
Pick manda o comando "pick" e espera o result (o Type é preenchido aqui).
func (*Bot) Restart ¶
func (b *Bot) Restart(ctx context.Context, cmd RestartCommand) error
Restart manda o comando "restart" e espera o result (o Type é preenchido aqui).
func (*Bot) Run ¶
Run conecta e fica no ar até o ctx acabar (devolve nil) ou o bot parar de vez: auth recusada, sala inválida ou tentativas esgotadas (devolve o *Error). Caiu por outro motivo, volta sozinho com espera crescente.
func (*Bot) Send ¶
Send manda um comando da sala (qualquer struct XxxCommand, com o Type preenchido) e espera o result: nil com ok, *Error com o code do servidor (invalid, permission, rate_limited...). Os métodos gerados (Chat, Kick...) preenchem o Type.
func (*Bot) SetCommandDefaults ¶
SetCommandDefaults define os padrões de todos os comandos (a define de cada um sobrescreve).
func (*Bot) Shuffle ¶
func (b *Bot) Shuffle(ctx context.Context, cmd ShuffleCommand) error
Shuffle manda o comando "shuffle" e espera o result (o Type é preenchido aqui).
func (*Bot) Start ¶
func (b *Bot) Start(ctx context.Context, cmd StartCommand) error
Start manda o comando "start" e espera o result (o Type é preenchido aqui).
type BotCommand ¶
type BotCommand struct {
// Delta corresponds to the JSON schema field "delta".
Delta interface{} `json:"delta"`
// Slot corresponds to the JSON schema field "slot".
Slot *int `json:"slot,omitempty,omitzero"`
// Team corresponds to the JSON schema field "team".
Team BotCommandTeam `json:"team"`
// Type corresponds to the JSON schema field "type".
Type string `json:"type"`
}
type BotCommandTeam ¶
type BotCommandTeam string
const BotCommandTeamA BotCommandTeam = "a"
const BotCommandTeamB BotCommandTeam = "b"
type BotsCommand ¶
type BotsCommand struct {
// Action corresponds to the JSON schema field "action".
Action BotsCommandAction `json:"action"`
// Type corresponds to the JSON schema field "type".
Type string `json:"type"`
}
type BotsCommandAction ¶
type BotsCommandAction string
const BotsCommandActionClear BotsCommandAction = "clear"
const BotsCommandActionFill BotsCommandAction = "fill"
type CaptainCommand ¶
type CaptainCommand struct {
// O id do jogador nesta sala, informado nos eventos e no estado ao vivo. O id
// muda se o jogador sair e voltar.
PlayerID int `json:"playerId"`
// Team corresponds to the JSON schema field "team".
Team CaptainCommandTeam `json:"team"`
// Type corresponds to the JSON schema field "type".
Type string `json:"type"`
}
type CaptainCommandTeam ¶
type CaptainCommandTeam string
const CaptainCommandTeamA CaptainCommandTeam = "a"
const CaptainCommandTeamB CaptainCommandTeam = "b"
type ChatCommand ¶
type ChatMessageEvent ¶
type ChatMessageEvent struct {
// At corresponds to the JSON schema field "at".
At int `json:"at"`
// Player corresponds to the JSON schema field "player".
Player *ChatMessageEventPlayer `json:"player"`
// Role corresponds to the JSON schema field "role".
Role *ChatMessageEventRole `json:"role,omitempty,omitzero"`
// RoomID corresponds to the JSON schema field "roomId".
RoomID string `json:"roomId"`
// Text corresponds to the JSON schema field "text".
Text string `json:"text"`
// Type corresponds to the JSON schema field "type".
Type string `json:"type"`
}
type ChatMessageEventPlayer ¶
type ChatMessageEventPlayer struct {
// AccountID corresponds to the JSON schema field "accountId".
AccountID PlayerRefAccountID `json:"accountId"`
// O id do jogador nesta sala, informado nos eventos e no estado ao vivo. O id
// muda se o jogador sair e voltar.
ID int `json:"id"`
// Nick corresponds to the JSON schema field "nick".
Nick string `json:"nick"`
}
type ChatMessageEventPlayer_0 ¶
type ChatMessageEventPlayer_0 = PlayerRef
type ChatMessageEventRole ¶
type ChatMessageEventRole string
const ChatMessageEventRoleOwner ChatMessageEventRole = "owner"
const ChatMessageEventRolePlayer ChatMessageEventRole = "player"
const ChatMessageEventRoleStaff ChatMessageEventRole = "staff"
type ClientMessage ¶
type ClientMessage interface{}
O que o bot manda: a auth (primeira mensagem) e, depois dela, comandos. Todo comando aceita um campo ref (texto até 64), que volta no result dele (x-amebas-bot.commandRef).
type Cmd ¶
type Cmd struct {
Aliases []string
// Description é a linha do !ajuda.
Description string
// Hidden tira o comando do !ajuda.
Hidden bool
Args []Arg
Cooldown time.Duration
RoomCooldown time.Duration
StaffPays bool
Permission Permission
Messages Messages
// Parse troca o parser padrão: devolve os args, ou um erro (vira a resposta de uso com o texto do erro).
Parse func(ParseInput) (map[string]any, error)
}
Cmd é a define de um comando. Um valor simples: dá pra guardar numa var e copiar (staff := Cmd{Permission: PermissionStaff}; c := staff; c.Args = ...).
type CommandPlayer ¶
CommandPlayer é quem mandou o comando: a Person e o papel na sala.
type Commands ¶
type Commands struct {
// contains filtered or unexported fields
}
Commands guarda os comandos de uma sala (ou de um bot), decide o que cada mensagem é e controla os cooldowns.
func (*Commands) Add ¶
Add registra um comando; o mesmo nome de novo substitui o anterior. Erro de define volta com o que está errado e o jeito certo.
func (*Commands) Dispatch ¶
Dispatch roda a mensagem: responde (reply) ou chama o handler do comando e fecha o cooldown. Devolve se era comando. O handler que devolve *UsageError vira a resposta de uso (e não conta); ErrNotCounted devolve o cooldown; outro erro devolve o cooldown e sobe.
func (*Commands) Match ¶
func (c *Commands) Match(in MatchInput) *Decision
Match decide o que a mensagem é: nil = não é comando daqui.
func (*Commands) SetDefaults ¶
SetDefaults define os padrões de todos os comandos (campos vazios não mudam o que já foi definido).
type ConfigCommand ¶
type ConfigCommand struct {
// Config corresponds to the JSON schema field "config".
Config HostedRoomConfigInput `json:"config"`
// IsPublic corresponds to the JSON schema field "isPublic".
IsPublic *bool `json:"isPublic,omitempty,omitzero"`
// Name corresponds to the JSON schema field "name".
Name *string `json:"name,omitempty,omitzero"`
// Password corresponds to the JSON schema field "password".
Password interface{} `json:"password,omitempty,omitzero"`
// Type corresponds to the JSON schema field "type".
Type string `json:"type"`
}
type ConfigCommandPassword_0 ¶
type ConfigCommandPassword_0 *string
type ConfirmCommand ¶
type ConfirmCommand struct {
// Type corresponds to the JSON schema field "type".
Type string `json:"type"`
}
type Ctx ¶
type Ctx struct {
Player CommandPlayer
// Args já convertidos; use os atalhos Int, Number, Text, Bool, Team, Person.
Args map[string]any
// Command é o nome registrado (sem o prefixo); Alias, o que a pessoa digitou.
Command string
Alias string
Words []string
Rest string
// contains filtered or unexported fields
}
Ctx é o que o handler recebe.
type Decision ¶
type Decision struct {
Replies []string
// Finish fecha o uso de um comando: counted false devolve o cooldown.
Finish func(counted bool)
// contains filtered or unexported fields
}
Decision é o que fazer com a mensagem: rodar um comando, ou responder.
type Defaults ¶
type Defaults struct {
// Prefix é o que vem antes do nome; padrão "!".
Prefix string
Cooldown time.Duration
RoomCooldown time.Duration
// StaffPays: a staff também espera o cooldown (por padrão é isenta).
StaffPays bool
Permission Permission
Messages Messages
// NoHelp desliga o !ajuda embutido.
NoHelp bool
}
Defaults são os padrões de todos os comandos; a define de cada comando sobrescreve campo a campo.
type ErrorMessage ¶
type FinishCommand ¶
type FinishCommand struct {
// Type corresponds to the JSON schema field "type".
Type string `json:"type"`
}
type Handler ¶
Handler é a função do comando. Devolver ErrNotCounted não gasta o cooldown; devolver *UsageError responde o uso com o motivo; outro erro sobe pro dispatch.
type HostBot ¶
type HostBot struct {
// Afk corresponds to the JSON schema field "afk".
Afk *HostBotAfk `json:"afk,omitempty,omitzero"`
// ChatRules corresponds to the JSON schema field "chatRules".
ChatRules *HostBotChatRules `json:"chatRules,omitempty,omitzero"`
// Notices corresponds to the JSON schema field "notices".
Notices *HostBotNotices `json:"notices,omitempty,omitzero"`
// Welcome corresponds to the JSON schema field "welcome".
Welcome *HostBotWelcome `json:"welcome,omitempty,omitzero"`
}
type HostBotAfk ¶
type HostBotAfk struct {
// Action corresponds to the JSON schema field "action".
Action HostBotAfkAction `json:"action"`
// Seconds corresponds to the JSON schema field "seconds".
Seconds int `json:"seconds"`
}
type HostBotAfkAction ¶
type HostBotAfkAction string
const HostBotAfkActionKick HostBotAfkAction = "kick"
const HostBotAfkActionSpectate HostBotAfkAction = "spectate"
type HostBotChatRules ¶
type HostBotChatRules struct {
// Action corresponds to the JSON schema field "action".
Action HostBotChatRulesAction `json:"action"`
// Words corresponds to the JSON schema field "words".
Words []string `json:"words"`
}
type HostBotChatRulesAction ¶
type HostBotChatRulesAction string
const HostBotChatRulesActionKick HostBotChatRulesAction = "kick"
const HostBotChatRulesActionMute HostBotChatRulesAction = "mute"
type HostBotNotices ¶
type HostBotWelcome ¶
type HostBotWelcome struct {
// Text corresponds to the JSON schema field "text".
Text string `json:"text"`
}
type HostedRoom ¶
type HostedRoom struct {
// AlwaysOn corresponds to the JSON schema field "alwaysOn".
AlwaysOn bool `json:"alwaysOn"`
// Código fixo da sala: o id da comunidade, um hífen e um apelido de 1 a 16 letras
// minúsculas, números e hífen.
Code string `json:"code"`
// Slug da comunidade, definido na criação e imutável depois dela.
CommunityID string `json:"communityId"`
// Config corresponds to the JSON schema field "config".
Config HostedRoomConfig `json:"config"`
// CreatedAt corresponds to the JSON schema field "createdAt".
CreatedAt int `json:"createdAt"`
// Desired corresponds to the JSON schema field "desired".
Desired HostedRoomDesired `json:"desired"`
// HasPassword corresponds to the JSON schema field "hasPassword".
HasPassword bool `json:"hasPassword"`
// HostBot corresponds to the JSON schema field "hostBot".
HostBot *HostedRoomHostBot `json:"hostBot,omitempty,omitzero"`
// ID corresponds to the JSON schema field "id".
ID string `json:"id"`
// IsPublic corresponds to the JSON schema field "isPublic".
IsPublic bool `json:"isPublic"`
// Live corresponds to the JSON schema field "live".
Live *HostedRoomLive `json:"live,omitempty,omitzero"`
// MaxPlayers corresponds to the JSON schema field "maxPlayers".
MaxPlayers int `json:"maxPlayers"`
// Name corresponds to the JSON schema field "name".
Name string `json:"name"`
// PaidUntil corresponds to the JSON schema field "paidUntil".
PaidUntil interface{} `json:"paidUntil"`
// Plan corresponds to the JSON schema field "plan".
Plan HostedRoomPlan `json:"plan"`
// Rules corresponds to the JSON schema field "rules".
Rules *HostedRoomRules `json:"rules,omitempty,omitzero"`
// Script corresponds to the JSON schema field "script".
Script *HostedRoomScript `json:"script,omitempty,omitzero"`
// Status corresponds to the JSON schema field "status".
Status HostedRoomStatus `json:"status"`
// Teams corresponds to the JSON schema field "teams".
Teams *HostedRoomTeams `json:"teams,omitempty,omitzero"`
// UpdatedAt corresponds to the JSON schema field "updatedAt".
UpdatedAt int `json:"updatedAt"`
}
type HostedRoomConfig ¶
type HostedRoomConfig struct {
// Ball corresponds to the JSON schema field "ball".
Ball *string `json:"ball,omitempty,omitzero"`
// CommunityMap corresponds to the JSON schema field "communityMap".
CommunityMap *string `json:"communityMap,omitempty,omitzero"`
// Format corresponds to the JSON schema field "format".
Format *HostedRoomConfigFormat `json:"format,omitempty,omitzero"`
// FormatParams corresponds to the JSON schema field "formatParams".
FormatParams HostedRoomConfigFormatParams `json:"formatParams,omitempty,omitzero"`
// Gameplay corresponds to the JSON schema field "gameplay".
Gameplay *HostedRoomConfigGameplay `json:"gameplay,omitempty,omitzero"`
// Goalkeeper corresponds to the JSON schema field "goalkeeper".
Goalkeeper *int `json:"goalkeeper,omitempty,omitzero"`
// Goals corresponds to the JSON schema field "goals".
Goals *int `json:"goals,omitempty,omitzero"`
// Keepers corresponds to the JSON schema field "keepers".
Keepers *bool `json:"keepers,omitempty,omitzero"`
// Map corresponds to the JSON schema field "map".
Map *string `json:"map,omitempty,omitzero"`
// Mode corresponds to the JSON schema field "mode".
Mode *HostedRoomConfigMode `json:"mode,omitempty,omitzero"`
// ModeParams corresponds to the JSON schema field "modeParams".
ModeParams HostedRoomConfigModeParams `json:"modeParams,omitempty,omitzero"`
// Preset corresponds to the JSON schema field "preset".
Preset *string `json:"preset,omitempty,omitzero"`
// TeamSize corresponds to the JSON schema field "teamSize".
TeamSize *int `json:"teamSize,omitempty,omitzero"`
// Time corresponds to the JSON schema field "time".
Time *int `json:"time,omitempty,omitzero"`
}
type HostedRoomConfigFormat ¶
type HostedRoomConfigFormat string
const HostedRoomConfigFormatEveryone HostedRoomConfigFormat = "everyone"
const HostedRoomConfigFormatKnockout HostedRoomConfigFormat = "knockout"
const HostedRoomConfigFormatManual HostedRoomConfigFormat = "manual"
const HostedRoomConfigFormatOpen HostedRoomConfigFormat = "open"
const HostedRoomConfigFormatQueue HostedRoomConfigFormat = "queue"
const HostedRoomConfigFormatRounds HostedRoomConfigFormat = "rounds"
type HostedRoomConfigFormatParams ¶
type HostedRoomConfigFormatParams map[string]interface{}
type HostedRoomConfigGameplay ¶
type HostedRoomConfigGameplay struct {
// AccelTime corresponds to the JSON schema field "accelTime".
AccelTime *float64 `json:"accelTime,omitempty,omitzero"`
// AimAssist corresponds to the JSON schema field "aimAssist".
AimAssist *float64 `json:"aimAssist,omitempty,omitzero"`
// BallAirFriction corresponds to the JSON schema field "ballAirFriction".
BallAirFriction *float64 `json:"ballAirFriction,omitempty,omitzero"`
// BallBounce corresponds to the JSON schema field "ballBounce".
BallBounce *float64 `json:"ballBounce,omitempty,omitzero"`
// BallFriction corresponds to the JSON schema field "ballFriction".
BallFriction *float64 `json:"ballFriction,omitempty,omitzero"`
// BallMass corresponds to the JSON schema field "ballMass".
BallMass *float64 `json:"ballMass,omitempty,omitzero"`
// BallSize corresponds to the JSON schema field "ballSize".
BallSize *float64 `json:"ballSize,omitempty,omitzero"`
// ControlSpin corresponds to the JSON schema field "controlSpin".
ControlSpin *float64 `json:"controlSpin,omitempty,omitzero"`
// Gravity corresponds to the JSON schema field "gravity".
Gravity *float64 `json:"gravity,omitempty,omitzero"`
// KickPower corresponds to the JSON schema field "kickPower".
KickPower *float64 `json:"kickPower,omitempty,omitzero"`
// MaxSpeed corresponds to the JSON schema field "maxSpeed".
MaxSpeed *float64 `json:"maxSpeed,omitempty,omitzero"`
// PlayerSize corresponds to the JSON schema field "playerSize".
PlayerSize *float64 `json:"playerSize,omitempty,omitzero"`
// Turning corresponds to the JSON schema field "turning".
Turning *float64 `json:"turning,omitempty,omitzero"`
}
type HostedRoomConfigInput ¶
type HostedRoomConfigInput struct {
// Ball corresponds to the JSON schema field "ball".
Ball *string `json:"ball,omitempty,omitzero"`
// CommunityMap corresponds to the JSON schema field "communityMap".
CommunityMap *string `json:"communityMap,omitempty,omitzero"`
// Format corresponds to the JSON schema field "format".
Format *HostedRoomConfigInputFormat `json:"format,omitempty,omitzero"`
// FormatParams corresponds to the JSON schema field "formatParams".
FormatParams HostedRoomConfigInputFormatParams `json:"formatParams,omitempty,omitzero"`
// Gameplay corresponds to the JSON schema field "gameplay".
Gameplay *HostedRoomConfigInputGameplay `json:"gameplay,omitempty,omitzero"`
// Goalkeeper corresponds to the JSON schema field "goalkeeper".
Goalkeeper *int `json:"goalkeeper,omitempty,omitzero"`
// Goals corresponds to the JSON schema field "goals".
Goals *int `json:"goals,omitempty,omitzero"`
// Keepers corresponds to the JSON schema field "keepers".
Keepers *bool `json:"keepers,omitempty,omitzero"`
// Map corresponds to the JSON schema field "map".
Map *string `json:"map,omitempty,omitzero"`
// Mode corresponds to the JSON schema field "mode".
Mode *HostedRoomConfigInputMode `json:"mode,omitempty,omitzero"`
// ModeParams corresponds to the JSON schema field "modeParams".
ModeParams HostedRoomConfigInputModeParams `json:"modeParams,omitempty,omitzero"`
// Preset corresponds to the JSON schema field "preset".
Preset *string `json:"preset,omitempty,omitzero"`
// TeamSize corresponds to the JSON schema field "teamSize".
TeamSize *int `json:"teamSize,omitempty,omitzero"`
// Time corresponds to the JSON schema field "time".
Time *int `json:"time,omitempty,omitzero"`
}
type HostedRoomConfigInputFormat ¶
type HostedRoomConfigInputFormat string
const HostedRoomConfigInputFormatEveryone HostedRoomConfigInputFormat = "everyone"
const HostedRoomConfigInputFormatKnockout HostedRoomConfigInputFormat = "knockout"
const HostedRoomConfigInputFormatManual HostedRoomConfigInputFormat = "manual"
const HostedRoomConfigInputFormatOpen HostedRoomConfigInputFormat = "open"
const HostedRoomConfigInputFormatQueue HostedRoomConfigInputFormat = "queue"
const HostedRoomConfigInputFormatRounds HostedRoomConfigInputFormat = "rounds"
type HostedRoomConfigInputFormatParams ¶
type HostedRoomConfigInputFormatParams map[string]interface{}
type HostedRoomConfigInputGameplay ¶
type HostedRoomConfigInputGameplay struct {
// AccelTime corresponds to the JSON schema field "accelTime".
AccelTime *float64 `json:"accelTime,omitempty,omitzero"`
// AimAssist corresponds to the JSON schema field "aimAssist".
AimAssist *float64 `json:"aimAssist,omitempty,omitzero"`
// BallAirFriction corresponds to the JSON schema field "ballAirFriction".
BallAirFriction *float64 `json:"ballAirFriction,omitempty,omitzero"`
// BallBounce corresponds to the JSON schema field "ballBounce".
BallBounce *float64 `json:"ballBounce,omitempty,omitzero"`
// BallFriction corresponds to the JSON schema field "ballFriction".
BallFriction *float64 `json:"ballFriction,omitempty,omitzero"`
// BallMass corresponds to the JSON schema field "ballMass".
BallMass *float64 `json:"ballMass,omitempty,omitzero"`
// BallSize corresponds to the JSON schema field "ballSize".
BallSize *float64 `json:"ballSize,omitempty,omitzero"`
// ControlSpin corresponds to the JSON schema field "controlSpin".
ControlSpin *float64 `json:"controlSpin,omitempty,omitzero"`
// Gravity corresponds to the JSON schema field "gravity".
Gravity *float64 `json:"gravity,omitempty,omitzero"`
// KickPower corresponds to the JSON schema field "kickPower".
KickPower *float64 `json:"kickPower,omitempty,omitzero"`
// MaxSpeed corresponds to the JSON schema field "maxSpeed".
MaxSpeed *float64 `json:"maxSpeed,omitempty,omitzero"`
// PlayerSize corresponds to the JSON schema field "playerSize".
PlayerSize *float64 `json:"playerSize,omitempty,omitzero"`
// Turning corresponds to the JSON schema field "turning".
Turning *float64 `json:"turning,omitempty,omitzero"`
}
type HostedRoomConfigInputMode ¶
type HostedRoomConfigInputMode string
const HostedRoomConfigInputModeCtf HostedRoomConfigInputMode = "ctf"
const HostedRoomConfigInputModeDodgeball HostedRoomConfigInputMode = "dodgeball"
const HostedRoomConfigInputModeFootball HostedRoomConfigInputMode = "football"
const HostedRoomConfigInputModePenalty HostedRoomConfigInputMode = "penalty"
const HostedRoomConfigInputModeRace HostedRoomConfigInputMode = "race"
const HostedRoomConfigInputModeTenman HostedRoomConfigInputMode = "tenman"
const HostedRoomConfigInputModeVolleyball HostedRoomConfigInputMode = "volleyball"
type HostedRoomConfigInputModeParams ¶
type HostedRoomConfigInputModeParams map[string]interface{}
type HostedRoomConfigMode ¶
type HostedRoomConfigMode string
const HostedRoomConfigModeCtf HostedRoomConfigMode = "ctf"
const HostedRoomConfigModeDodgeball HostedRoomConfigMode = "dodgeball"
const HostedRoomConfigModeFootball HostedRoomConfigMode = "football"
const HostedRoomConfigModePenalty HostedRoomConfigMode = "penalty"
const HostedRoomConfigModeRace HostedRoomConfigMode = "race"
const HostedRoomConfigModeTenman HostedRoomConfigMode = "tenman"
const HostedRoomConfigModeVolleyball HostedRoomConfigMode = "volleyball"
type HostedRoomConfigModeParams ¶
type HostedRoomConfigModeParams map[string]interface{}
type HostedRoomDesired ¶
type HostedRoomDesired string
const HostedRoomDesiredOff HostedRoomDesired = "off"
const HostedRoomDesiredOn HostedRoomDesired = "on"
type HostedRoomHostBot ¶
type HostedRoomHostBot struct {
// Afk corresponds to the JSON schema field "afk".
Afk *HostBotAfk `json:"afk,omitempty,omitzero"`
// ChatRules corresponds to the JSON schema field "chatRules".
ChatRules *HostBotChatRules `json:"chatRules,omitempty,omitzero"`
// Notices corresponds to the JSON schema field "notices".
Notices *HostBotNotices `json:"notices,omitempty,omitzero"`
// Welcome corresponds to the JSON schema field "welcome".
Welcome *HostBotWelcome `json:"welcome,omitempty,omitzero"`
}
type HostedRoomHostBot_0 ¶
type HostedRoomHostBot_0 = HostBot
type HostedRoomLive ¶
type HostedRoomLive struct {
// Address corresponds to the JSON schema field "address".
Address HostedRoomLive_0Address `json:"address"`
// Code corresponds to the JSON schema field "code".
Code string `json:"code"`
// Players corresponds to the JSON schema field "players".
Players int `json:"players"`
}
type HostedRoomLive_0 ¶
type HostedRoomLive_0 struct {
// Address corresponds to the JSON schema field "address".
Address HostedRoomLive_0Address `json:"address"`
// Code corresponds to the JSON schema field "code".
Code string `json:"code"`
// Players corresponds to the JSON schema field "players".
Players int `json:"players"`
}
type HostedRoomLive_0Address ¶
type HostedRoomLive_0Address *string
type HostedRoomPaidUntil_0 ¶
type HostedRoomPaidUntil_0 *int
type HostedRoomPlan ¶
type HostedRoomPlan string
const HostedRoomPlanFull HostedRoomPlan = "full"
const HostedRoomPlanSimple HostedRoomPlan = "simple"
type HostedRoomRules ¶
type HostedRoomRules []Rule
type HostedRoomRules_0 ¶
type HostedRoomRules_0 = RoomRules
type HostedRoomScript ¶
type HostedRoomScript_0 ¶
type HostedRoomScript_0 = RoomScript
type HostedRoomStatus ¶
type HostedRoomStatus string
const HostedRoomStatusLive HostedRoomStatus = "live"
const HostedRoomStatusOff HostedRoomStatus = "off"
const HostedRoomStatusStarting HostedRoomStatus = "starting"
type HostedRoomTeams ¶
type HostedRoomTeams struct {
// A corresponds to the JSON schema field "a".
A TeamStyle `json:"a"`
// B corresponds to the JSON schema field "b".
B TeamStyle `json:"b"`
}
O uniforme do time da casa (a) e o do time visitante (b).
type HostedRoomTeams_0 ¶
type HostedRoomTeams_0 = RoomTeams
type KickCommand ¶
type KnockoutCommand ¶
type KnockoutCommand struct {
// Action corresponds to the JSON schema field "action".
Action KnockoutCommandAction `json:"action"`
// Type corresponds to the JSON schema field "type".
Type string `json:"type"`
}
type KnockoutCommandAction ¶
type KnockoutCommandAction string
const KnockoutCommandActionLock KnockoutCommandAction = "lock"
const KnockoutCommandActionReset KnockoutCommandAction = "reset"
type LivePlayer ¶
type LivePlayer struct {
// AccountID corresponds to the JSON schema field "accountId".
AccountID LivePlayerAccountID `json:"accountId"`
// Admin corresponds to the JSON schema field "admin".
Admin bool `json:"admin"`
// Connection corresponds to the JSON schema field "connection".
Connection LivePlayerConnection `json:"connection"`
// O id do jogador nesta sala, informado nos eventos e no estado ao vivo. O id
// muda se o jogador sair e voltar.
ID int `json:"id"`
// Nick corresponds to the JSON schema field "nick".
Nick string `json:"nick"`
// Place corresponds to the JSON schema field "place".
Place LivePlayerPlace `json:"place"`
}
type LivePlayerAccountID ¶
type LivePlayerAccountID *string
type LivePlayerConnection ¶
type LivePlayerConnection string
const LivePlayerConnectionAfk LivePlayerConnection = "afk"
const LivePlayerConnectionOk LivePlayerConnection = "ok"
const LivePlayerConnectionReconnecting LivePlayerConnection = "reconnecting"
type LivePlayerPlace ¶
type LivePlayerPlace string
const LivePlayerPlaceA LivePlayerPlace = "a"
const LivePlayerPlaceB LivePlayerPlace = "b"
const LivePlayerPlaceStands LivePlayerPlace = "stands"
type LiveRoom ¶
type LiveRoom struct {
// Address corresponds to the JSON schema field "address".
Address LiveRoomAddress `json:"address"`
// Code corresponds to the JSON schema field "code".
Code string `json:"code"`
// Map corresponds to the JSON schema field "map".
Map string `json:"map"`
// Mode corresponds to the JSON schema field "mode".
Mode string `json:"mode"`
// Phase corresponds to the JSON schema field "phase".
Phase LiveRoomPhase `json:"phase"`
// Players corresponds to the JSON schema field "players".
Players []LivePlayer `json:"players"`
// Score corresponds to the JSON schema field "score".
Score LiveRoomScore `json:"score"`
}
type LiveRoomAddress ¶
type LiveRoomAddress *string
type LiveRoomPhase ¶
type LiveRoomPhase string
const LiveRoomPhasePaused LiveRoomPhase = "paused"
const LiveRoomPhasePlaying LiveRoomPhase = "playing"
const LiveRoomPhaseStopped LiveRoomPhase = "stopped"
type LiveRoomScore ¶
type LockCommand ¶
type Match ¶
type Match struct {
// DurationSeconds corresponds to the JSON schema field "durationSeconds".
DurationSeconds int `json:"durationSeconds"`
// Format corresponds to the JSON schema field "format".
Format MatchFormat `json:"format"`
// HostedRoomID corresponds to the JSON schema field "hostedRoomId".
HostedRoomID MatchHostedRoomID `json:"hostedRoomId"`
// ID corresponds to the JSON schema field "id".
ID string `json:"id"`
// Map corresponds to the JSON schema field "map".
Map MatchMap `json:"map"`
// Mode corresponds to the JSON schema field "mode".
Mode string `json:"mode"`
// PlayedAt corresponds to the JSON schema field "playedAt".
PlayedAt int `json:"playedAt"`
// Players corresponds to the JSON schema field "players".
Players []MatchPlayersElem `json:"players"`
// Room corresponds to the JSON schema field "room".
Room string `json:"room"`
// Rules corresponds to the JSON schema field "rules".
Rules *bool `json:"rules,omitempty,omitzero"`
// ScoreA corresponds to the JSON schema field "scoreA".
ScoreA int `json:"scoreA"`
// ScoreB corresponds to the JSON schema field "scoreB".
ScoreB int `json:"scoreB"`
}
type MatchEndedEvent ¶
type MatchEndedEvent struct {
// At corresponds to the JSON schema field "at".
At int `json:"at"`
// Match corresponds to the JSON schema field "match".
Match Match `json:"match"`
// RoomID corresponds to the JSON schema field "roomId".
RoomID string `json:"roomId"`
// Type corresponds to the JSON schema field "type".
Type string `json:"type"`
}
type MatchEventEvent ¶
type MatchEventEvent struct {
// At corresponds to the JSON schema field "at".
At int `json:"at"`
// Event corresponds to the JSON schema field "event".
Event MatchEventEventEvent `json:"event"`
// Player corresponds to the JSON schema field "player".
Player *MatchEventEventPlayer `json:"player"`
// RoomID corresponds to the JSON schema field "roomId".
RoomID string `json:"roomId"`
// Team corresponds to the JSON schema field "team".
Team interface{} `json:"team"`
// Type corresponds to the JSON schema field "type".
Type string `json:"type"`
}
type MatchEventEventEvent ¶
type MatchEventEventEvent string
const MatchEventEventEventBlock MatchEventEventEvent = "Block"
const MatchEventEventEventCard MatchEventEventEvent = "Card"
const MatchEventEventEventEliminated MatchEventEventEvent = "Eliminated"
const MatchEventEventEventFault MatchEventEventEvent = "Fault"
const MatchEventEventEventFinished MatchEventEventEvent = "Finished"
const MatchEventEventEventFlagCaptured MatchEventEventEvent = "FlagCaptured"
const MatchEventEventEventFlagDropped MatchEventEventEvent = "FlagDropped"
const MatchEventEventEventFlagTaken MatchEventEventEvent = "FlagTaken"
const MatchEventEventEventFoul MatchEventEventEvent = "Foul"
const MatchEventEventEventFrozen MatchEventEventEvent = "Frozen"
const MatchEventEventEventGoal MatchEventEventEvent = "Goal"
const MatchEventEventEventLapCompleted MatchEventEventEvent = "LapCompleted"
const MatchEventEventEventOut MatchEventEventEvent = "Out"
const MatchEventEventEventPenaltyKick MatchEventEventEvent = "PenaltyKick"
const MatchEventEventEventPoint MatchEventEventEvent = "Point"
const MatchEventEventEventPost MatchEventEventEvent = "Post"
const MatchEventEventEventRevived MatchEventEventEvent = "Revived"
const MatchEventEventEventRoundEnd MatchEventEventEvent = "RoundEnd"
const MatchEventEventEventRoundStart MatchEventEventEvent = "RoundStart"
const MatchEventEventEventSave MatchEventEventEvent = "Save"
const MatchEventEventEventUnfrozen MatchEventEventEvent = "Unfrozen"
type MatchEventEventPlayer ¶
type MatchEventEventPlayer struct {
// AccountID corresponds to the JSON schema field "accountId".
AccountID PlayerRefAccountID `json:"accountId"`
// O id do jogador nesta sala, informado nos eventos e no estado ao vivo. O id
// muda se o jogador sair e voltar.
ID int `json:"id"`
// Nick corresponds to the JSON schema field "nick".
Nick string `json:"nick"`
}
type MatchEventEventPlayer_0 ¶
type MatchEventEventPlayer_0 = PlayerRef
type MatchEventEventTeam_0 ¶
type MatchEventEventTeam_0 string
const MatchEventEventTeam_0_A MatchEventEventTeam_0 = "a"
const MatchEventEventTeam_0_B MatchEventEventTeam_0 = "b"
type MatchFormat ¶
type MatchFormat *string
type MatchHostedRoomID ¶
type MatchHostedRoomID *string
type MatchInput ¶
type MatchInput struct {
Text string
Player CommandPlayer
Now time.Duration
Players []Person
}
MatchInput é a mensagem, quem mandou, o relógio e quem está na sala (pro argumento player).
type MatchPlayersElem ¶
type MatchPlayersElem struct {
// AccountID corresponds to the JSON schema field "accountId".
AccountID MatchPlayersElemAccountID `json:"accountId"`
// Nick corresponds to the JSON schema field "nick".
Nick string `json:"nick"`
// Outcome corresponds to the JSON schema field "outcome".
Outcome interface{} `json:"outcome"`
// Stats corresponds to the JSON schema field "stats".
Stats MatchPlayersElemStats `json:"stats"`
// Team corresponds to the JSON schema field "team".
Team MatchPlayersElemTeam `json:"team"`
}
type MatchPlayersElemAccountID ¶
type MatchPlayersElemAccountID *string
type MatchPlayersElemOutcome_0 ¶
type MatchPlayersElemOutcome_0 string
const MatchPlayersElemOutcome_0_Draw MatchPlayersElemOutcome_0 = "draw"
const MatchPlayersElemOutcome_0_Loss MatchPlayersElemOutcome_0 = "loss"
const MatchPlayersElemOutcome_0_Win MatchPlayersElemOutcome_0 = "win"
type MatchPlayersElemStats ¶
type MatchPlayersElemTeam ¶
type MatchPlayersElemTeam string
const MatchPlayersElemTeamA MatchPlayersElemTeam = "a"
const MatchPlayersElemTeamB MatchPlayersElemTeam = "b"
type MatchStartedEvent ¶
type MatchStartedEvent struct {
// At corresponds to the JSON schema field "at".
At int `json:"at"`
// Map corresponds to the JSON schema field "map".
Map string `json:"map"`
// Mode corresponds to the JSON schema field "mode".
Mode string `json:"mode"`
// RoomID corresponds to the JSON schema field "roomId".
RoomID string `json:"roomId"`
// Type corresponds to the JSON schema field "type".
Type string `json:"type"`
}
type Messages ¶
Messages são as respostas prontas, com {command} (!gols), {nick}, {usage} (!gols <n>) e, em cada uma: {reason} no Usage, {left} (9s, 1min 5s) no Cooldown e {who} (a staff, o dono da sala) no Permission. Vazio herda o padrão.
type MoveCommand ¶
type MoveCommand struct {
// O id do jogador nesta sala, informado nos eventos e no estado ao vivo. O id
// muda se o jogador sair e voltar.
PlayerID int `json:"playerId"`
// Slot corresponds to the JSON schema field "slot".
Slot *int `json:"slot,omitempty,omitzero"`
// To corresponds to the JSON schema field "to".
To MoveCommandTo `json:"to"`
// Type corresponds to the JSON schema field "type".
Type string `json:"type"`
}
type MoveCommandTo ¶
type MoveCommandTo string
const MoveCommandToA MoveCommandTo = "a"
const MoveCommandToB MoveCommandTo = "b"
const MoveCommandToStands MoveCommandTo = "stands"
type MuteCommand ¶
type MuteCommand struct {
// Muted corresponds to the JSON schema field "muted".
Muted bool `json:"muted,omitempty,omitzero"`
// O id do jogador nesta sala, informado nos eventos e no estado ao vivo. O id
// muda se o jogador sair e voltar.
PlayerID int `json:"playerId"`
// Type corresponds to the JSON schema field "type".
Type string `json:"type"`
}
type Options ¶
type Options struct {
// BaseURL é onde a API responde: http://localhost:8092 no dev, https://<site>/api em produção.
BaseURL string
RoomID string
// Key é a chave da comunidade com o escopo rooms:control (amb_...).
Key string
// NoReconnect desliga a reconexão.
NoReconnect bool
// InitialDelay é a primeira espera depois de cair (dobra a cada tentativa); padrão 1 s.
InitialDelay time.Duration
// MaxDelay é o teto da espera; padrão 30 s.
MaxDelay time.Duration
// MaxAttempts: desiste depois de tantas tentativas seguidas sem ready; 0 = nunca.
MaxAttempts int
// CommandTimeout: quanto esperar o result de um comando; padrão 10 s.
CommandTimeout time.Duration
}
Options configura o Bot.
type ParseInput ¶
type ParseInput struct {
Rest string
Words []string
Player CommandPlayer
Players []Person
}
ParseInput é o que o Parse próprio recebe: o texto depois do nome, já em palavras.
type PauseCommand ¶
type Permission ¶
type Permission string
Permission diz quem pode usar o comando. Vazio herda o padrão (todos).
const ( PermissionAll Permission = "all" PermissionStaff Permission = "staff" PermissionOwner Permission = "owner" )
type PickCommand ¶
type PickCommand struct {
// Keyword corresponds to the JSON schema field "keyword".
Keyword *PickCommandKeyword `json:"keyword,omitempty,omitzero"`
// Number corresponds to the JSON schema field "number".
Number *int `json:"number,omitempty,omitzero"`
// O id do jogador nesta sala, informado nos eventos e no estado ao vivo. O id
// muda se o jogador sair e voltar.
PlayerID *int `json:"playerId,omitempty,omitzero"`
// Type corresponds to the JSON schema field "type".
Type string `json:"type"`
}
type PickCommandKeyword ¶
type PickCommandKeyword string
const PickCommandKeywordBottom PickCommandKeyword = "bottom"
const PickCommandKeywordRandom PickCommandKeyword = "random"
const PickCommandKeywordTop PickCommandKeyword = "top"
type PlayerJoinedEvent ¶
type PlayerJoinedEvent struct {
// At corresponds to the JSON schema field "at".
At int `json:"at"`
// Player corresponds to the JSON schema field "player".
Player PlayerRef `json:"player"`
// quantas pessoas ficaram na sala
Players int `json:"players"`
// RoomID corresponds to the JSON schema field "roomId".
RoomID string `json:"roomId"`
// Type corresponds to the JSON schema field "type".
Type string `json:"type"`
}
type PlayerLeftEvent ¶
type PlayerLeftEvent struct {
// At corresponds to the JSON schema field "at".
At int `json:"at"`
// Player corresponds to the JSON schema field "player".
Player PlayerRef `json:"player"`
// quantas pessoas ficaram na sala
Players int `json:"players"`
// Reason corresponds to the JSON schema field "reason".
Reason PlayerLeftEventReason `json:"reason"`
// RoomID corresponds to the JSON schema field "roomId".
RoomID string `json:"roomId"`
// Type corresponds to the JSON schema field "type".
Type string `json:"type"`
}
type PlayerLeftEventReason ¶
type PlayerLeftEventReason string
const PlayerLeftEventReasonBanned PlayerLeftEventReason = "banned"
const PlayerLeftEventReasonDropped PlayerLeftEventReason = "dropped"
const PlayerLeftEventReasonKicked PlayerLeftEventReason = "kicked"
const PlayerLeftEventReasonLeft PlayerLeftEventReason = "left"
type PlayerRef ¶
type PlayerRef struct {
// AccountID corresponds to the JSON schema field "accountId".
AccountID PlayerRefAccountID `json:"accountId"`
// O id do jogador nesta sala, informado nos eventos e no estado ao vivo. O id
// muda se o jogador sair e voltar.
ID int `json:"id"`
// Nick corresponds to the JSON schema field "nick".
Nick string `json:"nick"`
}
type PlayerRefAccountID ¶
type PlayerRefAccountID *string
type ReadyMessage ¶
type ReadyMessage struct {
// Live corresponds to the JSON schema field "live".
Live *ReadyMessageLive `json:"live"`
// Room corresponds to the JSON schema field "room".
Room HostedRoom `json:"room"`
// Type corresponds to the JSON schema field "type".
Type string `json:"type"`
}
type ReadyMessageLive ¶
type ReadyMessageLive struct {
// Address corresponds to the JSON schema field "address".
Address LiveRoomAddress `json:"address"`
// Code corresponds to the JSON schema field "code".
Code string `json:"code"`
// Map corresponds to the JSON schema field "map".
Map string `json:"map"`
// Mode corresponds to the JSON schema field "mode".
Mode string `json:"mode"`
// Phase corresponds to the JSON schema field "phase".
Phase LiveRoomPhase `json:"phase"`
// Players corresponds to the JSON schema field "players".
Players []LivePlayer `json:"players"`
// Score corresponds to the JSON schema field "score".
Score LiveRoomScore `json:"score"`
}
type ReadyMessageLive_0 ¶
type ReadyMessageLive_0 = LiveRoom
type RestartCommand ¶
type RestartCommand struct {
// Type corresponds to the JSON schema field "type".
Type string `json:"type"`
}
type ResultMessage ¶
type ResultMessage struct {
// Code corresponds to the JSON schema field "code".
Code *string `json:"code,omitempty,omitzero"`
// Message corresponds to the JSON schema field "message".
Message *string `json:"message,omitempty,omitzero"`
// Ok corresponds to the JSON schema field "ok".
Ok bool `json:"ok"`
// Ref corresponds to the JSON schema field "ref".
Ref *string `json:"ref,omitempty,omitzero"`
// Type corresponds to the JSON schema field "type".
Type string `json:"type"`
}
type RoomCommand ¶
type RoomCommand interface{}
type RoomConfigEvent ¶
type RoomConfigEvent struct {
// At corresponds to the JSON schema field "at".
At int `json:"at"`
// Config corresponds to the JSON schema field "config".
Config HostedRoomConfig `json:"config"`
// Name corresponds to the JSON schema field "name".
Name string `json:"name"`
// RoomID corresponds to the JSON schema field "roomId".
RoomID string `json:"roomId"`
// Type corresponds to the JSON schema field "type".
Type string `json:"type"`
}
type RoomLiveEvent ¶
type RoomLiveEvent struct {
// Address corresponds to the JSON schema field "address".
Address RoomLiveEventAddress `json:"address"`
// At corresponds to the JSON schema field "at".
At int `json:"at"`
// Code corresponds to the JSON schema field "code".
Code string `json:"code"`
// RoomID corresponds to the JSON schema field "roomId".
RoomID string `json:"roomId"`
// Type corresponds to the JSON schema field "type".
Type string `json:"type"`
}
type RoomLiveEventAddress ¶
type RoomLiveEventAddress *string
type RoomOffEvent ¶
type RoomOffEvent struct {
// At corresponds to the JSON schema field "at".
At int `json:"at"`
// Reason corresponds to the JSON schema field "reason".
Reason RoomOffEventReason `json:"reason"`
// RoomID corresponds to the JSON schema field "roomId".
RoomID string `json:"roomId"`
// Type corresponds to the JSON schema field "type".
Type string `json:"type"`
}
type RoomOffEventReason ¶
type RoomOffEventReason string
const RoomOffEventReasonEmpty RoomOffEventReason = "empty"
const RoomOffEventReasonFailed RoomOffEventReason = "failed"
const RoomOffEventReasonReleased RoomOffEventReason = "released"
const RoomOffEventReasonServerLost RoomOffEventReason = "server_lost"
type RoomScript ¶
type RoomTeams ¶
type RoomTeams struct {
// A corresponds to the JSON schema field "a".
A TeamStyle `json:"a"`
// B corresponds to the JSON schema field "b".
B TeamStyle `json:"b"`
}
O uniforme do time da casa (a) e o do time visitante (b).
type Rule ¶
type Rule struct {
// CooldownSeconds corresponds to the JSON schema field "cooldownSeconds".
CooldownSeconds *int `json:"cooldownSeconds,omitempty,omitzero"`
// Do corresponds to the JSON schema field "do".
Do []RuleAction `json:"do"`
// Enabled corresponds to the JSON schema field "enabled".
Enabled bool `json:"enabled"`
// ID corresponds to the JSON schema field "id".
ID string `json:"id"`
// If corresponds to the JSON schema field "if".
If []RuleCondition `json:"if"`
// Name corresponds to the JSON schema field "name".
Name string `json:"name"`
// When corresponds to the JSON schema field "when".
When RuleTrigger `json:"when"`
}
Quando (when) acontecer X, se (if) Y, faça (do) Z.
type RuleAction ¶
type RuleAction interface{}
type RuleCondition ¶
type RuleCondition interface{}
type RuleFiredEvent ¶
type RuleFiredEvent struct {
// Actions corresponds to the JSON schema field "actions".
Actions []RuleFiredEventActionsElem `json:"actions"`
// At corresponds to the JSON schema field "at".
At int `json:"at"`
// Depth corresponds to the JSON schema field "depth".
Depth int `json:"depth"`
// Player corresponds to the JSON schema field "player".
Player *RuleFiredEventPlayer `json:"player"`
// RoomID corresponds to the JSON schema field "roomId".
RoomID string `json:"roomId"`
// Rule corresponds to the JSON schema field "rule".
Rule RuleFiredEventRule `json:"rule"`
// Trigger corresponds to the JSON schema field "trigger".
Trigger string `json:"trigger"`
// Type corresponds to the JSON schema field "type".
Type string `json:"type"`
}
type RuleFiredEventActionsElem ¶
type RuleFiredEventActionsElem struct {
// Message corresponds to the JSON schema field "message".
Message *string `json:"message,omitempty,omitzero"`
// Ok corresponds to the JSON schema field "ok".
Ok bool `json:"ok"`
// Type corresponds to the JSON schema field "type".
Type string `json:"type"`
}
type RuleFiredEventPlayer ¶
type RuleFiredEventPlayer struct {
// AccountID corresponds to the JSON schema field "accountId".
AccountID PlayerRefAccountID `json:"accountId"`
// O id do jogador nesta sala, informado nos eventos e no estado ao vivo. O id
// muda se o jogador sair e voltar.
ID int `json:"id"`
// Nick corresponds to the JSON schema field "nick".
Nick string `json:"nick"`
}
type RuleFiredEventPlayer_0 ¶
type RuleFiredEventPlayer_0 = PlayerRef
type RuleFiredEventRule ¶
type RuleTrigger ¶
type RuleTrigger interface{}
type ScriptLogEvent ¶
type ScriptLogEvent struct {
// At corresponds to the JSON schema field "at".
At int `json:"at"`
// RoomID corresponds to the JSON schema field "roomId".
RoomID string `json:"roomId"`
// Text corresponds to the JSON schema field "text".
Text string `json:"text"`
// Type corresponds to the JSON schema field "type".
Type string `json:"type"`
}
type ScriptStoppedEvent ¶
type ScriptStoppedEvent struct {
// At corresponds to the JSON schema field "at".
At int `json:"at"`
// Message corresponds to the JSON schema field "message".
Message string `json:"message"`
// Reason corresponds to the JSON schema field "reason".
Reason ScriptStoppedEventReason `json:"reason"`
// RoomID corresponds to the JSON schema field "roomId".
RoomID string `json:"roomId"`
// Type corresponds to the JSON schema field "type".
Type string `json:"type"`
}
type ScriptStoppedEventReason ¶
type ScriptStoppedEventReason string
const ScriptStoppedEventReasonActions ScriptStoppedEventReason = "actions"
const ScriptStoppedEventReasonBudget ScriptStoppedEventReason = "budget"
const ScriptStoppedEventReasonCompile ScriptStoppedEventReason = "compile"
const ScriptStoppedEventReasonMemory ScriptStoppedEventReason = "memory"
const ScriptStoppedEventReasonPrivate ScriptStoppedEventReason = "private"
const ScriptStoppedEventReasonRanked ScriptStoppedEventReason = "ranked"
const ScriptStoppedEventReasonRuntime ScriptStoppedEventReason = "runtime"
const ScriptStoppedEventReasonTime ScriptStoppedEventReason = "time"
type ServerMessage ¶
type ServerMessage interface{}
O que a API manda: ready (auth aceita), result (de cada comando), error e os eventos da sala.
type ShuffleCommand ¶
type ShuffleCommand struct {
// Type corresponds to the JSON schema field "type".
Type string `json:"type"`
}
type StartCommand ¶
type StartCommand struct {
// Type corresponds to the JSON schema field "type".
Type string `json:"type"`
}
type StopCommand ¶
type StopCommand struct {
// Type corresponds to the JSON schema field "type".
Type string `json:"type"`
}
type TeamCommand ¶
type TeamCommand struct {
// Colors corresponds to the JSON schema field "colors".
Colors *TeamCommandColors `json:"colors,omitempty,omitzero"`
// Kit corresponds to the JSON schema field "kit".
Kit *string `json:"kit,omitempty,omitzero"`
// Name corresponds to the JSON schema field "name".
Name *string `json:"name,omitempty,omitzero"`
// Team corresponds to the JSON schema field "team".
Team TeamCommandTeam `json:"team"`
// Type corresponds to the JSON schema field "type".
Type string `json:"type"`
}
type TeamCommandColors ¶
type TeamCommandTeam ¶
type TeamCommandTeam string
const TeamCommandTeamA TeamCommandTeam = "a"
const TeamCommandTeamB TeamCommandTeam = "b"
type TeamStyle ¶
type TeamStyle struct {
// Colors corresponds to the JSON schema field "colors".
Colors *TeamStyleColors `json:"colors,omitempty,omitzero"`
// Kit corresponds to the JSON schema field "kit".
Kit string `json:"kit"`
// Name corresponds to the JSON schema field "name".
Name string `json:"name"`
}
type TeamStyleColors ¶
type UsageError ¶
type UsageError struct{ Reason string }
UsageError é o motivo de um argumento ruim: vira a resposta de uso.
func (*UsageError) Error ¶
func (e *UsageError) Error() string
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
welcome-bot
command
Um bot de sala completo: dá boas-vindas, responde !regras e rola um !dado com argumento, faixa e cooldown.
|
Um bot de sala completo: dá boas-vindas, responde !regras e rola um !dado com argumento, faixa e cooldown. |