slacksay

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2019 License: MIT Imports: 11 Imported by: 0

README

slacksay

Convert slack messages to audible speech on Mac.

Install

go get github.com/ikawaha/slacksay/...

Usage

1. Get your slack token

see. https://api.slack.com/custom-integrations/legacy-tokens or https://api.slack.com/apps

2. Run slacksay
slacksay -t <slack_token> [-d (<json data>|@<file_name>|@-)]
  -d string
    	json data. If you start the data with the letter @, the rest should be a file name to read the data from, or -  if you  want to read the data from stdin.
  -t string
    	slack token

ex.

slacksay -t xoxp-your-token -d '{"bot_message": "true"}'

Configuration

note. If you do not specify anything for these options, the default values are used.

Option default Description Example
command say your speech tool(default say) say
channel::yomi --- specify the keyword reading ["random", "ザツダン"]
channel::includes --- target channels ["general", "develop"]
channel::excludes --- ignored channels ["random"]
user::yomi --- specify the user reading ["yamada", "ヤマダ"]
user::includes --- target users ["general", "develop"]
user::excludes --- ignored users ["random"]
keyword::yomi --- specify the keyword reading ["dev", "デブ"]
keyword::includes --- speak only messages that contain these keywords ["general", "develop"]
keyword::excludes --- ignore messages that contain these keywords ["random"]
bot_message false ignore bot message if false true
timeout 1m speech command timeout 3m10s
Example
{
  "command": "say",
  "channel": {
    "yomi": ["random", "ザツダン"],
    "includes": [],
    "excludes": ["bot-report"]
  },
  "user": {
    "yomi": ["yamada", "ヤマダ"],
    "includes": [],
    "excludes": ["my_slack_name"]
  },
  "keyword": {
    "yomi": ["dev", "開発環境"],
    "includes": ["レポート"],
    "excludes": ["info:"]
  },
  "bot_message": false,
  "timeout": "30s"
}
Ordr of Filtering

Options are specified, messages are filtered in the following order:

  1. channel
    1. includes ?
  2. user
    1. includes ?
  3. keyword (Convert a message to lowercase and apply filters to it.)
    1. includes ?
  4. bot_message ?
  5. channel
    1. excludes ?
  6. user
    1. excludes ?
  7. keyword (Convert a message to lowercase and apply filters to it.)
    1. excludes ?

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bot

type Bot struct {
	*slackbot.Client
	// contains filtered or unexported fields
}

Bot represents slack bot client.

func NewBot

func NewBot(ctx context.Context, token string, cfg *Config) (*Bot, error)

NewBot returns a client.

func (Bot) Close

func (bot Bot) Close()

Close closes client connections.

func (Bot) Response

func (bot Bot) Response(msg *slackbot.Message)

Response processes a slack message.

type Condition

type Condition struct {
	Yomi     []string `json:"yomi"`
	Includes []string `json:"includes"`
	Excludes []string `json:"excludes"`
	// contains filtered or unexported fields
}

Condition represents message filters and pronunciations for some keywords.

type Config

type Config struct {
	Command    string    `json:"command"`
	Channel    Condition `json:"channel"`
	User       Condition `json:"user"`
	Keyword    Condition `json:"keyword"`
	BotMessage bool      `json:"bot_message"`
	Timeout    string    `json:"timeout"`
}

Config represents the setting for the slacksay bot.

func NewConfigReader

func NewConfigReader(r io.Reader) (*Config, error)

NewConfigReader creates a config of slacksay bot from io reader.

func (Config) String

func (c Config) String() string

String returns json representation of the config.

Directories

Path Synopsis
cmd
slacksay command

Jump to

Keyboard shortcuts

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