Documentation ¶
Overview ¶
Copyright © 2018 BigOokie
Use of this source code is governed by an MIT license that can be found in the LICENSE file.
Index ¶
- func CreateMarkup(btns ...string) tgbotapi.InlineKeyboardMarkup
- func CreateMultiLineMarkup(btns ...string) tgbotapi.InlineKeyboardMarkup
- type Bot
- func (bot *Bot) AddGroupMessageHandler(handler MessageHandler)
- func (bot *Bot) AddPrivateMessageHandler(handler MessageHandler)
- func (bot *Bot) Reply(ctx *BotContext, format, text string) error
- func (bot *Bot) Send(ctx *BotContext, mode, format, text string) error
- func (bot *Bot) SendMainMenuMessage(ctx *BotContext) error
- func (bot *Bot) SendNewMessage(format, text string) error
- func (bot *Bot) SendReplyInlineKeyboard(ctx *BotContext, kb tgbotapi.InlineKeyboardMarkup, text string) error
- func (bot *Bot) Start()
- type BotContext
- type Command
- type CommandHandler
- type Commands
- type MessageHandler
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateMarkup ¶
func CreateMarkup(btns ...string) tgbotapi.InlineKeyboardMarkup
CreateMarkup will return a tgbotapi.InlineKeyboardMarkup. Supports a single button row only
func CreateMultiLineMarkup ¶
func CreateMultiLineMarkup(btns ...string) tgbotapi.InlineKeyboardMarkup
CreateMultiLineMarkup will build and return a multiline tgbotapi.InlineKeyboardMarkup The "|" character is used in the btns input to define the end of a row for example "1", "2", "|", "3", "4" will produce two rows with "1", "2" and "3", "4"
Types ¶
type Bot ¶
type Bot struct {
// contains filtered or unexported fields
}
Bot provides management of the interface to the Telegram Bot
func NewBot ¶
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) SendMainMenuMessage ¶
func (bot *Bot) SendMainMenuMessage(ctx *BotContext) error
SendMainMenuMessage will send a main menu message
func (*Bot) SendNewMessage ¶
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
type BotContext ¶
type BotContext struct { User *User // contains filtered or unexported fields }
BotContext provides context for Bot Messages
func (*BotContext) IsCallBackQuery ¶
func (ctx *BotContext) IsCallBackQuery() bool
IsCallBackQuery will evaluate the BotContext and determine if it is a CallBackQueyr or not
func (*BotContext) IsUserMessage ¶
func (ctx *BotContext) IsUserMessage() bool
IsUserMessage will evaluate the BotContext and determine if it is a regular User Message or not
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 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 ¶
NameAndTags is a helper function to append namess and tags to users within the group