From 8ebff5e31cd12e6c9c95296346ab821f3beb50f3 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Fri, 4 Nov 2016 11:19:15 +0000 Subject: [PATCH] Update GH pages --- pkg/github.com/index.html | 23 +- .../matrix-org/go-neb/clients/index.html | 10 +- pkg/github.com/matrix-org/go-neb/index.html | 23 +- .../matrix-org/go-neb/plugin/index.html | 314 ------------------ .../go-neb/services/echo/index.html | 67 +++- .../go-neb/services/giphy/index.html | 77 ++++- .../go-neb/services/github/index.html | 287 +++++++++++++++- .../go-neb/services/guggy/index.html | 76 ++++- .../matrix-org/go-neb/services/index.html | 12 +- .../go-neb/services/jira/index.html | 167 +++++++++- .../go-neb/services/rssbot/index.html | 134 +++++++- .../matrix-org/go-neb/types/index.html | 211 ++++++++++-- pkg/github.com/matrix-org/index.html | 23 +- 13 files changed, 1005 insertions(+), 419 deletions(-) delete mode 100644 pkg/github.com/matrix-org/go-neb/plugin/index.html diff --git a/pkg/github.com/index.html b/pkg/github.com/index.html index 5f90a89..f097d57 100644 --- a/pkg/github.com/index.html +++ b/pkg/github.com/index.html @@ -845,17 +845,6 @@ - - - plugin - - - - - - - - polling @@ -938,7 +927,7 @@ echo - + Package echo implements a Service which echoes back !commands. @@ -949,7 +938,7 @@ giphy - + Package giphy implements a Service which adds !commands for Giphy. @@ -960,7 +949,7 @@ github - + Package github implements a command service and a webhook service for interacting with Github. @@ -993,7 +982,7 @@ guggy - + Package guggy implements a Service which adds !commands for Guggy. @@ -1004,7 +993,7 @@ jira - + Package jira implements a command and webhook service for interacting with JIRA. @@ -1026,7 +1015,7 @@ rssbot - + Package rssbot implements a Service capable of reading Atom/RSS feeds. diff --git a/pkg/github.com/matrix-org/go-neb/clients/index.html b/pkg/github.com/matrix-org/go-neb/clients/index.html index 311233a..395daad 100644 --- a/pkg/github.com/matrix-org/go-neb/clients/index.html +++ b/pkg/github.com/matrix-org/go-neb/clients/index.html @@ -185,7 +185,7 @@ -

type Clients

+

type Clients

type Clients struct {
     // contains filtered or unexported fields
 }
@@ -204,7 +204,7 @@ A Clients is a collection of clients used for bot services. -

func New

+

func New

func New(db *database.ServiceDB, cli *http.Client) *Clients

New makes a new collection of matrix clients @@ -216,7 +216,7 @@ New makes a new collection of matrix clients -

func (*Clients) Client

+

func (*Clients) Client

func (c *Clients) Client(userID string) (*matrix.Client, error)

Client gets a client for the userID @@ -227,7 +227,7 @@ Client gets a client for the userID -

func (*Clients) Start

+

func (*Clients) Start

func (c *Clients) Start() error

Start listening on client /sync streams @@ -238,7 +238,7 @@ Start listening on client /sync streams -

func (*Clients) Update

+

func (*Clients) Update

func (c *Clients) Update(config api.ClientConfig) (api.ClientConfig, error)

Update updates the config for a matrix client diff --git a/pkg/github.com/matrix-org/go-neb/index.html b/pkg/github.com/matrix-org/go-neb/index.html index 654afaf..c128740 100644 --- a/pkg/github.com/matrix-org/go-neb/index.html +++ b/pkg/github.com/matrix-org/go-neb/index.html @@ -177,17 +177,6 @@ - - - plugin - - - - - - - - polling @@ -270,7 +259,7 @@ echo - + Package echo implements a Service which echoes back !commands. @@ -281,7 +270,7 @@ giphy - + Package giphy implements a Service which adds !commands for Giphy. @@ -292,7 +281,7 @@ github - + Package github implements a command service and a webhook service for interacting with Github. @@ -325,7 +314,7 @@ guggy - + Package guggy implements a Service which adds !commands for Guggy. @@ -336,7 +325,7 @@ jira - + Package jira implements a command and webhook service for interacting with JIRA. @@ -358,7 +347,7 @@ rssbot - + Package rssbot implements a Service capable of reading Atom/RSS feeds. diff --git a/pkg/github.com/matrix-org/go-neb/plugin/index.html b/pkg/github.com/matrix-org/go-neb/plugin/index.html deleted file mode 100644 index cb66123..0000000 --- a/pkg/github.com/matrix-org/go-neb/plugin/index.html +++ /dev/null @@ -1,314 +0,0 @@ - - - - - - - - plugin - The Go Programming Language - - - - - - - - -

-... -
- -
- - - -
-
- - -

Package plugin

- - - - - - - - - - - - - - -
-
-
import "github.com/matrix-org/go-neb/plugin"
-
-
-
Overview
-
Index
- - -
-
- -
- -
-

Overview ▾

- -
-
- - -
- -
-

Index ▾

- - - - - - - -

Package files

-

- - - plugin.go - - -

- -
-
- - - - - - - - -

func OnMessage

-
func OnMessage(plugins []Plugin, client *matrix.Client, event *matrix.Event)
-

-OnMessage checks the message event to see whether it contains any commands -or expansions from the listed plugins and processes those commands or -expansions. -

- - - - - - - - -

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 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 Plugin

-
type Plugin struct {
-    Commands   []Command
-    Expansions []Expansion
-}
-

-A Plugin is a list of commands and expansions to apply to incoming messages. -

- - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- - - - - - - - - - - - diff --git a/pkg/github.com/matrix-org/go-neb/services/echo/index.html b/pkg/github.com/matrix-org/go-neb/services/echo/index.html index 47a8e44..67da52f 100644 --- a/pkg/github.com/matrix-org/go-neb/services/echo/index.html +++ b/pkg/github.com/matrix-org/go-neb/services/echo/index.html @@ -5,7 +5,7 @@ - services - The Go Programming Language + echo - The Go Programming Language @@ -42,7 +42,7 @@
-

Package services

+

Package echo

@@ -87,7 +87,10 @@

Overview ▾

- +

+Package echo implements a Service which echoes back !commands. +

+
@@ -103,10 +106,20 @@
+
Constants
+ +
type Service
+ + + +
    func (e *Service) Commands(cli *matrix.Client, roomID string) []types.Command
+ + +
@@ -163,9 +176,57 @@ +

Constants

+ +
const ServiceType = "echo"
+

+ServiceType of the Echo service +

+ + + + + +

type Service

+
type Service struct {
+    types.DefaultService
+}
+

+Service represents the Echo service. It has no Config fields. +

+ + + + + + + + + + + + + + +

func (*Service) Commands

+
func (e *Service) Commands(cli *matrix.Client, roomID string) []types.Command
+

+Commands supported: +

+
!echo some message
+
+

+Responds with a notice of "some message". +

+ + + + + + diff --git a/pkg/github.com/matrix-org/go-neb/services/giphy/index.html b/pkg/github.com/matrix-org/go-neb/services/giphy/index.html index ec7b9bf..79c9306 100644 --- a/pkg/github.com/matrix-org/go-neb/services/giphy/index.html +++ b/pkg/github.com/matrix-org/go-neb/services/giphy/index.html @@ -5,7 +5,7 @@ - services - The Go Programming Language + giphy - The Go Programming Language @@ -42,7 +42,7 @@
-

Package services

+

Package giphy

@@ -87,7 +87,10 @@

Overview ▾

- +

+Package giphy implements a Service which adds !commands for Giphy. +

+
@@ -103,10 +106,20 @@
+
Constants
+ +
type Service
+ + + +
    func (s *Service) Commands(client *matrix.Client, roomID string) []types.Command
+ + +
@@ -163,9 +176,67 @@ +

Constants

+ +
const ServiceType = "giphy"
+

+ServiceType of the Giphy service. +

+ + + + + +

type Service

+
type Service struct {
+    types.DefaultService
+    // The Giphy API key to use when making HTTP requests to Giphy.
+    // The public beta API key is "dc6zaTOxFJmzC".
+    APIKey string `json:"api_key"`
+}
+

+Service contains the Config fields for the Giphy Service. +

+

+Example: +

+
{
+    "api_key": "dc6zaTOxFJmzC"
+}
+
+ + + + + + + + + + + + + + +

func (*Service) Commands

+
func (s *Service) Commands(client *matrix.Client, roomID string) []types.Command
+

+Commands supported: +

+
!giphy some search query without quotes
+
+

+Responds with a suitable GIF into the same room as the command. +

+ + + + + + diff --git a/pkg/github.com/matrix-org/go-neb/services/github/index.html b/pkg/github.com/matrix-org/go-neb/services/github/index.html index c1f1e0b..7ab3430 100644 --- a/pkg/github.com/matrix-org/go-neb/services/github/index.html +++ b/pkg/github.com/matrix-org/go-neb/services/github/index.html @@ -5,7 +5,7 @@ - services - The Go Programming Language + github - The Go Programming Language @@ -42,7 +42,7 @@
-

Package services

+

Package github

@@ -89,7 +89,14 @@

Overview ▾

- +

+Package github implements a command service and a webhook service for interacting with Github. +

+

+The command service is a service which adds !commands and issue expansions for Github. The +webhook service adds Github webhook support. +

+
@@ -105,9 +112,39 @@
+
Constants
+ + +
type Service
+ + + +
    func (s *Service) Commands(cli *matrix.Client, roomID string) []types.Command
+ + +
    func (s *Service) Expansions(cli *matrix.Client, roomID string) []types.Expansion
+ + +
    func (s *Service) Register(oldService types.Service, client *matrix.Client) error
+ + + +
type WebhookService
+ + + +
    func (s *WebhookService) OnReceiveWebhook(w http.ResponseWriter, req *http.Request, cli *matrix.Client)
+ + +
    func (s *WebhookService) PostRegister(oldService types.Service)
+ + +
    func (s *WebhookService) Register(oldService types.Service, client *matrix.Client) error
+ +
@@ -167,8 +204,252 @@ +

Constants

+ +
const ServiceType = "github"
+

+ServiceType of the Github service +

+ + +
const WebhookServiceType = "github-webhook"
+

+WebhookServiceType of the Github Webhook service. +

+ + + + + + +

type Service

+
type Service struct {
+    types.DefaultService
+    // The ID of an existing "github" realm. This realm will be used to obtain
+    // credentials of users when they create issues on Github.
+    RealmID string
+}
+

+Service contains the Config fields for the Github service. +

+

+Before you can set up a Github Service, you need to set up a Github Realm. This +service requires a syncing client. +

+

+You can set a "default repository" for a Matrix room by sending a `m.room.bot.options` state event +which has the following `content`: +

+
{
+  "github": {
+    "default_repo": "owner/repo"
+  }
+}
+
+

+This will allow the "owner/repo" to be omitted when creating/expanding issues. +

+

+Example: +

+
{
+    "RealmID": "github-realm-id"
+}
+
+ + + + + + + + + + + + + + +

func (*Service) Commands

+
func (s *Service) Commands(cli *matrix.Client, roomID string) []types.Command
+

+Commands supported: +

+
!github create owner/repo "issue title" "optional issue description"
+
+

+Responds with the outcome of the issue creation request. This command requires +a Github account to be linked to the Matrix user ID issuing the command. If there +is no link, it will return a Starter Link instead. +

+ + + + + + +

func (*Service) Expansions

+
func (s *Service) Expansions(cli *matrix.Client, roomID string) []types.Expansion
+

+Expansions expands strings of the form: +

+
owner/repo#12
+
+

+Where #12 is an issue number or pull request. If there is a default repository set on the room, +it will also expand strings of the form: +

+
#12
+
+

+using the default repository. +

+ + + + + + +

func (*Service) Register

+
func (s *Service) Register(oldService types.Service, client *matrix.Client) error
+

+Register makes sure that the given realm ID maps to a github realm. +

+ + + + + + + + +

type WebhookService

+
type WebhookService struct {
+    types.DefaultService
+
+    // The user ID to create/delete webhooks as.
+    ClientUserID string
+    // The ID of an existing "github" realm. This realm will be used to obtain
+    // the Github credentials of the ClientUserID.
+    RealmID string
+    // A map from Matrix room ID to Github "owner/repo"-style repositories.
+    Rooms map[string]struct {
+        // A map of "owner/repo"-style repositories to the events to listen for.
+        Repos map[string]struct {
+            // The webhook events to listen for. Currently supported:
+            //    push : When users push to this repository.
+            //    pull_request : When a pull request is made to this repository.
+            //    issues : When an issue is opened/closed.
+            //    issue_comment : When an issue or pull request is commented on.
+            //    pull_request_review_comment : When a line comment is made on a pull request.
+            // Full list: https://developer.github.com/webhooks/#events
+            Events []string
+        }
+    }
+    // Optional. The secret token to supply when creating the webhook. If supplied,
+    // Go-NEB will perform security checks on incoming webhook requests using this token.
+    SecretToken string
+    // contains filtered or unexported fields
+}
+

+WebhookService contains the Config fields for the Github Webhook Service. +

+

+Before you can set up a Github Service, you need to set up a Github Realm. This +service does not require a syncing client. +

+

+This service will send notices into a Matrix room when Github sends webhook events +to it. It requires a public domain which Github can reach. Notices will be sent +as the service user ID, not the ClientUserID. +

+

+Example: +

+
{
+    ClientUserID: "@alice:localhost",
+    RealmID: "github-realm-id",
+    Rooms: {
+        "!qmElAGdFYCHoCJuaNt:localhost": {
+            Repos: {
+                "matrix-org/go-neb": {
+                    Events: ["push", "issues", "pull_request"]
+                }
+            }
+        }
+    }
+}
+
+ + + + + + + + + + + + + + +

func (*WebhookService) OnReceiveWebhook

+
func (s *WebhookService) OnReceiveWebhook(w http.ResponseWriter, req *http.Request, cli *matrix.Client)
+

+OnReceiveWebhook receives requests from Github and possibly sends requests to Matrix as a result. +

+

+If the "owner/repo" string in the webhook request case-insensitively matches a repo in this Service +config AND the event type matches an event type registered for that repo, then a message will be sent +into Matrix. +

+

+If the "owner/repo" string doesn't exist in this Service config, then the webhook will be deleted from +Github. +

+ + + + + + +

func (*WebhookService) PostRegister

+
func (s *WebhookService) PostRegister(oldService types.Service)
+

+PostRegister cleans up removed repositories from the old service by +working out the delta between the old and new hooks. +

+ + + + + + +

func (*WebhookService) Register

+
func (s *WebhookService) Register(oldService types.Service, client *matrix.Client) error
+

+Register will create webhooks for the repos specified in Rooms +

+

+The hooks made are a delta between the old service and the current configuration. If all webhooks are made, +Register() succeeds. If any webhook fails to be created, Register() fails. A delta is used to allow clients to incrementally +build up the service config without recreating the hooks every time a change is made. +

+

+Hooks are deleted when this service receives a webhook event from Github for a repo which has no user configurations. +

+

+Hooks can get out of sync if a user manually deletes a hook in the Github UI. In this case, toggling the repo configuration will +force NEB to recreate the hook. +

+ + + + + diff --git a/pkg/github.com/matrix-org/go-neb/services/guggy/index.html b/pkg/github.com/matrix-org/go-neb/services/guggy/index.html index 8adf7ba..a652eff 100644 --- a/pkg/github.com/matrix-org/go-neb/services/guggy/index.html +++ b/pkg/github.com/matrix-org/go-neb/services/guggy/index.html @@ -5,7 +5,7 @@ - services - The Go Programming Language + guggy - The Go Programming Language @@ -42,7 +42,7 @@
-

Package services

+

Package guggy

@@ -87,7 +87,10 @@

Overview ▾

- +

+Package guggy implements a Service which adds !commands for Guggy. +

+
@@ -103,10 +106,20 @@
+
Constants
+ +
type Service
+ + + +
    func (s *Service) Commands(client *matrix.Client, roomID string) []types.Command
+ + +
@@ -163,9 +176,66 @@ +

Constants

+ +
const ServiceType = "guggy"
+

+ServiceType of the Guggy service +

+ + + + + +

type Service

+
type Service struct {
+    types.DefaultService
+    // The Guggy API key to use when making HTTP requests to Guggy.
+    APIKey string `json:"api_key"`
+}
+

+Service contains the Config fields for the Guggy service. +

+

+Example: +

+
{
+    "api_key": "fkweugfyuwegfweyg"
+}
+
+ + + + + + + + + + + + + + +

func (*Service) Commands

+
func (s *Service) Commands(client *matrix.Client, roomID string) []types.Command
+

+Commands supported: +

+
!guggy some search query without quotes
+
+

+Responds with a suitable GIF into the same room as the command. +

+ + + + + + diff --git a/pkg/github.com/matrix-org/go-neb/services/index.html b/pkg/github.com/matrix-org/go-neb/services/index.html index c80a387..83cd0b1 100644 --- a/pkg/github.com/matrix-org/go-neb/services/index.html +++ b/pkg/github.com/matrix-org/go-neb/services/index.html @@ -91,7 +91,7 @@ echo - + Package echo implements a Service which echoes back !commands. @@ -102,7 +102,7 @@ giphy - + Package giphy implements a Service which adds !commands for Giphy. @@ -113,7 +113,7 @@ github - + Package github implements a command service and a webhook service for interacting with Github. @@ -146,7 +146,7 @@ guggy - + Package guggy implements a Service which adds !commands for Guggy. @@ -157,7 +157,7 @@ jira - + Package jira implements a command and webhook service for interacting with JIRA. @@ -179,7 +179,7 @@ rssbot - + Package rssbot implements a Service capable of reading Atom/RSS feeds. diff --git a/pkg/github.com/matrix-org/go-neb/services/jira/index.html b/pkg/github.com/matrix-org/go-neb/services/jira/index.html index 261d1de..c0c4657 100644 --- a/pkg/github.com/matrix-org/go-neb/services/jira/index.html +++ b/pkg/github.com/matrix-org/go-neb/services/jira/index.html @@ -5,7 +5,7 @@ - services - The Go Programming Language + jira - The Go Programming Language @@ -42,7 +42,7 @@
-

Package services

+

Package jira

@@ -89,7 +89,13 @@

Overview ▾

- +

+Package jira implements a command and webhook service for interacting with JIRA. +

+

+The service adds !commands and issue expansions, in addition to JIRA webhook support. +

+
@@ -105,8 +111,27 @@
+
Constants
+ + + +
type Service
+ + + +
    func (s *Service) Commands(cli *matrix.Client, roomID string) []types.Command
+ + +
    func (s *Service) Expansions(cli *matrix.Client, roomID string) []types.Expansion
+ + +
    func (s *Service) OnReceiveWebhook(w http.ResponseWriter, req *http.Request, cli *matrix.Client)
+ + +
    func (s *Service) Register(oldService types.Service, client *matrix.Client) error
+
@@ -165,8 +190,144 @@
+

Constants

+ +
const ServiceType = "jira"
+

+ServiceType of the JIRA Service +

+ + + + + + +

type Service

+
type Service struct {
+    types.DefaultService
+
+    // The user ID to create issues as, or to create/delete webhooks as. This user
+    // is also used to look up issues for expansions.
+    ClientUserID string
+    // A map from Matrix room ID to JIRA realms and project keys.
+    Rooms map[string]struct {
+        // A map of realm IDs to project keys. The realm IDs determine the JIRA
+        // endpoint used.
+        Realms map[string]struct {
+            // A map of project keys e.g. "SYN" to config options.
+            Projects map[string]struct {
+                // True to expand issues with this key e.g "SYN-123" will be expanded.
+                Expand bool
+                // True to add a webhook to this project and send updates into the room.
+                Track bool
+            }
+        }
+    }
+    // contains filtered or unexported fields
+}
+

+Service contains the Config fields for the JIRA service. +

+

+Before you can set up a JIRA Service, you need to set up a JIRA Realm. +

+

+Example: +

+
{
+    Rooms: {
+        "!qmElAGdFYCHoCJuaNt:localhost": {
+            Realms: {
+                "jira-realm-id": {
+                    Projects: {
+                        "SYN": { Expand: true },
+                        "BOTS": { Expand: true, Track: true }
+                    }
+                }
+            }
+        }
+    }
+}
+
+ + + + + + + + + + + + + + +

func (*Service) Commands

+
func (s *Service) Commands(cli *matrix.Client, roomID string) []types.Command
+

+Commands supported: +

+
!jira create KEY "issue title" "optional issue description"
+
+

+Responds with the outcome of the issue creation request. This command requires +a JIRA account to be linked to the Matrix user ID issuing the command. It also +requires there to be a project with the given project key (e.g. "KEY") to exist +on the linked JIRA account. If there are multiple JIRA accounts which contain the +same project key, which project is chosen is undefined. If there +is no JIRA account linked to the Matrix user ID, it will return a Starter Link +if there is a known public project with that project key. +

+ + + + + + +

func (*Service) Expansions

+
func (s *Service) Expansions(cli *matrix.Client, roomID string) []types.Expansion
+

+Expansions expands JIRA issues represented as: +

+
KEY-12
+
+

+Where "KEY" is the project key and 12" is an issue number. The Service Config will be used +to map the project key to a realm, and subsequently the JIRA endpoint to hit. +If there are multiple projects with the same project key in the Service Config, one will +be chosen arbitrarily. +

+ + + + + + +

func (*Service) OnReceiveWebhook

+
func (s *Service) OnReceiveWebhook(w http.ResponseWriter, req *http.Request, cli *matrix.Client)
+

+OnReceiveWebhook receives requests from JIRA and possibly sends requests to Matrix as a result. +

+ + + + + + +

func (*Service) Register

+
func (s *Service) Register(oldService types.Service, client *matrix.Client) error
+

+Register ensures that the given realm IDs are valid JIRA realms and registers webhooks +with those JIRA endpoints. +

+ + + + + diff --git a/pkg/github.com/matrix-org/go-neb/services/rssbot/index.html b/pkg/github.com/matrix-org/go-neb/services/rssbot/index.html index 2e74be2..f6cf301 100644 --- a/pkg/github.com/matrix-org/go-neb/services/rssbot/index.html +++ b/pkg/github.com/matrix-org/go-neb/services/rssbot/index.html @@ -5,7 +5,7 @@ - services - The Go Programming Language + rssbot - The Go Programming Language @@ -42,7 +42,7 @@
-

Package services

+

Package rssbot

@@ -87,7 +87,10 @@

Overview ▾

- +

+Package rssbot implements a Service capable of reading Atom/RSS feeds. +

+
@@ -103,10 +106,26 @@
+
Constants
+ +
type Service
+ + + +
    func (s *Service) OnPoll(cli *matrix.Client) time.Time
+ + +
    func (s *Service) PostRegister(oldService types.Service)
+ + +
    func (s *Service) Register(oldService types.Service, client *matrix.Client) error
+ + +
@@ -163,9 +182,118 @@ +

Constants

+ +
const ServiceType = "rssbot"
+

+ServiceType of the RSS Bot service +

+ + + + + +

type Service

+
type Service struct {
+    types.DefaultService
+    // Feeds is a map of feed URL to configuration options for this feed.
+    Feeds map[string]struct {
+        // Optional. The time to wait between polls. If this is less than minPollingIntervalSeconds, it is ignored.
+        PollIntervalMins int `json:"poll_interval_mins"`
+        // The list of rooms to send feed updates into. This cannot be empty.
+        Rooms []string `json:"rooms"`
+        // True if rss bot is unable to poll this feed. This is populated by Go-NEB. Use /getService to
+        // retrieve this value.
+        IsFailing bool `json:"is_failing"`
+        // The time of the last successful poll. This is populated by Go-NEB. Use /getService to retrieve
+        // this value.
+        FeedUpdatedTimestampSecs int64 `json:"last_updated_ts_secs"`
+        // Internal field. When we should poll again.
+        NextPollTimestampSecs int64
+        // Internal field. The most recently seen GUIDs. Sized to the number of items in the feed.
+        RecentGUIDs []string
+    } `json:"feeds"`
+}
+

+Service contains the Config fields for this service. +

+

+Example: +

+
{
+    feeds: {
+        "http://rss.cnn.com/rss/edition.rss": {
+             poll_interval_mins: 60,
+             rooms: ["!cBrPbzWazCtlkMNQSF:localhost"]
+        },
+        "https://www.wired.com/feed/": {
+             rooms: ["!qmElAGdFYCHoCJuaNt:localhost"]
+        }
+    }
+}
+
+ + + + + + + + + + + + + + +

func (*Service) OnPoll

+
func (s *Service) OnPoll(cli *matrix.Client) time.Time
+

+OnPoll rechecks RSS feeds which are due to be polled. +

+

+In order for a feed to be polled, the current time must be greater than NextPollTimestampSecs. +In order for an item on a feed to be sent to Matrix, the item's GUID must not exist in RecentGUIDs. +The GUID for an item is created according to the following rules: +

+
- If there is a GUID field, use it.
+- Else if there is a Link field, use it as the GUID.
+- Else if there is a Title field, use it as the GUID.
+
+

+Returns a timestamp representing when this Service should have OnPoll called again. +

+ + + + + + +

func (*Service) PostRegister

+
func (s *Service) PostRegister(oldService types.Service)
+

+PostRegister deletes this service if there are no feeds remaining. +

+ + + + + + +

func (*Service) Register

+
func (s *Service) Register(oldService types.Service, client *matrix.Client) error
+

+Register will check the liveness of each RSS feed given. If all feeds check out okay, no error is returned. +

+ + + + + + diff --git a/pkg/github.com/matrix-org/go-neb/types/index.html b/pkg/github.com/matrix-org/go-neb/types/index.html index 33d50f6..e9ad77a 100644 --- a/pkg/github.com/matrix-org/go-neb/types/index.html +++ b/pkg/github.com/matrix-org/go-neb/types/index.html @@ -137,14 +137,28 @@ +
type Command
+ + + +
    func (command *Command) Matches(arguments []string) bool
+ + +
type DefaultService
+ +
    func NewDefaultService(serviceID, serviceUserID, serviceType string) DefaultService
+ -
    func (s *DefaultService) OnReceiveWebhook(w http.ResponseWriter, req *http.Request, cli *matrix.Client)
+
    func (s *DefaultService) Commands(cli *matrix.Client, roomID string) []Command
+ + +
    func (s *DefaultService) Expansions(cli *matrix.Client, roomID string) []Expansion
-
    func (s *DefaultService) Plugin(cli *matrix.Client, roomID string) plugin.Plugin
+
    func (s *DefaultService) OnReceiveWebhook(w http.ResponseWriter, req *http.Request, cli *matrix.Client)
    func (s *DefaultService) PostRegister(oldService Service)
@@ -152,6 +166,20 @@
    func (s *DefaultService) Register(oldService Service, client *matrix.Client) error
+ +
    func (s *DefaultService) ServiceID() string
+ + +
    func (s *DefaultService) ServiceType() string
+ + +
    func (s *DefaultService) ServiceUserID() string
+ + + +
type Expansion
+ +
type Poller
@@ -177,7 +205,11 @@

- types.go + actions.go + + auth.go + + service.go

@@ -227,7 +259,7 @@ -

func BaseURL

+

func BaseURL

func BaseURL(u string) error

BaseURL sets the base URL of NEB to the url given. This URL must be accessible from the @@ -240,7 +272,7 @@ public internet. -

func PollingServiceTypes

+

func PollingServiceTypes

func PollingServiceTypes() (types []string)

PollingServiceTypes returns a list of service types which meet the Poller interface @@ -252,7 +284,7 @@ PollingServiceTypes returns a list of service types which meet the Poller interf -

func RegisterAuthRealm

+

func RegisterAuthRealm

func RegisterAuthRealm(factory func(string, string) AuthRealm)

RegisterAuthRealm registers a factory for creating AuthRealm instances. @@ -264,7 +296,7 @@ RegisterAuthRealm registers a factory for creating AuthRealm instances. -

func RegisterService

+

func RegisterService

func RegisterService(factory func(string, string, string) Service)

RegisterService registers a factory for creating Service instances. @@ -277,7 +309,7 @@ RegisterService registers a factory for creating Service instances. -

type AuthRealm

+

type AuthRealm

type AuthRealm interface {
     ID() string
     Type() string
@@ -303,7 +335,7 @@ This may static (like github.com) or a specific domain (like matrix.org/jira)
 
 			
 				
-				

func CreateAuthRealm

+

func CreateAuthRealm

func CreateAuthRealm(realmID, realmType string, realmJSON []byte) (AuthRealm, error)

CreateAuthRealm creates an AuthRealm of the given type and realm ID. @@ -318,7 +350,7 @@ Returns an error if the realm couldn't be created or the JSON cannot be unma -

type AuthSession

+

type AuthSession

type AuthSession interface {
     ID() string
     UserID() string
@@ -346,7 +378,7 @@ an auth realm.
 		
 			
 			
-			

type BotOptions

+

type BotOptions

type BotOptions struct {
     RoomID      string
     UserID      string
@@ -372,8 +404,50 @@ BotOptions for a given bot user in a given room
 		
 			
 			
-			

type DefaultService

-
type DefaultService struct{}
+

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. +

+ + + + + + + + + + + + + + +

func (*Command) Matches

+
func (command *Command) Matches(arguments []string) bool
+

+Matches if the arguments start with the path of the command. +

+ + + + + + + + +

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.

@@ -388,13 +462,34 @@ DefaultService NO-OPs the implementation of optional Service interface methods. + +

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 *matrix.Client, roomID string) []Command
+

+Commands returns no commands. +

+ + + -

func (*DefaultService) OnReceiveWebhook

-
func (s *DefaultService) OnReceiveWebhook(w http.ResponseWriter, req *http.Request, cli *matrix.Client)
+

func (*DefaultService) Expansions

+
func (s *DefaultService) Expansions(cli *matrix.Client, roomID string) []Expansion

-OnReceiveWebhook does nothing but 200 OK the request. +Expansions returns no expansions.

@@ -402,10 +497,10 @@ OnReceiveWebhook does nothing but 200 OK the request. -

func (*DefaultService) Plugin

-
func (s *DefaultService) Plugin(cli *matrix.Client, roomID string) plugin.Plugin
+

func (*DefaultService) OnReceiveWebhook

+
func (s *DefaultService) OnReceiveWebhook(w http.ResponseWriter, req *http.Request, cli *matrix.Client)

-Plugin returns no plugins. +OnReceiveWebhook does nothing but 200 OK the request.

@@ -413,7 +508,7 @@ Plugin returns no plugins. -

func (*DefaultService) PostRegister

+

func (*DefaultService) PostRegister

func (s *DefaultService) PostRegister(oldService Service)

PostRegister does nothing. @@ -424,7 +519,7 @@ PostRegister does nothing. -

func (*DefaultService) Register

+

func (*DefaultService) Register

func (s *DefaultService) Register(oldService Service, client *matrix.Client) error

Register does nothing and returns no error. @@ -434,10 +529,75 @@ 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

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.
@@ -462,7 +622,7 @@ Poller represents a thing which can poll. Services should implement this method
 		
 			
 			
-			

type Service

+

type Service

type Service interface {
     // Return the user ID of this service.
     ServiceUserID() string
@@ -470,7 +630,8 @@ Poller represents a thing which can poll. Services should implement this method
     ServiceID() string
     // Return the type of service. This string MUST NOT change.
     ServiceType() string
-    Plugin(cli *matrix.Client, roomID string) plugin.Plugin
+    Commands(cli *matrix.Client, roomID string) []Command
+    Expansions(cli *matrix.Client, roomID string) []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
@@ -498,7 +659,7 @@ A Service is the configuration for a bot service.
 
 			
 				
-				

func CreateService

+

func CreateService

func CreateService(serviceID, serviceType, serviceUserID string, serviceJSON []byte) (Service, error)

CreateService creates a Service of the given type and serviceID. diff --git a/pkg/github.com/matrix-org/index.html b/pkg/github.com/matrix-org/index.html index 560090c..c7b3988 100644 --- a/pkg/github.com/matrix-org/index.html +++ b/pkg/github.com/matrix-org/index.html @@ -185,17 +185,6 @@ - - - plugin - - - - - - - - polling @@ -278,7 +267,7 @@ echo - + Package echo implements a Service which echoes back !commands. @@ -289,7 +278,7 @@ giphy - + Package giphy implements a Service which adds !commands for Giphy. @@ -300,7 +289,7 @@ github - + Package github implements a command service and a webhook service for interacting with Github. @@ -333,7 +322,7 @@ guggy - + Package guggy implements a Service which adds !commands for Guggy. @@ -344,7 +333,7 @@ jira - + Package jira implements a command and webhook service for interacting with JIRA. @@ -366,7 +355,7 @@ rssbot - + Package rssbot implements a Service capable of reading Atom/RSS feeds.