handlers

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2015 License: GPL-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package handlers provides several pre-baked gobot.Handlers for convenience.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HelpHandler

type HelpHandler struct {
	ShortDesc string
	LongDesc  string
}

HelpHandler stores a short help message and a long help message and responds with them to !help and !help @[BotName], respectively.

func (*HelpHandler) HandleIncoming

func (h *HelpHandler) HandleIncoming(r *gobot.Room, p *proto.Packet) (*proto.Packet, error)

HandleIncoming checks incoming SendEvents for help commands and responds appropriately.

func (*HelpHandler) Run

func (h *HelpHandler) Run(r *gobot.Room)

Run is a no-op.

func (*HelpHandler) Stop

func (h *HelpHandler) Stop(r *gobot.Room)

Stop is a no-op.

type PongHandler

type PongHandler struct{}

PongHandler responds to a send-event starting with "!ping" and returns a send command containing "pong!".

func (*PongHandler) HandleIncoming

func (ph *PongHandler) HandleIncoming(r *gobot.Room, p *proto.Packet) (*proto.Packet, error)

HandleIncoming satisfies the Handler interface.

func (*PongHandler) Run

func (ph *PongHandler) Run(r *gobot.Room)

Run is a no-op- the PongHandler does not need to run continuously, only in response to an incoming packet.

func (*PongHandler) Stop

func (ph *PongHandler) Stop(r *gobot.Room)

Stop is also a no-op- there is nothing to stop.

type UptimeHandler

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

UptimeHandler records the time when the bot goes up and responds to commands with the duration the bot has been up.

func (*UptimeHandler) HandleIncoming

func (u *UptimeHandler) HandleIncoming(r *gobot.Room, p *proto.Packet) (*proto.Packet, error)

HandleIncoming checks incoming commands for !uptime or !uptime @[BotName] and responds with the duration the bot has been up.

func (*UptimeHandler) Run

func (u *UptimeHandler) Run(r *gobot.Room)

Run simply records the time.

func (*UptimeHandler) Stop

func (u *UptimeHandler) Stop(r *gobot.Room)

Stop is a no-op.

Jump to

Keyboard shortcuts

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