Help us shape the future of Go! Take the 2026 Go Developer Survey

slackcat

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

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

Go to latest
Published: Feb 11, 2022 License: MIT Imports: 6 Imported by: 3

README

slackcat

slackcat is a command line tool that posts messages to Slack.

$ echo "hello" | slackcat

Important

This package has been superseded by sfomuseum/go-slack and will no longer be maintained.

Installing

If you have a working go installation run go get github.com/paulhammond/slackcat. Prebuilt binaries will be provided soon.

Configuring

First, create a new Slack Incoming Webhook integration.

Then create a /etc/slackcat.conf file, and add your new webhook url:

{
    "webhook_url":"https://my.slack.com/services/hooks/incoming-webhook?token=token"
}

If you don't have permission to create /etc/slackcat.conf then you can create ~/.slackcat.conf instead.

Usage

slackcat will take each line from stdin and post it as a message to Slack:

tail -F logfile | slackcat

If you'd prefer to provide a message on the command line, you can:

sleep 300; slackcat "done"

By default slackcat will post each message as coming from "user@hostname". If you want a different username, use the --name flag:

echo ":coffee:" | slackcat --name "coffeebot"

Slackcat will use the channel specified when you set up the incoming webhook. You can override this in the config file by adding a "channel" option, or you can use the --channel flag:

echo "testing" | slackcat --channel #test

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	WebhookUrl string `json:"webhook_url"`
	Channel    string `json:"channel"`
	Username   string `json:"username"`
}

func ReadConfig

func ReadConfig(possible ...string) (*Config, error)

type SlackMsg

type SlackMsg struct {
	Channel   string `json:"channel"`
	Username  string `json:"username,omitempty"`
	Text      string `json:"text"`
	Parse     string `json:"parse"`
	IconEmoji string `json:"icon_emoji,omitempty"`
}

func (SlackMsg) Encode

func (m SlackMsg) Encode() (string, error)

func (SlackMsg) Post

func (m SlackMsg) Post(WebhookURL string) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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