microhal

package module
v0.0.0-...-379abff Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2014 License: GPL-2.0 Imports: 9 Imported by: 1

README

microhal

A chatbot inspired by MegaHal

Usage

Initialize either a new Microhal instance with microhal.NewMicrohal(name, order) or load a database with microhal.LoadMicrohal(name).

To start the bot use microhal.Start(saveInterval, maxLength) which returns two channels, one for input and one for output. The bot will respond on the output channel to strings sent to the input channel.

Documentation

Overview

Package microhal provides a simple chatbot inspired by MegaHAL

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Microhal

type Microhal struct {
	// contains filtered or unexported fields
}

func LoadMicrohal

func LoadMicrohal(name string) *Microhal

LoadMicrohal returns a new instance of Microhal, initialized from save data associated with name.

func NewMicrohal

func NewMicrohal(name string, order int) *Microhal

NewMicrohal returns a new instance of Microhal. If there alreade exsitst save data associated with name name, it will be overwritten. Markov chains of order order will be used for the database.

func (*Microhal) GetName

func (m *Microhal) GetName() string

func (*Microhal) MarshalJSON

func (m *Microhal) MarshalJSON() ([]byte, error)

func (*Microhal) Start

func (m *Microhal) Start(saveInterval time.Duration, maxLength int) (chan<- string, <-chan string)

Start returns two chanels for input and output to this microhol. Strings sent to input chanel will be processed and a response of at most maxLength words will be sent to the output channel. After each processed input there is a 500 ms. delay. Each saveDuration the current state will be saved to disk.

func (*Microhal) UnmarshalJSON

func (m *Microhal) UnmarshalJSON(b []byte) error

Jump to

Keyboard shortcuts

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