synochat

package module
v0.0.0-...-cb211ed Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 28, 2022 License: MIT Imports: 9 Imported by: 1

README

go-synochat

Synology Chat client library in Golang

Why ?

Needs of connect using go code with Synology Chat Server.

It's follow Synology Chat integration.

Installs

go get github.com/0ghny/go-synochat

Usage

// Send a message using an incoming hook to a channel
c, _ := synochat.NewClient("https://your_synology_url") // or your_synology_url:port
err := c.SendMessage(&synochat.ChatMessage{Text: "Hello from automated test"}, "your incoming webhook token")

To learn how to configure an incoming webhook read this.

Read Incoming webhooks to see how format "text" variable to print links, etc.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiResponse

type ApiResponse struct {
	Success bool `json:"success"`
	Error   struct {
		Code   int `json:"code"`
		Errors struct {
			Name   string `json:"name"`
			Reason string `json:"reason"`
		} `json:"errors,omitempty"`
	}
}

"{\"error\":{\"code\":120,\"errors\":{\"name\":\"payload\",\"reason\":\"required\"}},\"success\":false}"

func NewApiResponseFromHttpResponse

func NewApiResponseFromHttpResponse(resp *http.Response) (*ApiResponse, error)

Creates an ApiResponse from an http.Response object

type ChatMessage

type ChatMessage struct {
	Text string `json:"text"`
}

type Client

type Client struct {
	BaseURL *url.URL
	// contains filtered or unexported fields
}

func NewClient

func NewClient(baseURL string) (*Client, error)

func NewCustomClient

func NewCustomClient(baseURL string, httpClient *http.Client) (*Client, error)

func (*Client) SendMessage

func (c *Client) SendMessage(msg *ChatMessage, token string) error

type ClientOpts

type ClientOpts struct {
	BaseUrl    string
	HTTPClient *http.Client
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL