Documentation ¶
Index ¶
- func BaseURL(u string) error
- func PollingServiceTypes() (types []string)
- func RegisterAuthRealm(factory func(string, string) AuthRealm)
- func RegisterService(factory func(string, string, string) Service)
- type AuthRealm
- type AuthSession
- type BotOptions
- type Command
- type DefaultService
- func (s *DefaultService) Commands(cli *gomatrix.Client) []Command
- func (s *DefaultService) Expansions(cli *gomatrix.Client) []Expansion
- func (s *DefaultService) OnReceiveWebhook(w http.ResponseWriter, req *http.Request, cli *gomatrix.Client)
- func (s *DefaultService) PostRegister(oldService Service)
- func (s *DefaultService) Register(oldService Service, client *gomatrix.Client) error
- func (s *DefaultService) ServiceID() string
- func (s *DefaultService) ServiceType() string
- func (s *DefaultService) ServiceUserID() string
- type Expansion
- 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, userID, realmID string) AuthSession RequestAuthSession(userID string, 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() string 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 string UserID string SetByUserID string Options map[string]interface{} }
BotOptions for a given bot user in a given room
type Command ¶
type Command struct { Path []string Arguments []string Help string Command func(roomID, userID string, 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, serviceUserID, serviceType string) DefaultService
NewDefaultService creates a new service with implementations for ServiceID(), ServiceType() and ServiceUserID()
func (*DefaultService) Commands ¶
func (s *DefaultService) Commands(cli *gomatrix.Client) []Command
Commands returns no commands.
func (*DefaultService) Expansions ¶
func (s *DefaultService) Expansions(cli *gomatrix.Client) []Expansion
Expansions returns no expansions.
func (*DefaultService) OnReceiveWebhook ¶
func (s *DefaultService) OnReceiveWebhook(w http.ResponseWriter, req *http.Request, cli *gomatrix.Client)
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, client *gomatrix.Client) 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() string
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, userID string, 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 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 *gomatrix.Client) 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() string // 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 *gomatrix.Client) []Command Expansions(cli *gomatrix.Client) []Expansion OnReceiveWebhook(w http.ResponseWriter, req *http.Request, cli *gomatrix.Client) // 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 *gomatrix.Client) 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.