Skip to content

A thin library to make writing slackbot commands super simple

Notifications You must be signed in to change notification settings

premshree/lib-slackbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lib-slackbot

Build Status

lib-slackbot is a thin convenience wrapper around nlopes' excellent Slack API in Go.

When writing slack bots in Go I found myself repeating a lot of the same boilerplate. This is where lib-slackbot is useful. Currently, lib-slackbot is useful whenever you want to write a bot that listens to commands with optional arguments like so:

?weather 11231
?oncall

See the examples directory for an implementation.

Installation

$ go get github.com/premshree/lib-slackbot

Example

package main

import(
  "time"

  "github.com/premshree/lib-slackbot"
)

func main() {
  token := "YOUR_SLACK_BOT_TOKEN"
  bot := slackbot.New(token)

  bot.AddCommand("?time", "What's the local time?", func(bot *slackbot.Bot, channelID string, channelName string, args ...string) {
    t := time.Now()
    bot.Reply(channelID, t.Format("Mon Jan _2 15:04:05 2006"))
  })

  // Run starts the bot's listen loop
  bot.Run()
}

About

A thin library to make writing slackbot commands super simple

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages