func BaseURL(u string) error
BaseURL sets the base URL of NEB to the url given. This URL must be accessible from the public internet.
func PollingServiceTypes() (types []string)
PollingServiceTypes returns a list of service types which meet the Poller interface
func RegisterAuthRealm(factory func(string, string) AuthRealm)
RegisterAuthRealm registers a factory for creating AuthRealm instances.
func RegisterService(factory func(string, string, string) Service)
RegisterService registers a factory for creating Service instances.
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)
func CreateAuthRealm(realmID, realmType string, realmJSON []byte) (AuthRealm, error)
CreateAuthRealm creates an AuthRealm of the given type and realm ID. Returns an error if the realm couldn't be created or the JSON cannot be unmarshalled.
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 struct { RoomID string UserID string SetByUserID string Options map[string]interface{} }
BotOptions for a given bot user in a given room
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.
func (command *Command) Matches(arguments []string) bool
Matches if the arguments start with the path of the command.
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(serviceID, serviceUserID, serviceType string) DefaultService
NewDefaultService creates a new service with implementations for ServiceID(), ServiceType() and ServiceUserID()
func (s *DefaultService) Commands(cli *matrix.Client) []Command
Commands returns no commands.
func (s *DefaultService) Expansions(cli *matrix.Client) []Expansion
Expansions returns no expansions.
func (s *DefaultService) OnReceiveWebhook(w http.ResponseWriter, req *http.Request, cli *matrix.Client)
OnReceiveWebhook does nothing but 200 OK the request.
func (s *DefaultService) PostRegister(oldService Service)
PostRegister does nothing.
func (s *DefaultService) Register(oldService Service, client *matrix.Client) error
Register does nothing and returns no error.
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 (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 (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 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 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 *matrix.Client) time.Time }
Poller represents a thing which can poll. Services should implement this method signature to support polling.
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 *matrix.Client) []Command Expansions(cli *matrix.Client) []Expansion OnReceiveWebhook(w http.ResponseWriter, req *http.Request, cli *matrix.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 *matrix.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.
func CreateService(serviceID, serviceType, serviceUserID string, serviceJSON []byte) (Service, error)
CreateService creates a Service of the given type and serviceID. Returns an error if the Service couldn't be created.