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
.
Amazon SNS http endpoint
nopaste can accept Amazon SNS notification messages.
Set environment variables.
AWS_ACCESS_KEY_ID=XXXXXXXXXX
AWS_SECRET_ACCESS_KEY=yyyyyyyyyyy
Add a SNS topic http(s) endpoint to http://example.com/np/amazon-sns/{channel_name}?key={message key}
.
LICENCE
The MIT License (MIT)
Documentation
¶
Index ¶
- Constants
- Variables
- func NewSNS(ctx context.Context, region string) (*sns.Client, error)
- func Run(ctx context.Context, configFile string) error
- func RunIRCAgent(c *Config, ch chan IRCMessage)
- func RunMsgr(ctx context.Context, configFile string) error
- func RunSlackAgent(c *Config, ch chan SlackMessage)
- type Config
- type HttpNotification
- type IRCConfig
- type IRCMessage
- type IRCMessageChan
- type LocalStorage
- type MessageChan
- type S3Config
- type S3Storage
- type SlackAgent
- type SlackConfig
- type SlackMessage
- type SlackMessageChan
- type Storage
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 Debug = false
View Source
var (
IRCThrottleWindow = 1 * time.Second
)
Functions ¶
func RunIRCAgent ¶
func RunIRCAgent(c *Config, ch chan IRCMessage)
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"` S3 *S3Config `yaml:"s3"` IRC *IRCConfig `yaml:"irc"` Slack *SlackConfig `yaml:"slack"` Channels []string `yaml:"channels"` // contains filtered or unexported fields }
func (*Config) AddChannel ¶
func (*Config) SetFilePath ¶
type HttpNotification ¶ added in v0.2.0
type HttpNotification struct { Type string `json:"Type"` MessageId string `json:"MessageId"` Token string `json:"Token"` // Only for subscribe and unsubscribe TopicArn string `json:"TopicArn"` Subject string `json:"Subject"` // Only for Notification Message string `json:"Message"` SubscribeURL string `json:"SubscribeURL"` // Only for subscribe and unsubscribe Timestamp time.Time `json:"Timestamp"` SignatureVersion string `json:"SignatureVersion"` Signature string `json:"Signature"` SigningCertURL string `json:"SigningCertURL"` UnsubscribeURL string `json:"UnsubscribeURL"` // Only for notifications }
type IRCMessage ¶
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 LocalStorage ¶ added in v0.2.0
type LocalStorage struct {
DataDir string
}
func NewLocalStorage ¶ added in v0.2.0
func NewLocalStorage(datadir string) *LocalStorage
func (*LocalStorage) Load ¶ added in v0.2.0
func (s *LocalStorage) Load(_ context.Context, name string) (io.ReadCloser, error)
type MessageChan ¶ added in v0.0.5
type S3Storage ¶ added in v0.2.0
func NewS3Storage ¶ added in v0.2.0
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 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)
Source Files
¶
Click to show internal directories.
Click to hide internal directories.