telegrambot

package
v0.2.0-beta.10 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2018 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bot

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

Bot provides management of the interface to the Telegram Bot

func NewBot

func NewBot(config wcconfig.Config) (*Bot, error)

NewBot will create a new instance of a Bot struct based on the passed Config structure which supplies runtime configuration for the bot.

func (*Bot) AddGroupMessageHandler

func (bot *Bot) AddGroupMessageHandler(handler MessageHandler)

AddGroupMessageHandler adds a group MessageHandler to the Bot

func (*Bot) AddPrivateMessageHandler

func (bot *Bot) AddPrivateMessageHandler(handler MessageHandler)

AddPrivateMessageHandler adds a private MessageHandler to the Bot

func (*Bot) Reply

func (bot *Bot) Reply(ctx *BotContext, format, text string) error

Reply will respond to a message received by the Bot in the BotContext (ctx). Specify the reply format and message text as parameters.

func (*Bot) Send

func (bot *Bot) Send(ctx *BotContext, mode, format, text string) error

Send will send a new message from the Bot using the provided BotContext The mode, format and text parameters are used to constuct the message and determine its format and delivery

func (*Bot) SendNewMessage

func (bot *Bot) SendNewMessage(format, text string) error

SendNewMessage will send a new message without requiring a BotContext.

func (*Bot) SendReplyInlineKeyboard

func (bot *Bot) SendReplyInlineKeyboard(ctx *BotContext, kb tgbotapi.InlineKeyboardMarkup, text string) error

SendReplyInlineKeyboard will send a reply using the provided inline keyboard

func (*Bot) Start

func (bot *Bot) Start()

Start will start the Bot running - the main duty being to monitor for and handle messages

type BotContext

type BotContext struct {
	User *User
	// contains filtered or unexported fields
}

BotContext provides context for Bot Messages

type Command

type Command struct {
	Admin       bool
	Command     string
	Handlerfunc CommandHandler
}

Command struct is used to define a Telegram Bot command, including if its an Admin only command, the string command (i.e. `/start`) and the function that will handle the command

type CommandHandler

type CommandHandler func(*Bot, *BotContext, string, string) error

CommandHandler provides an interface specification for command handlers

type Commands

type Commands []Command

Commands provides an array (slice) of Command structs

type MessageHandler

type MessageHandler func(*Bot, *BotContext, string) (bool, error)

MessageHandler provides an interface specification for message handlers

type User

type User struct {
	ID        int    `json:"id"`
	UserName  string `db:"username" json:"username,omitempty"`
	FirstName string `db:"first_name" json:"first_name,omitempty"`
	LastName  string `db:"last_name" json:"last_name,omitempty"`
	Banned    bool   `json:"banned"`
	Admin     bool   `json:"admin"`
}

User is a structure to model the Telegram Bot user that is being interacted with

func (*User) NameAndTags

func (u *User) NameAndTags() string

NameAndTags is a helper function to append namess and tags to users within the group

Jump to

Keyboard shortcuts

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