Documentation ¶
Index ¶
- 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) 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 ¶
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 ¶
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 ¶
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
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