Documentation
¶
Index ¶
- Constants
- Variables
- func AppendStickerCommand(ctx *CommandContext) error
- func ContactServer(c chan ServerResult, bot *Client, ctx context.Context, serverName string, ...)
- func FetchStateHistory(ctx context.Context, bot *Client, roomID id.RoomID, eventID id.EventID, ...) []*event.Event
- func ForwardEvent(ctx *CommandContext) error
- func GetEventCallback(ctx *CommandContext) error
- func GetMembershipHistoryCallback(ctx *CommandContext) error
- func GetServersCallback(ctx *CommandContext) error
- func GetStateContent(ctx context.Context, room *mautrix.Room, eventType event.Type) *event.Content
- func GetStateEventCallback(ctx *CommandContext) error
- func GetStateHistoryCallback(ctx *CommandContext) error
- func HelpCommandCallback(ctx *CommandContext) error
- func IDPillConverter(_, mxid, eventID string, _ format.Context) string
- func JoinCommandCallback(ctx *CommandContext) error
- func LeaveCommandCallback(ctx *CommandContext) error
- func ParseMatrixReference(target string) id.MatrixURI
- func PingCommandCallback(ctx *CommandContext) (err error)
- func ProgressBar(total, current, length int) string
- func ResolveAliasCommandCallback(ctx *CommandContext) error
- func RoomIDFromReference(ctx context.Context, bot *Client, target id.MatrixURI) id.RoomID
- func RoomInfoCommandCallback(ctx *CommandContext) error
- func ServerInfoCommandCallback(ctx *CommandContext) error
- func TimestampToDatetimeCallback(ctx *CommandContext) error
- func UserInfoCommandCallback(ctx *CommandContext) error
- func UsersOfCallback(ctx *CommandContext) error
- type Client
- func (bot *Client) AddCommand(command Command) error
- func (bot *Client) AddReaction(room id.RoomID, evt id.EventID, key string) error
- func (bot *Client) AddReactionBG(ctx context.Context, room id.RoomID, evt id.EventID, key string)
- func (bot *Client) AddStatus(ctx context.Context, roomID id.RoomID, evt id.EventID, key string, ...) chan bool
- func (bot *Client) FetchUsers(ctx context.Context, room id.RoomID, ...) (map[id.UserID]*event.MemberEventContent, error)
- func (bot *Client) GetCommand(name string) Command
- func (bot *Client) GetStringBan(list *policyeval.PolicyList, target string) *event.Event
- func (bot *Client) HandlePanic(ctx context.Context, evt *event.Event)
- func (bot *Client) LoadRooms(ctx context.Context) error
- func (bot *Client) OnReaction(ctx context.Context, evt *event.Event)
- func (bot *Client) ProcessMessage(ctx context.Context, evt *event.Event)
- func (bot *Client) RemoveCommand(name string) (cmd Command, err error)
- func (bot *Client) SendAlert(ctx context.Context, content string)
- func (bot *Client) SetVersion(v string)
- func (bot *Client) ToRoomID(value string) (id.RoomID, error)
- func (bot *Client) UpdateObservations(user id.UserID, timestamp int64)
- func (bot *Client) VerifyWithRecoveryKey(ctx context.Context, recoveryKey string) error
- func (bot *Client) Version() string
- type Command
- type CommandContext
- func (ctx *CommandContext) Logger() *zerolog.Logger
- func (ctx *CommandContext) PrepareReply(msg string, msgtype event.MessageType) event.MessageEventContent
- func (ctx *CommandContext) Reply(msg string, msgtype event.MessageType) (*mautrix.RespSendEvent, error)
- func (ctx *CommandContext) ShouldReplyNotice(msg string) error
- type Config
- type MSC3946DynamicPredecessorEventContent
- type MaubotPingResponse
- type MaybeResult
- type ObservatoryConfig
- type RoomInfo
- type ServerInfo
- type ServerResult
- type StickerEventContent
- type StickerPack
- type StickerPackImage
- type UnstableAuthIssuer
- type UnstableAuthMetadata
- type WellKnownSupport
- type WellKnownSupportContact
Constants ¶
const ( EmojiX = "❌" EmojiHOURGLASS = "⏳" EmojiTICK = "✅" EmojiGLOBE = "🌐" )
const UnixSecondsMax = 253402300799
Variables ¶
var ( HistoryStrings = map[event.HistoryVisibility]string{ event.HistoryVisibilityWorldReadable: "World readable", event.HistoryVisibilityShared: "Available to all members", event.HistoryVisibilityInvited: "Available to members only after they are invited", event.HistoryVisibilityJoined: "Available to members only after they join", } JoinRuleStrings = map[event.JoinRule]string{ event.JoinRulePublic: "Public to anyone who knows the link", event.JoinRuleInvite: "Invite only", event.JoinRuleKnock: "Users must request to join", event.JoinRuleRestricted: "Must be a member of another room or space in order to join", event.JoinRuleKnockRestricted: "Can request to join if user is already a member of another room or space", event.JoinRulePrivate: "Uh oh", } GuestAccessStrings = map[event.GuestAccess]string{ event.GuestAccessCanJoin: "Guests can join", event.GuestAccessForbidden: "Guests cannot join", } )
var StateStickerPack = event.Type{Type: "im.ponies.room_emotes", Class: event.StateEventType}
Functions ¶
func AppendStickerCommand ¶
func AppendStickerCommand(ctx *CommandContext) error
func ContactServer ¶
func FetchStateHistory ¶
func ForwardEvent ¶
func ForwardEvent(ctx *CommandContext) error
func GetEventCallback ¶
func GetEventCallback(ctx *CommandContext) error
func GetMembershipHistoryCallback ¶
func GetMembershipHistoryCallback(ctx *CommandContext) error
func GetServersCallback ¶
func GetServersCallback(ctx *CommandContext) error
func GetStateContent ¶
func GetStateEventCallback ¶
func GetStateEventCallback(ctx *CommandContext) error
func GetStateHistoryCallback ¶
func GetStateHistoryCallback(ctx *CommandContext) error
func HelpCommandCallback ¶
func HelpCommandCallback(ctx *CommandContext) error
func JoinCommandCallback ¶
func JoinCommandCallback(ctx *CommandContext) error
func LeaveCommandCallback ¶
func LeaveCommandCallback(ctx *CommandContext) error
func ParseMatrixReference ¶
func PingCommandCallback ¶
func PingCommandCallback(ctx *CommandContext) (err error)
func ProgressBar ¶
func ResolveAliasCommandCallback ¶
func ResolveAliasCommandCallback(ctx *CommandContext) error
func RoomIDFromReference ¶
func RoomInfoCommandCallback ¶
func RoomInfoCommandCallback(ctx *CommandContext) error
func ServerInfoCommandCallback ¶
func ServerInfoCommandCallback(ctx *CommandContext) error
func TimestampToDatetimeCallback ¶
func TimestampToDatetimeCallback(ctx *CommandContext) error
func UserInfoCommandCallback ¶
func UserInfoCommandCallback(ctx *CommandContext) error
func UsersOfCallback ¶
func UsersOfCallback(ctx *CommandContext) error
Types ¶
type Client ¶
type Client struct { Mau mautrix.Client Fed *federation.Client DB db.Manager Config Config MainContext context.Context Commands []Command StartedAt time.Time Crypto *cryptohelper.CryptoHelper ObservatoryClient *observatory.ObservatoryClient PolicyManager *policyeval.PolicyListManager Rooms map[id.RoomID]*mautrix.Room GenericPolicyEvaluator *policyeval.PolicyListManager DidVerify bool // contains filtered or unexported fields }
func (*Client) AddCommand ¶
AddCommand adds a command to the internal register. The command must not have a conflicting name or alias.
func (*Client) AddReaction ¶
AddReaction adds a reaction to an event.
func (*Client) AddReactionBG ¶
AddReactionBG unlike AddReaction, runs the AddReaction function in a separate goroutine, ignoring any errors.
func (*Client) FetchUsers ¶
func (*Client) GetCommand ¶
GetCommand gets a registered command from the sensebot client. A case-sensitive comparison is performed so name should be lowercased before calling.
func (*Client) GetStringBan ¶
func (bot *Client) GetStringBan(list *policyeval.PolicyList, target string) *event.Event
func (*Client) ProcessMessage ¶
ProcessMessage processes a message event. This function, and NewClient, can only be read if "Order" by "Heaven Pierce Her" is playing.
func (*Client) RemoveCommand ¶
RemoveCommand removes a command.
func (*Client) SetVersion ¶
func (*Client) UpdateObservations ¶
func (*Client) VerifyWithRecoveryKey ¶
type Command ¶
type Command struct { Name string Usage string Aliases []string ShortDescription string LongDescription string Hidden bool Callback func(ctx *CommandContext) error }
func (*Command) NewContext ¶
type CommandContext ¶
type CommandContext struct { InvokedCommand *Command Bot *Client Event *event.Event Context context.Context Args []string RuntimeID string // Unique ID for the command execution, used for logging and debugging ExecStart time.Time }
func (*CommandContext) Logger ¶
func (ctx *CommandContext) Logger() *zerolog.Logger
func (*CommandContext) PrepareReply ¶
func (ctx *CommandContext) PrepareReply(msg string, msgtype event.MessageType) event.MessageEventContent
func (*CommandContext) Reply ¶
func (ctx *CommandContext) Reply(msg string, msgtype event.MessageType) (*mautrix.RespSendEvent, error)
func (*CommandContext) ShouldReplyNotice ¶
func (ctx *CommandContext) ShouldReplyNotice(msg string) error
type Config ¶
type Config struct { DatabaseFile string `json:"database_file"` HomeserverURL string `json:"homeserver_url"` AccessToken string `json:"access_token"` Prefix string `json:"prefix"` PickleKey string `json:"pickle_key"` StoreFile string `json:"store_file"` OwnerIDs []id.UserID `json:"owner_ids"` AutoJoinAll bool `json:"auto_join_all"` RejectInvites bool `json:"reject_invites"` RejectReason string `json:"reject_reason"` AlertRoom id.RoomID `json:"alert_room_id"` RecoveryKey string `json:"recovery_key"` Observatory ObservatoryConfig `json:"observatory"` PolicyRooms []id.RoomID `json:"policy_rooms"` Logging *zeroconfig.Config `json:"logging"` }
func LoadConfig ¶
LoadConfig attempts to the l
type MaubotPingResponse ¶
type MaubotPingResponse struct { *event.MessageEventContent Pong pong `json:"pong"` RelatesTo *pongRelatesTo `json:"m.relates_to"` }
type MaybeResult ¶
func (*MaybeResult[T]) IsError ¶
func (m *MaybeResult[T]) IsError() bool
func (*MaybeResult[T]) IsOk ¶
func (m *MaybeResult[T]) IsOk() bool
func (*MaybeResult[T]) MustValue ¶
func (m *MaybeResult[T]) MustValue() T
type ObservatoryConfig ¶
type ObservatoryConfig struct { BaseURL string `json:"base_url"` }
type RoomInfo ¶
type RoomInfo struct { *mautrix.Room DynamicPredecessor MSC3946DynamicPredecessorEventContent Name event.RoomNameEventContent ID id.RoomID CanonicalAlias event.CanonicalAliasEventContent CreateEvent event.CreateEventContent Tombstone event.TombstoneEventContent Members map[id.UserID]*event.MemberEventContent Encryption event.EncryptionEventContent JoinRules event.JoinRulesEventContent GuestAccess event.GuestAccessEventContent HistoryVisibility event.HistoryVisibilityEventContent Topic event.TopicEventContent Avatar event.RoomAvatarEventContent // contains filtered or unexported fields }
func GetFullRoomInfo ¶
func ManualMutualRooms ¶
func ManualMutualRooms(ctx *CommandContext, target id.UserID) []RoomInfo
func RoomInfoFromState ¶
func (*RoomInfo) CalculatedName ¶
type ServerInfo ¶
type ServerInfo struct { Name string C2S MaybeResult[url.URL] S2S MaybeResult[federation.ResolvedServerName] Version MaybeResult[federation.RespServerVersion] Support MaybeResult[WellKnownSupport] RegFlows []mautrix.UIAFlow RegEnabled bool RegError error ExternalAuthProvider *string FirstSeen time.Time LastSeen time.Time ObservedUsers int }
type ServerResult ¶
type StickerEventContent ¶
type StickerEventContent struct { Images map[string]StickerPackImage `json:"images"` Pack StickerPack `json:"pack"` }
type StickerPack ¶
type StickerPack struct { DisplayName string `json:"display_name,omitempty"` AvatarUri id.ContentURIString `json:"avatar_uri,omitempty"` Usage []string `json:"usage,omitempty"` Attribution string `json:"attribution,omitempty"` }
type StickerPackImage ¶
type UnstableAuthIssuer ¶
type UnstableAuthIssuer struct {
Issuer string `json:"issuer"`
}
UnstableAuthIssuer from https://github.com/sandhose/matrix-spec-proposals/blob/msc/sandhose/oidc-discovery/proposals/2965-auth-metadata.md
type UnstableAuthMetadata ¶
type UnstableAuthMetadata struct { Issuer string `json:"issuer"` AuthorizationEndpoint string `json:"authorization_endpoint"` TokenEndpoint string `json:"token_endpoint"` RegistrationEndpoint string `json:"registration_endpoint"` RevocationEndpoint string `json:"revocation_endpoint"` ResponseTypesSupported []string `json:"response_types_supported"` GrantTypesSupported []string `json:"grant_types_supported"` ResponseModesSupported []string `json:"response_modes_supported"` CodeChallengeMethodsSupported []string `json:"code_challenge_methods_supported"` }
UnstableAuthMetadata from https://github.com/sandhose/matrix-spec-proposals/blob/msc/sandhose/oidc-discovery/proposals/2965-auth-metadata.md
type WellKnownSupport ¶
type WellKnownSupport struct { Contacts []WellKnownSupportContact SupportPage *url.URL }
func (*WellKnownSupport) UnmarshalJSON ¶
func (w *WellKnownSupport) UnmarshalJSON(data []byte) error