botmetrics

package
v0.0.0-...-650939c Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2017 License: MPL-2.0 Imports: 6 Imported by: 1

README

go-botmetrics

go-botmetrics is a Go client to the BotMetrics service which lets you collect & analyze metrics for your bot.

Build Status

Usage

Log in to your BotMetrics account, navigate to "Bot Settings" and find out your Bot ID and API Key.

With that, you can initialize a BotmetricsClient:

import "github.com/botmetrics/go-botmetrics"

client := botmetrics.NewBotmetricsClient("api-key", "bot-id")

Alternatively, you can set the following ENV variables

  • ENV['BOTMETRICS_API_KEY']
  • ENV['BOTMETRICS_BOT_ID']

and initialize a BotmetricsClient with the default ENV variables:

import "github.com/botmetrics/go-botmetrics"

client := botmetrics.NewBotmetricsClient()
RegisterBot

With a BotmetricsClient instance, every time you create a new Slack Bot (in the OAuth2 callback), and assuming the bot token you received as part of the OAuth2 callback is bot-token, you can make the following call:

import "github.com/botmetrics/go-botmetrics"

client := botmetrics.NewBotmetricsClient("api-key", "bot-id")
client.RegisterBot('bot-token', 0)
Retroactive Registration

If you created your bot in the past, you can pass in created_at with the UNIX timestamp of when your bot was created, like so:

import "github.com/botmetrics/go-botmetrics"

client := botmetrics.NewBotmetricsClient("api-key", "bot-id")
client.RegisterBot('bot-token', 1462318092)

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/botmetrics/go-botmetrics. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrClientNotConfigured = fmt.Errorf("Set the environment variables BOTMETRICS_API_KEY and BOTMETRICS_BOT_ID or call NewBotmetricsClient(\"api_key\", \"bot_id\")")
)

Functions

This section is empty.

Types

type BotmetricsClient

type BotmetricsClient struct {
	ApiKey string
	BotId  string
}

func NewBotmetricsClient

func NewBotmetricsClient(args ...string) (*BotmetricsClient, error)

func (*BotmetricsClient) RegisterBot

func (b *BotmetricsClient) RegisterBot(token string, createdAt int64) bool

Jump to

Keyboard shortcuts

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