libneosay

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2023 License: MIT Imports: 4 Imported by: 1

README

libneosay donuts-are-good's followers donuts-are-good's stars donuts-are-good's visitors

libneosay

a library for neosay, a program that shouts into the matrix

usage

you probably don't need this, but i need this, so that is why it got made.

generally you can use neosay by piping program output into it and configuring it to speak to a matrix channel, so that you can have notifications and things in your bash scripts that easily go to your devices of choice.

i needed libneosay because i like using matrix channels to monitor web apps, and the one im working on has distinct subsections so libneosay has support for multiple chat channels in the config and you can message each channel easily like the example below.

package main

import (
	"fmt"
	"github.com/donuts-are-good/libneosay"
)

func main() {
	neosay, err := libneosay.NewNeosay("path/to/config.json")
	if err != nil {
		fmt.Println("Error initializing Neosay:", err)
		return
	}

	rooms := []string{"rooma", "roomb", "roomc", "roomd"}

	for _, room := range rooms {
		message := fmt.Sprintf("Hello, %s!", room)
		err = neosay.SendMessage(room, message)
		if err != nil {
			fmt.Printf("Error sending message to %s: %v\n", room, err)
		} else {
			fmt.Printf("Message sent to %s\n", room)
		}
	}
}

this demo program will say hello in every room it has a config for.

this is what a config looks like:

{
  "HomeserverURL": "your_homeserver_url",
  "UserID": "your_user_id",
  "AccessToken": "your_access_token",
  "Rooms": {
      "rooma": "room_id_a",
      "roomb": "room_id_b",
      "roomc": "room_id_c",
      "roomd": "room_id_d"
  }
}

license

MIT License 2023 donuts-are-good, for more info see license.md

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	HomeserverURL string            `json:"homeserverURL"`
	UserID        string            `json:"userID"`
	AccessToken   string            `json:"accessToken"`
	Rooms         map[string]string `json:"rooms"`
}

type Neosay

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

func NewNeosay

func NewNeosay(configFile string) (*Neosay, error)

func (*Neosay) SendMessage

func (n *Neosay) SendMessage(roomName, message string) error

Jump to

Keyboard shortcuts

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