/dosbot

A simple chat bot in Golang inspired by Hubot

Primary LanguageGoApache License 2.0Apache-2.0

dos-bot

A simple chat bot in Go(lang) inspired by Hubot

New Actions

Creating new actions are as simple as this:

func myAction(input string) (string, error) {
    // Check if action supports input.
    if input != "test" {
        return "", ErrEventNotSupportedByAction
    }

    return "Hello world!", nil
}

func init() {
    RegisterAction("directed-message", myAction)
}

New Connections

Creating new connections are as simple as this:

func myConnector(bot Bot, toActions chan<- Event, toChannel <-chan Event) {
    // Inputs
    go func() {
        // Query from service (Discord, Slack, Rocket.Chat, etc) here.
        EmitActions("directed-message", "test", toActions)
    }()

    // Outputs
    go func() {
        // Output to service from here
    }()
}

func init() {
    RegisterConnector(myConnector)
}

New Bot

package mybot

import "github.com/scott-wilson/dosbot"

func main() {
    bot := NewBot("test")

    // Register actions first
    dosbot.RegisterAction("directed-message", myAction)

    // Register connectors
    RegisterConnector(myConnector)

    // Run
    Run(bot)
}