victor

package module
v0.0.0-...-4ab9184 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2012 License: MIT Imports: 10 Imported by: 0

README

Victor is a 37Signals Campfire bot written in Go (http://golang.org); inspired by Github's Hubot (http://github.com/github/hubot).

Here's a sample Victor executable:

package main

import (
    "victor"
)

func main() {
    options := map[string]string{
        "account": "",          // name of the account (subdomain of *.campfirenow.com)
        "token": "",            // token for the user
        "rooms": "",            // comma seperated list
    }

    r := victor.NewRobot("campfire", options)

    r.Hear("derp", func(msg *victor.TextMessage) {
        msg.Send("Derp!")
    })

    r.Respond("hello", func(msg *victor.TextMessage) {
        msg.Reply("Hello!")
    })

    r.Run()
}

Robot Abilities

  • Hear: Trigger an action based on some criteria heard anywhere in the channel.
  • Respond: Respond to a direct statement at the robot (e.g. "gobias show me the diff")

Actions on Messages

  • Send: Send a bit of text to the channel.
  • Reply: Reply directly to the person that triggered the action (e.g. "Brett: Yo yo yo. Here's the diff:")

TODO Stuff

  • TESTS plz.
  • More default actions like help, test, ping, etc.
  • Documentation

Of course I accept pull-requests! 😄 👍

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Campfire

type Campfire struct {
	*Robot
	// contains filtered or unexported fields
}

func (*Campfire) Client

func (self *Campfire) Client() *campfire.Client

func (*Campfire) Reply

func (self *Campfire) Reply(roomId int, userId int) func(string)

func (*Campfire) RoomList

func (self *Campfire) RoomList() []int

func (*Campfire) Run

func (self *Campfire) Run()

func (*Campfire) Send

func (self *Campfire) Send(roomId int) func(string)

type Listener

type Listener struct {
	Exp      *regexp.Regexp
	Callback func(*TextMessage)
}

func NewListener

func NewListener(exp *regexp.Regexp, callback func(*TextMessage)) *Listener

func (*Listener) Test

func (self *Listener) Test(msg *TextMessage) bool

type Robot

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

func (*Robot) Hear

func (self *Robot) Hear(expStr string, callback func(*TextMessage))

func (*Robot) Receive

func (self *Robot) Receive(msg *TextMessage)

func (*Robot) RememberUser

func (self *Robot) RememberUser(user *User)

func (*Robot) Respond

func (self *Robot) Respond(expStr string, callback func(*TextMessage))

func (*Robot) Shutdown

func (self *Robot) Shutdown()

func (*Robot) UserForId

func (self *Robot) UserForId(id int) *User

type RobotAdapter

type RobotAdapter interface {
	Hear(string, func(*TextMessage))
	Respond(string, func(*TextMessage))
	Run()
}

func NewRobot

func NewRobot(adapter string, options map[string]string) RobotAdapter

type Shell

type Shell struct {
	*Robot
	// contains filtered or unexported fields
}

func (*Shell) Run

func (self *Shell) Run()

type TextMessage

type TextMessage struct {
	Id        int
	Body      string
	CreatedAt string

	Send  func(text string)
	Reply func(text string)
	Topic func(text string)
	// contains filtered or unexported fields
}

func (*TextMessage) Matches

func (self *TextMessage) Matches() []string

func (*TextMessage) RandomString

func (self *TextMessage) RandomString(strings []string) string

func (*TextMessage) SetMatches

func (self *TextMessage) SetMatches(matches []string)

type User

type User struct {
	Id   int
	Name string
}

Directories

Path Synopsis
examples
utils

Jump to

Keyboard shortcuts

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