Skip to content

Latest commit

 

History

History
80 lines (58 loc) · 1.96 KB

README.md

File metadata and controls

80 lines (58 loc) · 1.96 KB

Whistler

Whistler avatar

Whistler, also called Xeno, was the astromech droid of Corran Horn. It was the same R-series model as the legendary R2-D2.

Whistler is based on the slackbot library. He's pretty cool.

Robots

GoDoc

Robot skeleton

package robots

// FooBot is a robot that …
type FooBot struct {
}

import (
	"fmt"
	"strings"
)

func init() {
	RegisterRobot("foo", func() (robot Robot) { return new(FooBot) })
}

// Run executes a deferred action
func (b FooBot) Run(c *SlashCommand) string {
	go b.DeferredAction(c)
	return ""
}

// DeferredAction makes a incoming webhook call
func (b FooBot) DeferredAction(c *SlashCommand) {
	MakeIncomingWebhookCall(&IncomingWebhook{
		Channel:     c.ChannelID,
		Username:    "Foo Bot",
		Text:        fmt.Sprintf("@%s Something!", c.Username),
		IconEmoji:   ":apple:",
		UnfurlLinks: true,
		Parse:       "full",
	})
}

// Description describes what the robot does
func (b ListBot) Description() string {
	return strings.Join([]string{
		"Does something!",
		"Usage: /whistler foo [args]",
		"Expected Response: Something",
	}, "\n\t")
}

Development

Running Whistler locally

Note: You need to add the integration Incoming Webhooks here.

SLACK_WEBHOOK_URL=https://hooks.slack.com/services/… go run main.go

Development request

Note: You can find the ID of your Slack channels here.

curl -X POST -d 'user_name=peterhellberg&channel_id=…&command=/whistler&text=lobsters' http://0.0.0.0:5454/slack_hook

Restarting Whistler

You may want to get comfortable with hk log and hk restart if you're having issues.