bot

package
v0.0.0-...-40a7325 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package bot exports a Bot interface to manage bots for differents platforms easily.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bot

type Bot interface {
	Connect(c client.Client, addr string, token string, cap int, defaultResponse string) error
	Start() error
	Listen() error
	Stop() error
}

Bot is an interface to manage bots for differentes platforms.

func Create

func Create(platform string) (Bot, error)

Create returns a bot that satisfies the Bot interface depending on the received platform. If the platform is not supported it returns an error.

type Discord

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

Discord is a wrapper for a bwmawwin/discordgo session that satisfies the Bot interface.

func (*Discord) Connect

func (d *Discord) Connect(c client.Client, addr string, token string, cap int, defaultResponse string) error

Connect receives a token with which tries to identify, setups everything necessary and initializes a goroutine to send the responses from the responses channel to the respective clients.

func (*Discord) Listen

func (d *Discord) Listen() error

Listen handles all the messages sent to the Discord bot and tries to get the response for the asked command from the botio's server and submit it to the responses channel, which eventually should send the response back to the client.

func (*Discord) Start

func (d *Discord) Start() error

Start opens the connection to Discord.

func (*Discord) Stop

func (d *Discord) Stop() error

Stop waits until the responses channel is closed and then closes the Discord session.

type Response

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

Response represents a bot response.

type Telegram

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

Telegram is a wrapper for a yanzay/tbot client that satifies the Bot interface.

func (*Telegram) Connect

func (t *Telegram) Connect(c client.Client, addr string, token string, cap int, defaultResponse string) error

Connect receives a token with which tries to indentify, setups everything necessary and initializes a goroutine to send the responses from the responses channel to the respective clients.

func (*Telegram) Listen

func (t *Telegram) Listen() error

Listen handles all the messages sent to the Telegram bot and tries to get the response for the asked command from the botio's server and submit it to the responses channel, which eventually should send the response back to the client.

func (*Telegram) Start

func (t *Telegram) Start() error

Start opens a connection to Telegram.

func (*Telegram) Stop

func (t *Telegram) Stop() error

Stop waits until the responses channel is closed and then stops the Telegram session.

Jump to

Keyboard shortcuts

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