mirror of
https://github.com/maubot/maubot
synced 2025-09-01 19:20:38 +00:00
Separate plugin interface to reduce file size
This commit is contained in:
parent
d572522a96
commit
ef8fffaff8
9 changed files with 254 additions and 31 deletions
48
interfaces/interfaces.go
Normal file
48
interfaces/interfaces.go
Normal file
|
@ -0,0 +1,48 @@
|
|||
package interfaces
|
||||
|
||||
type Plugin interface {
|
||||
Start()
|
||||
Stop()
|
||||
}
|
||||
|
||||
type EventHandler func(*Event) bool
|
||||
|
||||
type MatrixClient interface {
|
||||
AddEventHandler(string, EventHandler)
|
||||
}
|
||||
|
||||
type EventFuncs interface {
|
||||
Reply(text string) (string, error)
|
||||
SendMessage(text string) (string, error)
|
||||
SendEvent(content map[string]interface{}) (string, error)
|
||||
}
|
||||
|
||||
type Event struct {
|
||||
EventFuncs
|
||||
|
||||
StateKey string `json:"state_key,omitempty"` // The state key for the event. Only present on State Events.
|
||||
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)
|
||||
Content map[string]interface{} `json:"content"` // The JSON content of the event.
|
||||
Redacts string `json:"redacts,omitempty"` // The event ID that was redacted if a m.room.redaction event
|
||||
Unsigned Unsigned `json:"unsigned,omitempty"` // Unsigned content set by own homeserver.
|
||||
}
|
||||
|
||||
type Unsigned struct {
|
||||
PrevContent map[string]interface{} `json:"prev_content,omitempty"`
|
||||
PrevSender string `json:"prev_sender,omitempty"`
|
||||
ReplacesState string `json:"replaces_state,omitempty"`
|
||||
Age int64 `json:"age"`
|
||||
}
|
||||
|
||||
type PluginCreatorFunc func(client MatrixClient) Plugin
|
||||
|
||||
type PluginCreator struct {
|
||||
Create PluginCreatorFunc
|
||||
Name string
|
||||
Version string
|
||||
Path string
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue