synologychat

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

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

Go to latest
Published: May 8, 2024 License: MIT Imports: 8 Imported by: 0

README

go-synology-chat

Simple wrapper to send Messages to Synology Chat in Go

About

Simple wrapper to send Messages to Synology Chat in Go

🌟 If you want a Node.js version, please check synology-chat-communicator 🌟

❤️ Awesome Features:

  • Out of the box simple Interface. 🔥
  • Added support for multimedia messages 🍺
  • Simple way to send direct messages to one or many users 🎉
  • Direct support to list users and channels 🔊
  • Zero dependencies 💪
  • Easy to use and great test coverage ✅

Installation

go get github.com/UlisesGascon/go-synology-chat@1.0.0

Usage

Simple example
package main

import (
    "fmt"
    "github.com/UlisesGascon/go-synology-chat"
)

func main() {
    baseUrl := "https://<IP-OR-URL>:<PORT>"
    token := "<YOUR-TOKEN>"
    ignoreSSLErrors := true

    sc, err := synologychat.New(baseUrl, token, ignoreSSLErrors)
    if err != nil {
        fmt.Println("Error initializing SynologyChat:", err)
        return
    }

    users, err := sc.GetUsers()
    if err != nil {
        fmt.Println("Error getting users:", err)
        return
    }

    channels, err := sc.GetChannels()
    if err != nil {
        fmt.Println("Error getting channels:", err)
        return
    }

    const userId = 43451
    data, err := sc.SendDirectMessage([]int{userId}, "Hello, World!")
    if err != nil {
        fmt.Println("Error sending direct message:", err)
        return
    }

    fmt.Println(users)
    fmt.Println(channels)
    fmt.Println(data)
}
Disable SSL validation

If you have a Synology NAS with invalid SSL certificates (due to expiration or other issues), you can disable the SSL validation in the requests generated by the library by using the configuration parameter ignoreSSLErrors.

Additional Features

Please check out the official DSM Documentation to include new features

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

  • This project is under development, but you can help us to improve it! We ❤ FOSS!

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GeneratePayloadContent

func GeneratePayloadContent(userIDs []int, text string, file_url ...string) (string, error)

func GetUrlByMethod

func GetUrlByMethod(baseUrl, token string) func(string) (string, error)

func MakeGetRequest

func MakeGetRequest(url string, ignoreSSLErrors bool) func() (map[string]interface{}, error)

func MakePostRequest

func MakePostRequest(urlStr string, payload string, ignoreSSLErrors bool) (map[string]interface{}, error)

Types

type SynologyChat

type SynologyChat struct {
	// contains filtered or unexported fields
}

func New

func New(baseUrl string, token string, ignoreSSLErrors bool) (*SynologyChat, error)

func (*SynologyChat) GetChannels

func (sc *SynologyChat) GetChannels() (map[string]interface{}, error)

func (*SynologyChat) GetUsers

func (sc *SynologyChat) GetUsers() (map[string]interface{}, error)

func (*SynologyChat) SendDirectMessage

func (sc *SynologyChat) SendDirectMessage(userIDs []int, text string, file_url ...string) (map[string]interface{}, error)

Jump to

Keyboard shortcuts

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