deckard-bot

command module
v0.0.0-...-821ef61 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2017 License: MIT Imports: 6 Imported by: 0

README

deckard-bot

CircleCI GoDoc

Welcome to the home to Handwriting.io's chatbot, Deckard.

About

Deckard is a chatbot library that can help you simplify your life. He was created as a way to help Handwriting.io developers work more efficiently and transparently.

Deckard has two connections built-in. You can talk to him through Slack or through a terminal (stdin/stdout).

Installing

Download the source code

go get github.com/handwritingio/deckard-bot

Alternatively, git clone and go build to run from source.

And install

go install github.com/handwritingio/deckard-bot

Getting started

See PLUGINS.md for requirements for each of Deckard's built-in plugins.

Want to run Deckard using Slack?

First, create a Slack bot:

Then initialize the Slack connection in your main.go

import "github.com/handwritingio/deckard-bot/connection/slack"

func main() {
  ...

  slackConn := slack.NewConnection("mySlackBotAPIToken")

  ...
}
What to run Deckard using terminal?

First initialize the Stdio connection in your main.go

import "github.com/handwritingio/deckard-bot/connection/stdio"

func main() {
  ...

  stdioConn := slack.NewConnection()

  ...
}

That's it!

Initializing Plugins and create the Bot

Once you create a connection, you should initialize plugins and create your bot. We provided a few example plugins that you can use, but feel free to create your own!

import (
	"github.com/handwritingio/deckard-bot/bot"

	"github.com/handwritingio/deckard-bot/plugins/cats"
  // Make sure to import your custom plugins
)

func main() {
  ...

  deckard := bot.New("Deckard", myConnection,
    &cats.Plugin{},
    // Any other plugins
  )
  ...
}
Put it all together and start the bot!

Now that you've created a connection and initialized your plugins, you should create a new bot and start the bot. Here's an example of what a main.go file can look like:

package main

import (
	"github.com/handwritingio/deckard-bot/bot"

	"github.com/handwritingio/deckard-bot/plugins/cats"
	"github.com/handwritingio/deckard-bot/plugins/dice"
	"github.com/handwritingio/deckard-bot/plugins/principles"
	"github.com/handwritingio/deckard-bot/plugins/tableflip"

	"github.com/handwritingio/deckard-bot/connection/stdio"
)

func main() {
	// 1. Setup a new connection
	conn := stdio.NewConnection()

	// 2. Create the bot using the connection and a list of plugins
	deckard := bot.New("Deckard", conn,
    &dice.Plugin{},
    &tableflip.Plugin{},
    &cats.Plugin{},
    &principles.Plugin{},
  )

	// 3. Start the bot!
	deckard.Go()
}

Running Deckard

go build .
./deckard-bot

Developing

See DEVELOP.md

Contributing

See CONTRIBUTING.md

License

See LICENSE

Version Numbers

Version numbers for this package will follow standard semantic versioning.

Issues

Please open an issue on Github and we will look into it as soon as possible.

Documentation

Overview

This is a sample main.go file which includes setup for a stdio connection and plugins that do not require any configurations. If you'd like to build your own plugins or connections, see our DEVELOP.md documentation

Directories

Path Synopsis
Package bot manages the creation of the chatbot and adding plugins to the chatbot.
Package bot manages the creation of the chatbot and adding plugins to the chatbot.
Package config provides access to application-wide configuration.
Package config provides access to application-wide configuration.
Package connection creates the interface for all services that require a connection to the chatbot.
Package connection creates the interface for all services that require a connection to the chatbot.
slack
Package slack is a Connection to the Slack Real Time Messaging API (https://api.slack.com/rtm).
Package slack is a Connection to the Slack Real Time Messaging API (https://api.slack.com/rtm).
stdio
Package stdio is a Connection to a stdin/stdout Terminal session
Package stdio is a Connection to a stdin/stdout Terminal session
Package github is a wrapper around the go Github client and API
Package github is a wrapper around the go Github client and API
Package log serves as a light wrapper around logrus.
Package log serves as a light wrapper around logrus.
Package message contains the structure for basic messages that are allowed to be sent through the RX and TX channels.
Package message contains the structure for basic messages that are allowed to be sent through the RX and TX channels.
Package plugins contains all plugins that interface with the chatbot.
Package plugins contains all plugins that interface with the chatbot.
cats
Package cats is a plugin that queries some cat API's and returns responses.
Package cats is a plugin that queries some cat API's and returns responses.
dice
Package dice is a plugin that will roll dice based on the number of dice you specify and the number of sides on each dice (ex: roll 7 6-sized dice)
Package dice is a plugin that will roll dice based on the number of dice you specify and the number of sides on each dice (ex: roll 7 6-sized dice)
principles
Package principles searches the Handwriting.io team's Engineering principles document and returns the best fit to the search query
Package principles searches the Handwriting.io team's Engineering principles document and returns the best fit to the search query
sample
Package sample is a sample implementation of a plugin.
Package sample is a sample implementation of a plugin.
tableflip
Package tableflip returns an ASCII-based emoticon depicting a person flipping a table out of rage or unflipping the table once thing have cooled down
Package tableflip returns an ASCII-based emoticon depicting a person flipping a table out of rage or unflipping the table once thing have cooled down
write
Package write renders a PNG using the Handwriting.io API.
Package write renders a PNG using the Handwriting.io API.

Jump to

Keyboard shortcuts

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