Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Deprecated: this should be used as a placeholder that needs to be fixed HelpSectionUnclassified = HelpSection{"Unclassified", -1} HelpSectionGeneral = HelpSection{"General", 0} HelpSectionAuth = HelpSection{"Authentication", 10} HelpSectionAdmin = HelpSection{"Administration", 50} )
View Source
var CommandCancel = &FullHandler{ Func: func(ce *Event) { commandingUser, ok := ce.User.(CommandingUser) if !ok { ce.Reply("This bridge does not implement cancelable commands") return } state := commandingUser.GetCommandState() if state != nil { action := state.Action if action == "" { action = "Unknown action" } commandingUser.SetCommandState(nil) ce.Reply("%s cancelled.", action) } else { ce.Reply("No ongoing command.") } }, Name: "cancel", Help: HelpMeta{ Section: HelpSectionGeneral, Description: "Cancel an ongoing action.", }, }
View Source
var CommandDiscardMegolmSession = &FullHandler{ Func: func(ce *Event) { if ce.Bridge.Crypto == nil { ce.Reply("This bridge instance doesn't have end-to-bridge encryption enabled") } else { ce.Bridge.Crypto.ResetSession(ce.RoomID) ce.Reply("Successfully reset Megolm session in this room. New decryption keys will be shared the next time a message is sent from the remote network.") } }, Name: "discard-megolm-session", Aliases: []string{"discard-session"}, Help: HelpMeta{ Section: HelpSectionAdmin, Description: "Discard the Megolm session in the room", }, RequiresAdmin: true, }
View Source
var CommandHelp = &FullHandler{ Func: func(ce *Event) { ce.Reply(FormatHelp(ce)) }, Name: "help", Help: HelpMeta{ Section: HelpSectionGeneral, Description: "Show this help message.", }, }
View Source
var CommandLoginMatrix = &FullHandler{ Func: fnLoginMatrix, Name: "login-matrix", Help: HelpMeta{ Section: HelpSectionAuth, Description: "Enable double puppeting.", Args: "<_access token_>", }, RequiresLogin: true, }
View Source
var CommandLogoutMatrix = &FullHandler{ Func: fnLogoutMatrix, Name: "logout-matrix", Help: HelpMeta{ Section: HelpSectionAuth, Description: "Disable double puppeting.", }, RequiresLogin: true, }
View Source
var CommandPingMatrix = &FullHandler{ Func: fnPingMatrix, Name: "ping-matrix", Help: HelpMeta{ Section: HelpSectionAuth, Description: "Ping the Matrix server with the double puppet.", }, RequiresLogin: true, }
View Source
var CommandSetPowerLevel = &FullHandler{ Func: fnSetPowerLevel, Name: "set-pl", Aliases: []string{"set-power-level"}, Help: HelpMeta{ Section: HelpSectionAdmin, Description: "Change the power level in a portal room.", Args: "[_user ID_] <_power level_>", }, RequiresAdmin: true, RequiresPortal: true, }
View Source
var CommandVersion = &FullHandler{ Func: func(ce *Event) { ce.Reply("[%s](%s) %s (%s)", ce.Bridge.Name, ce.Bridge.URL, ce.Bridge.LinkifiedVersion, ce.Bridge.BuildTime) }, Name: "version", Help: HelpMeta{ Section: HelpSectionGeneral, Description: "Get the bridge version.", }, }
Functions ¶
func FormatHelp ¶
Types ¶
type AliasedHandler ¶
type CommandState ¶
type CommandState struct {
Next MinimalHandler
Action string
Meta interface{}
}
type CommandingUser ¶
type CommandingUser interface {
bridge.User
GetCommandState() *CommandState
SetCommandState(*CommandState)
}
type Event ¶
type Event struct {
Bot *appservice.IntentAPI
Bridge *bridge.Bridge
Portal bridge.Portal
Processor *Processor
Handler MinimalHandler
RoomID id.RoomID
EventID id.EventID
User bridge.User
Command string
Args []string
RawArgs string
ReplyTo id.EventID
ZLog *zerolog.Logger
// Deprecated: switch to ZLog
Log maulogger.Logger
}
Event stores all data which might be used to handle commands
func (*Event) MainIntent ¶
func (ce *Event) MainIntent() *appservice.IntentAPI
MainIntent returns the intent to use when replying to the command.
It prefers the bridge bot, but falls back to the other user in DMs if the bridge bot is not present.
func (*Event) Reply ¶
Reply sends a reply to command as notice, with optional string formatting and automatic $cmdprefix replacement.
func (*Event) ReplyAdvanced ¶
ReplyAdvanced sends a reply to command as notice. It allows using HTML and disabling markdown, but doesn't have built-in string formatting.
type FullHandler ¶
type FullHandler struct {
Func func(*Event)
Name string
Aliases []string
Help HelpMeta
RequiresAdmin bool
RequiresPortal bool
RequiresLogin bool
RequiresEventLevel event.Type
}
func (*FullHandler) GetAliases ¶
func (fh *FullHandler) GetAliases() []string
func (*FullHandler) GetHelp ¶
func (fh *FullHandler) GetHelp() HelpMeta
func (*FullHandler) GetName ¶
func (fh *FullHandler) GetName() string
func (*FullHandler) Run ¶
func (fh *FullHandler) Run(ce *Event)
func (*FullHandler) ShowInHelp ¶
func (fh *FullHandler) ShowInHelp(ce *Event) bool
type Handler ¶
type Handler interface {
MinimalHandler
GetName() string
}
type HelpMeta ¶
type HelpMeta struct {
Command string
Section HelpSection
Description string
Args string
}
type HelpSection ¶
type HelpfulHandler ¶
type MinimalHandler ¶
type MinimalHandler interface {
Run(*Event)
}
type MinimalHandlerFunc ¶
type MinimalHandlerFunc func(*Event)
func (MinimalHandlerFunc) Run ¶
func (mhf MinimalHandlerFunc) Run(ce *Event)
type Processor ¶
type Processor struct {
// contains filtered or unexported fields
}
func NewProcessor ¶
NewProcessor creates a Processor
func (*Processor) AddHandler ¶
func (*Processor) AddHandlers ¶
Click to show internal directories.
Click to hide internal directories.