chat

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2020 License: MIT Imports: 6 Imported by: 0

README

go-chat

I'm on my bullshit about chat-ops again.

Examples

The examples are an attempt to keep track of how the heck I think this library should work.

everyx

Drops a message into the channel(s) every X minutes.

If you run it without any special environment variables set, it runs in terminal mode, using stdout as "the channel" and reading standard input for messages.

For Slack mode, set the BOT_SLACK_TOKEN to your bot's API token. You can also set BOT_SLACK_CHANNEL to a single channel to join. Otherwise, the channel "testing" is assumed.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bot

type Bot interface {
	Post([]string, string, ...interface{})
	Every(Handler)
	On(string, Handler)
}

func Slack

func Slack(token string) (Bot, error)

func Terminal

func Terminal() (Bot, error)

type Context

type Context string

type Dispatcher

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

func (Dispatcher) Dispatch

func (d Dispatcher) Dispatch(msg Message)

func (*Dispatcher) Every

func (d *Dispatcher) Every(fn Handler)

func (*Dispatcher) On

func (d *Dispatcher) On(regex string, fn Handler)

type Handle

type Handle string

type Handler

type Handler func(Message, ...string) Then

type Message

type Message struct {
	Addressed bool
	Received  time.Time

	From Handle
	To   Handle
	In   Context
	Text string
	// contains filtered or unexported fields
}

func (Message) Reply

func (m Message) Reply(msg string, args ...interface{})

type SlackBot

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

func (*SlackBot) Every

func (b *SlackBot) Every(fn Handler)

func (*SlackBot) On

func (b *SlackBot) On(in string, fn Handler)

func (*SlackBot) Post

func (b *SlackBot) Post(to []string, msg string, args ...interface{})

type TerminalBot

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

func (*TerminalBot) Every

func (b *TerminalBot) Every(fn Handler)

func (*TerminalBot) On

func (b *TerminalBot) On(in string, fn Handler)

func (*TerminalBot) Post

func (b *TerminalBot) Post(to []string, msg string, args ...interface{})

type Then

type Then int
const (
	Handled Then = iota
	Continue
)

Directories

Path Synopsis
example
spy
lib

Jump to

Keyboard shortcuts

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