nopaste

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2015 License: MIT Imports: 18 Imported by: 0

README

nopaste

nopaste http server & IRC agent.

Install

$ go get github.com/kayac/nopaste/cmd/nopaste

Usage

$ nopaste -config config.yaml

nopaste will rewrite the config.yaml(irc.channels section) when join to a new IRC channel.

Configuration

base_url: http://example.com  # for IRC messages
listen: "localhost:3000"
data_dir: data
irc:
  host: localhost
  port: 6666
  secure: false
  password: secret
  nick: npbot
slack:
  webhook_url: https://hooks.slack.com/services/XXX/YYY/zzzz
channels:
- '#general'
- '#infra'

nopaste runs http server on http://#{listen}/np.

LICENCE

The MIT License (MIT)

Documentation

Index

Constants

View Source
const (
	MsgBufferLen = 100
)
View Source
const MsgrRoot = "/irc-msgr"
View Source
const Root = "/np"
View Source
const SlackMaxBackOff = 3600

Variables

View Source
var (
	SlackThrottleWindow = 1 * time.Second
	SlackInitialBackOff = 30
	Epoch               = time.Unix(0, 0)
)
View Source
var (
	IRCThrottleWindow = 1 * time.Second
)

Functions

func NewSNS added in v0.0.3

func NewSNS() *sns.SNS

func Run

func Run(configFile string) error

func RunIRCAgent

func RunIRCAgent(c *Config, ch chan IRCMessage)

func RunMsgr

func RunMsgr(configFile string) error

func RunSlackAgent added in v0.0.5

func RunSlackAgent(c *Config, ch chan SlackMessage)

Types

type Config

type Config struct {
	BaseURL string       `yaml:"base_url"`
	Listen  string       `yaml:"listen"`
	DataDir string       `yaml:"data_dir"`
	IRC     *IRCConfig   `yaml:"irc"`
	Slack   *SlackConfig `yaml:"slack"`

	Channels []string `yaml:"channels"`
	// contains filtered or unexported fields
}

func LoadConfig

func LoadConfig(file string) (*Config, error)

func (*Config) AddChannel

func (c *Config) AddChannel(channel string)

func (*Config) DataFilePath

func (c *Config) DataFilePath(id string) string

func (*Config) Save

func (c *Config) Save() error

func (*Config) SetFilePath

func (c *Config) SetFilePath(path string)

type IRCConfig

type IRCConfig struct {
	Host     string `yaml:"host"`
	Port     int    `yaml:"port"`
	Secure   bool   `yaml:"secure"`
	Debug    bool   `yaml:"debug"`
	Password string `yaml:"password"`
	Nick     string `yaml:"nick"`
}

type IRCMessage

type IRCMessage struct {
	Channel string
	Notice  bool
	Text    string
}

type IRCMessageChan added in v0.0.5

type IRCMessageChan chan IRCMessage

func (IRCMessageChan) PostMsgr added in v0.0.5

func (ch IRCMessageChan) PostMsgr(req *http.Request)

func (IRCMessageChan) PostNopaste added in v0.0.5

func (ch IRCMessageChan) PostNopaste(np nopasteContent, url string)

type MessageChan added in v0.0.5

type MessageChan interface {
	PostNopaste(np nopasteContent, url string)
	PostMsgr(np *http.Request)
}

type SlackAgent added in v0.0.5

type SlackAgent struct {
	WebhookURL string
	// contains filtered or unexported fields
}

func (*SlackAgent) Post added in v0.0.5

func (a *SlackAgent) Post(m SlackMessage) error

type SlackConfig added in v0.0.5

type SlackConfig struct {
	WebhookURL string `yaml:"webhook_url"`
}

type SlackMessage added in v0.0.5

type SlackMessage struct {
	Channel   string `json:"channel"`
	Text      string `json:"text"`
	IconEmoji string `json:"icon_emoji,omitempty"`
	IconURL   string `json:"icon_url,omitempty"`
	Username  string `json:"username"`
	LinkNames int    `json:"link_names,omitempty"`
}

type SlackMessageChan added in v0.0.5

type SlackMessageChan chan SlackMessage

func (SlackMessageChan) PostMsgr added in v0.0.5

func (ch SlackMessageChan) PostMsgr(req *http.Request)

func (SlackMessageChan) PostNopaste added in v0.0.5

func (ch SlackMessageChan) PostNopaste(np nopasteContent, url string)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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