bot

package module
v0.0.0-...-b934051 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2017 License: MIT Imports: 6 Imported by: 1

README

Bot

Build Status Go Report Card Coverage Status

Golang bot library

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API interface {
	Sender
	Starter
}

API implements bot go-telegram-bot-api interface

func NewTelegramBot

func NewTelegramBot(token string, processor Processor, logger Logger) API

NewTelegramBot init telegram api bot

type Bot

type Bot interface {
	Talker
}

Bot implements bot

func StartTelebot

func StartTelebot(key string, db Database) (Bot, error)

StartTelebot creates an api and start telebot

type Database

type Database interface {
	GetIDByUsername(messenger, username string) (string, error)
	SetUsernameID(messenger, username, id string) error
	RegisterBotIfAlreadyNot(string) bool
	DeregisterBots()
	DeregisterBot(string) error
}

Database describes bot db operations

type Logger

type Logger interface {
	WithError(err error) Logger
	WithFields(str interface{}) Logger
	Debug(message ...interface{})
	Error(message ...interface{})
	Fatal(message ...interface{})
	Info(message ...interface{})
}

Logger logs messages

type Message

type Message interface {
	Chattable() tgbotapi.Chattable
}

Message is a interface for cross-package messages

type MessageHandler

type MessageHandler func(update tgbotapi.Update) []tgbotapi.Chattable

MessageHandler is a func for bot api message handling

type Messages

type Messages chan Message

Messages implements chan of message

type Moderator

type Moderator interface {
	//Moderate(message *tgbotapi.Message, dialog *Dialog) []tgbotapi.Chattable
	ModeratorID() int64
}

Moderator runs dialog on moderator side

type Processor

type Processor interface {
	Process(update tgbotapi.Update) []tgbotapi.Chattable
}

Processor processes bot updates

type Sender

type Sender interface {
	Send([]tgbotapi.Chattable)
}

Sender sends messages

type Starter

type Starter interface {
	Start()
}

Starter starts process, usually as goroutine

type Talker

type Talker interface {
	Talk(username, message string) error
}

Talker talks to username

type Telebot

type Telebot interface {
	SendMessage(telebot.Recipient, string, *telebot.SendOptions) error
}

Telebot interface for telegram bot

Jump to

Keyboard shortcuts

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