zenbot

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2016 License: MIT Imports: 8 Imported by: 1

README

zenbot logo

Build Status

zenbot is a Slack bot that enforces "zen periods" for users, during which they are reprimanded for using Slack. Currently, the only available action is giving negative karmabot karma points.

Syntax

  • add a zen: ./zen <duration e.g. 1h30m> [reason - optional]
  • cancel a zen: ./zen cancel [reason]
  • cancel all zens: ./zen cancel

Installation

Build from Source

  1. clone the repo:
    1. git clone -b v1.1.1 https://github.com/kamaln7/zenbot.git
  2. run go get and then go build inside cmd/zenbot
    1. cd zenbot
    2. go get
    3. cd cmd/zenbot
    4. go build

Download a Pre-built Release

  1. head to the repo's releases page and download the appropriate latest release's binary for your system

Usage

  1. add a Slack Bot integration: https://team.slack.com/apps/A0F7YS25R-bots. an avatar is available here.
  2. invite zenbot to any existing channels and all future channels (this is a limitation of Slack's bot API, unfortunately)
  3. run zenbot. the following options are supported:
option required? description default
-token string yes slack RTM token
-debug=bool no set debug mode false
-timeout string no timeout between actions (karma downvotes) 10s
-whitelist.chan string no may be specified multiple times set a list of channel that zenbot may be used in. []

example: ./zenbot -token xoxb-abcdefg -whitelist.chan zen -whitelist.chan zenbot-test

It is recommended to pass zenbot's logs through humanlog. humanlog will format and color the JSON output as nice easy-to-read text.

Other

A systemd service unit file is available here. Edit the service file and replace xoxb-abcdefg with your Slack RTM token. Install it as usual.

License

see ./LICENSE

Documentation

Index

Constants

View Source
const Version = "v1.1.1"

Version

Variables

This section is empty.

Functions

This section is empty.

Types

type Bot

type Bot struct {
	Config *Config
	// contains filtered or unexported fields
}

A Bot is an instance of zenbot.

func New added in v1.1.1

func New(config *Config) *Bot

func (*Bot) ExpireZens

func (b *Bot) ExpireZens()

ExpireZens removes zens that have ended

func (*Bot) SendMessage

func (b *Bot) SendMessage(message, channel string)

SendMessage sends a message to a Slack channel.

func (*Bot) Zen

func (b *Bot) Zen()

Zen starts listening for Slack messages.

type Config

type Config struct {
	Slack            *Slack
	Debug            bool
	Log              *log.Log
	TimeoutDuration  time.Duration
	ChannelWhitelist StringList
}

Config contains all the necessary configs for a zenbot instance.

type Slack

type Slack struct {
	Bot *slack.Client
	RTM *slack.RTM
}

Slack contains the Slack client and RTM object.

type StringList added in v1.1.1

type StringList map[string]struct{}

func (*StringList) Set added in v1.1.1

func (sl *StringList) Set(value string) error

func (*StringList) String added in v1.1.1

func (sl *StringList) String() string

type Zen

type Zen struct {
	User, Name, Channel, Reason string
	EndsAt, Timeout             time.Time
}

A Zen is a zen time period for a user

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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