zenbot

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2016 License: MIT Imports: 6 Imported by: 0

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

./zen <duration e.g. 1h30m> [reason - optional]

Installation

Build from Source

  1. clone the repo:
    1. git clone -b v1.0.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

In addition, see the table below for the options related to the web UI.

example: ./zenbot -token xoxb-abcdefg

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

License

see ./LICENSE

Documentation

Index

Constants

View Source
const Version = "v1.0.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 (*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
}

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 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