rc

package module
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

README

A Simple tool to emit messages via RocketChat Webhook REST API

Github Release GoDoc Go Report Card Build/Test Status

This package provides an interface to RocketChat's Webhook / notification REST API (provided an endpoint is made available) and a command line tool for simple message sending / delivery.

Installation

go get -u github.com/fako1024/rc-notify

Examples

Send a simple message
req := rc.Request{
	Channel: "@me",
	User:    "Sending User",
	Message: "My message",
	Emoji:   rc.EmojiAlert,
}

// Execute the request (set webhook URI accordingly)
uri := "https://your.rc.instance.com/hooks/.../..."
if err := rc.Send(uri, req); err != nil {
	log.Fatalf("Failed to send message: %s", err)
}

Documentation

Index

Constants

View Source
const (

	// EmojiInfo denotes an info logo
	EmojiInfo = ":information_source:"

	// EmojiWarning denotes a warning logo
	EmojiWarning = ":warning:"

	// EmojiAlert denotes an alert logo
	EmojiAlert = ":rotating_light:"

	// EmojiBulb denotes a lightbulb logo
	EmojiBulb = ":bulb:"

	// EmojiArrowRight denotes a right arrow logo
	EmojiArrowRight = ":arrow_right:"

	// EmojiArrowLeft denotes a left arrow logo
	EmojiArrowLeft = ":arrow_left:"

	// EmojiLoginTest denotes the login logo for TEST
	EmojiLoginTest = ":login_test:"

	// EmojiLogoutTest denotes the logout logo for TEST
	EmojiLogoutTest = ":logout_test:"

	// EmojiLoginProd denotes the login logo for PROD
	EmojiLoginProd = ":login_prod:"

	// EmojiLogoutProd denotes the logout logo for PROD
	EmojiLogoutProd = ":logout_prod:"
)

Variables

This section is empty.

Functions

func Send

func Send(uri string, r Request) error

Send sends the request to the defined endpoint / RC instance

Types

type Attachment added in v1.0.2

type Attachment struct {
	Color      string  `json:"color,omitempty"`
	AuthorName string  `json:"author_name,omitempty"`
	AuthorLink string  `json:"author_link,omitempty"`
	AuthorIcon string  `json:"author_icon,omitempty"`
	Title      string  `json:"title"`
	TitleLink  string  `json:"title_link"`
	Text       string  `json:"text"`
	ImageURL   string  `json:"image_url,omitempty"`
	ThumbURL   string  `json:"thumb_url,omitempty"`
	Fields     []Field `json:"fields,omitempty"`
}

Attachment denotes a message attachment, like subfields or images and links

type Field added in v1.0.2

type Field struct {
	Title string `json:"title"`
	Value string `json:"value"`
	Short bool   `json:"short"`
}

Field denotes a (sub-)field to be displayed in the RC message / attachment

type Request

type Request struct {
	Channel     string       `json:"channel"`               // The channel to send to
	User        string       `json:"username"`              // The username to display next to the message
	Alias       string       `json:"alias,omitempty"`       // An alias to add to the message
	Emoji       string       `json:"emoji"`                 // The icon to use for the message
	Message     string       `json:"text"`                  // The message to send
	Attachments []Attachment `json:"attachments,omitempty"` // Potential message attachments
}

Request denotes an RC JSON request

func (*Request) Sanitize added in v1.0.2

func (r *Request) Sanitize() error

Sanitize checks and sanitizes the required fields of a request

Directories

Path Synopsis
cmd
rctool command
run-notify command

Jump to

Keyboard shortcuts

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