Documentation
¶
Index ¶
- func BaseURL(u string) error
- func PollingServiceTypes() (types []string)
- func RegisterAuthRealm(factory func(string, string) AuthRealm)
- func RegisterService(factory func(string, id.UserID, string) Service)
- type AuthRealm
- type AuthSession
- type BotOptions
- type BotOptionsContent
- type Command
- type DefaultService
- func (s *DefaultService) Commands(cli MatrixClient) []Command
- func (s *DefaultService) Expansions(cli MatrixClient) []Expansion
- func (s *DefaultService) OnReceiveWebhook(w http.ResponseWriter, req *http.Request, cli MatrixClient)
- func (s *DefaultService) PostRegister(oldService Service)
- func (s *DefaultService) Register(oldService Service, cli MatrixClient) error
- func (s *DefaultService) ServiceID() string
- func (s *DefaultService) ServiceType() string
- func (s *DefaultService) ServiceUserID() id.UserID
- type Expansion
- type GithubOptions
- type MatrixClient
- type Poller
- type Service
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BaseURL ¶
BaseURL sets the base URL of NEB to the url given. This URL must be accessible from the public internet.
func PollingServiceTypes ¶
func PollingServiceTypes() (types []string)
PollingServiceTypes returns a list of service types which meet the Poller interface
func RegisterAuthRealm ¶
RegisterAuthRealm registers a factory for creating AuthRealm instances.
Types ¶
type AuthRealm ¶
type AuthRealm interface { ID() string Type() string Init() error Register() error OnReceiveRedirect(w http.ResponseWriter, req *http.Request) AuthSession(id string, userID id.UserID, realmID string) AuthSession RequestAuthSession(userID id.UserID, config json.RawMessage) interface{} }
AuthRealm represents a place where a user can authenticate themselves. This may static (like github.com) or a specific domain (like matrix.org/jira)
type AuthSession ¶
type AuthSession interface { ID() string UserID() id.UserID RealmID() string Authenticated() bool Info() interface{} }
AuthSession represents a single authentication session between a user and an auth realm.
type BotOptions ¶
type BotOptions struct { RoomID id.RoomID UserID id.UserID SetByUserID id.UserID Options *BotOptionsContent }
BotOptions for a given bot user in a given room
type BotOptionsContent ¶
type BotOptionsContent struct {
Github GithubOptions `json:"github"`
}
type Command ¶
type Command struct { Path []string Arguments []string Help string Command func(roomID id.RoomID, userID id.UserID, arguments []string) (content interface{}, err error) }
A Command is something that a user invokes by sending a message starting with '!' followed by a list of strings that name the command, followed by a list of argument strings. The argument strings may be quoted using '\"' and '\” in the same way that they are quoted in the unix shell.
type DefaultService ¶
type DefaultService struct {
// contains filtered or unexported fields
}
DefaultService NO-OPs the implementation of optional Service interface methods. Feel free to override them.
func NewDefaultService ¶
func NewDefaultService(serviceID string, serviceUserID id.UserID, serviceType string) DefaultService
NewDefaultService creates a new service with implementations for ServiceID(), ServiceType() and ServiceUserID()
func (*DefaultService) Commands ¶
func (s *DefaultService) Commands(cli MatrixClient) []Command
Commands returns no commands.
func (*DefaultService) Expansions ¶
func (s *DefaultService) Expansions(cli MatrixClient) []Expansion
Expansions returns no expansions.
func (*DefaultService) OnReceiveWebhook ¶
func (s *DefaultService) OnReceiveWebhook(w http.ResponseWriter, req *http.Request, cli MatrixClient)
OnReceiveWebhook does nothing but 200 OK the request.
func (*DefaultService) PostRegister ¶
func (s *DefaultService) PostRegister(oldService Service)
PostRegister does nothing.
func (*DefaultService) Register ¶
func (s *DefaultService) Register(oldService Service, cli MatrixClient) error
Register does nothing and returns no error.
func (*DefaultService) ServiceID ¶
func (s *DefaultService) ServiceID() string
ServiceID returns the service's ID. In order for this to return the ID, DefaultService MUST have been initialised by NewDefaultService, the zero-initialiser is NOT enough.
func (*DefaultService) ServiceType ¶
func (s *DefaultService) ServiceType() string
ServiceType returns the type of service. See each individual service package for the ServiceType constant to find out what this value actually is. In order for this to return the Type, DefaultService MUST have been initialised by NewDefaultService, the zero-initialiser is NOT enough.
func (*DefaultService) ServiceUserID ¶
func (s *DefaultService) ServiceUserID() id.UserID
ServiceUserID returns the user ID that the service sends events as. In order for this to return the service user ID, DefaultService MUST have been initialised by NewDefaultService, the zero-initialiser is NOT enough.
type Expansion ¶
type Expansion struct { Regexp *regexp.Regexp Expand func(roomID id.RoomID, userID id.UserID, matchingGroups []string) interface{} }
An Expansion is something that actives when the user sends any message containing a string matching a given pattern. For example an RFC expansion might expand "RFC 6214" into "Adaptation of RFC 1149 for IPv6" and link to the appropriate RFC.
type GithubOptions ¶
type MatrixClient ¶
type MatrixClient interface { // Join a room by ID or alias. Content can optionally specify the request body. JoinRoom(roomIDorAlias, serverName string, content interface{}) (resp *mautrix.RespJoinRoom, err error) // Send a message event to a room. SendMessageEvent(roomID id.RoomID, eventType event.Type, contentJSON interface{}, extra ...mautrix.ReqSendEvent) (resp *mautrix.RespSendEvent, err error) // Upload an HTTP URL. UploadLink(link string) (*mautrix.RespMediaUpload, error) }
MatrixClient represents an object that can communicate with a Matrix server in certain ways that services require.
type Poller ¶
type Poller interface { // OnPoll is called when the poller should poll. Return the timestamp when you want to be polled again. // Return 0 to never be polled again. OnPoll(client MatrixClient) time.Time }
Poller represents a thing which can poll. Services should implement this method signature to support polling.
type Service ¶
type Service interface { // Return the user ID of this service. ServiceUserID() id.UserID // Return an opaque ID used to identify this service. ServiceID() string // Return the type of service. This string MUST NOT change. ServiceType() string Commands(cli MatrixClient) []Command Expansions(cli MatrixClient) []Expansion OnReceiveWebhook(w http.ResponseWriter, req *http.Request, cli MatrixClient) // A lifecycle function which is invoked when the service is being registered. The old service, if one exists, is provided, // along with a Client instance for ServiceUserID(). If this function returns an error, the service will not be registered // or persisted to the database, and the user's request will fail. This can be useful if you depend on external factors // such as registering webhooks. Register(oldService Service, client MatrixClient) error // A lifecycle function which is invoked after the service has been successfully registered and persisted to the database. // This function is invoked within the critical section for configuring services, guaranteeing that there will not be // concurrent modifications to this service whilst this function executes. This lifecycle hook should be used to clean // up resources which are no longer needed (e.g. removing old webhooks). PostRegister(oldService Service) }
A Service is the configuration for a bot service.