telegram

package
v0.0.0-...-fb114ad Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2018 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvCert     = "TG_BOT_CERT"
	EnvDomain   = "TG_BOT_DOMAIN"
	EnvKey      = "TG_BOT_KEY"
	EnvSecret   = "TG_BOT_SECRET"
	EnvToken    = "TG_BOT_TOKEN"
	EnvProxyURL = "TG_BOT_PROXY_URL"
)

Variables

View Source
var (
	ErrNoBotCert   = errors.New("Please, provide path to valid SSL certificate for Telegram bot.")
	ErrNoBotKey    = errors.New("Please, provide path to valid SSL key for Telegram bot.")
	ErrNoBotSecret = errors.New("Please, provide Telegram bot secret with TG_BOT_SECRET environment variable.")
	ErrNoBotToken  = errors.New("Please, provide Telegram bot token with TG_BOT_TOKEN environment variable.")
)
View Source
var (
	StickerMinecraftFabulous     = "CAADAgADsQMAAvJ-ggzCPqB_xrc8iwI"
	StickerMinecraftForeverAlone = "CAADAgADvAMAAvJ-ggyCesS6rGVfFgI"
	StickerCriminalRaccoonHat    = "CAADAgADlwYAAvoLtgiTap3uNdUieAI"
)

Functions

This section is empty.

Types

type Bot

type Bot struct {
	*tgbotapi.BotAPI

	Storage storage.BotStorage
	// contains filtered or unexported fields
}

func NewBot

func NewBot(s storage.BotStorage, cfg *BotConfig, debug bool) (*Bot, error)

func NewBotEnv

func NewBotEnv(s storage.BotStorage, debug bool) (*Bot, error)

func (*Bot) AnswerCallback

func (bot *Bot) AnswerCallback(upd *Update, text string, alert bool) error

func (*Bot) CallbackQuery

func (bot *Bot) CallbackQuery(name string, h Handler)

func (*Bot) Command

func (bot *Bot) Command(name string, h Handler)

func (*Bot) DefaultHandler

func (bot *Bot) DefaultHandler() Handler

func (*Bot) InlineQuery

func (bot *Bot) InlineQuery(query string, h Handler)

func (*Bot) Message

func (bot *Bot) Message(msg string, h Handler)

func (*Bot) SendMessage

func (bot *Bot) SendMessage(
	ctx *Context,
	text string,
	markup *tgbotapi.InlineKeyboardMarkup,
) error

func (*Bot) SendSticker

func (bot *Bot) SendSticker(ctx *Context, stickerID string) error

func (*Bot) Serve

func (bot *Bot) Serve(h Handler)

func (*Bot) Stop

func (bot *Bot) Stop()

func (*Bot) UpdateCallbackQueryMessage

func (bot *Bot) UpdateCallbackQueryMessage(
	upd *Update,
	caption, text string,
	markup *tgbotapi.InlineKeyboardMarkup,
) error

func (*Bot) Updates

func (bot *Bot) Updates() <-chan *Update

type BotConfig

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

func ConfigFromEnv

func ConfigFromEnv() (*BotConfig, error)

func (*BotConfig) IsWebhook

func (cfg *BotConfig) IsWebhook() bool

type Context

type Context struct {
	context.Context

	Bot    *Bot
	Update *Update
	User   *access.User
}

type Handler

type Handler interface {
	HandleUpdate(*Context) error
}

type HandlerFunc

type HandlerFunc func(*Context) error

func (HandlerFunc) HandleUpdate

func (fn HandlerFunc) HandleUpdate(ctx *Context) error

type Update

type Update struct {
	*tgbotapi.Update
	// contains filtered or unexported fields
}

func NewUpdate

func NewUpdate(upd *tgbotapi.Update) (update *Update)

func (*Update) CallbackQuery

func (upd *Update) CallbackQuery() string

func (*Update) Chat

func (upd *Update) Chat() *tgbotapi.Chat

func (*Update) Command

func (upd *Update) Command() string

func (*Update) CommandArgs

func (upd *Update) CommandArgs() string

func (*Update) InlineQuery

func (upd *Update) InlineQuery() string

func (*Update) IsCallbackQuery

func (upd *Update) IsCallbackQuery() bool

func (*Update) IsCommand

func (upd *Update) IsCommand() bool

func (*Update) IsInlineQuery

func (upd *Update) IsInlineQuery() bool

func (*Update) User

func (upd *Update) User() *tgbotapi.User

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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