bopher

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2016 License: MIT Imports: 15 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Bopher

Bot + Gopher = Bopher

Bopher is client application connecting Mattermost(3.3.0~) as Bot. You can call Gopher from chat!

Requirements

  • Mattermost 3.3.0~
  • mattn/gopher binary file (named gopher.exe)

Setup

1. Build gopher binary
2. Write config.json
{
  // Your Mattermost settings
  "mattermost": {
    "host": "localhost",
    "port": "8065",
    "bot": {
      "email": "admin@example.com",
      "password": "admin",
      "name": "Bot",
      "first_name": "Go",
      "last_name": "Bot"
    },
    "team": "tttt",
    "channel": {
      "name":"botting",
      "display_name": "BotRoom",
      "purpose": "bot_test"
    }
  },
  // path to gopher.exe (Even if you use windows, this value is like `$GOPATH` not `%GOPATH%`)
  // details -> https://github.com/golang/go/issues/8469
  "gopher": "$GOPATH/bin/gopher.exe",

  // The maximum number of gophers on display
  // If you set a large number, gopher will eat all of your machine resource)
  "max_of_gophers": 10                 
}
3. Run bopher
go run main.go
4. Call gopher on mattermost

Commands

Message Action
gopher Call a gopher
bye gopher kill all gophers 😱
jump gopher jump all existing gophers
hello gopher a gopher say hello
whats gopher? r u sure?

License

This code is provided under the MIT license.

Documentation

Index

Constants

View Source
const ConfigFileName = "config.json"

Variables

This section is empty.

Functions

func CreateBotDebuggingChannelIfNeeded

func CreateBotDebuggingChannelIfNeeded(ch Channel)

func FindBotTeam

func FindBotTeam(t string)

func HandleMsgFromDebuggingChannel

func HandleMsgFromDebuggingChannel(event *model.WebSocketEvent)

func HandleWebSocketResponse

func HandleWebSocketResponse(event *model.WebSocketEvent)

func InitialLoad

func InitialLoad()

func LoginAsTheBotUser

func LoginAsTheBotUser(bot Bot)

func MakeSureServerIsRunning

func MakeSureServerIsRunning()

func PrintError

func PrintError(err *model.AppError)

func Run

func Run()

func RunBot

func RunBot(config Config)

Documentation for the Go driver can be found at https://godoc.org/github.com/mattermost/platform/model#Client

func SendMsgToDebuggingChannel

func SendMsgToDebuggingChannel(msg string, replyToId string)

func SetupGracefulShutdown

func SetupGracefulShutdown()

func UpdateTheBotUserIfNeeded

func UpdateTheBotUserIfNeeded(bot Bot)

Types

type Bot

type Bot struct {
	Email    string `json:"email"`
	Password string `json:"password"`
	Name     string `json:"name"`
	First    string `json:"first_name"`
	Last     string `json:"last_name"`
}

type Channel

type Channel struct {
	Name        string `json:"name"`
	DisplayName string `json:"display_name"`
	Purpose     string `json:"purpose"`
}

type Config

type Config struct {
	Mattermost   Mattermost `json:"mattermost"`
	Gopher       string     `json:"gopher"`
	MaxOfGophers int        `json:"max_of_gophers"`
}

type Mattermost

type Mattermost struct {
	Host    string  `json:"host"`
	Port    string  `json:"port"`
	Bot     Bot     `json:"bot"`
	Team    string  `json:"team"`
	Channel Channel `json:"channel"`
}

func (*Mattermost) HttpURL

func (m *Mattermost) HttpURL() string

func (*Mattermost) WsURL

func (m *Mattermost) WsURL() string

type Service

type Service struct {
	Gopher       string
	MaxOfGophers int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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