Documentation ¶
Index ¶
- Variables
- type BotFramework
- func (bot *BotFramework) GetChatID(update *tgbotapi.Update) int64
- func (bot *BotFramework) HandleUpdate(update *tgbotapi.Update) error
- func (bot *BotFramework) HandleUpdates(ch tgbotapi.UpdatesChannel)
- func (bot *BotFramework) RegisterAudioHandler(f CommonHandler, chatID int64) error
- func (bot *BotFramework) RegisterCallbackQueryHandler(f CommonHandler, dataStartsWith string, chatID int64) error
- func (bot *BotFramework) RegisterCommand(name string, f CommonHandler, chatID int64) error
- func (bot *BotFramework) RegisterContactHandler(f CommonHandler, chatID int64) error
- func (bot *BotFramework) RegisterFileHandler(f CommonHandler, chatID int64) error
- func (bot *BotFramework) RegisterInlineQueryHandler(f CommonHandler, query string, userID int64) error
- func (bot *BotFramework) RegisterLocationHandler(f CommonHandler, chatID int64) error
- func (bot *BotFramework) RegisterPhotoHandler(f CommonHandler, chatID int64) error
- func (bot *BotFramework) RegisterPlainTextHandler(f CommonHandler, chatID int64) error
- func (bot *BotFramework) RegisterStickerHandler(f CommonHandler, chatID int64) error
- func (bot *BotFramework) RegisterUniversalHandler(f CommonHandler, chatID int64) error
- func (bot *BotFramework) RegisterVenueHandler(f CommonHandler, chatID int64) error
- func (bot *BotFramework) RegisterVideoHandler(f CommonHandler, chatID int64) error
- func (bot *BotFramework) RegisterVideoNoteHandler(f CommonHandler, chatID int64) error
- func (bot *BotFramework) RegisterVoiceHandler(f CommonHandler, chatID int64) error
- func (bot *BotFramework) UnregisterAudioHandler(chatID int64) error
- func (bot *BotFramework) UnregisterCallbackQueryHandler(dataStartsWith string, chatID int64) error
- func (bot *BotFramework) UnregisterCommand(name string, chatID int64) error
- func (bot *BotFramework) UnregisterContactHandler(chatID int64) error
- func (bot *BotFramework) UnregisterFileHandler(chatID int64) error
- func (bot *BotFramework) UnregisterInlineQueryHandler(query string, userID int64) error
- func (bot *BotFramework) UnregisterLocationHandler(chatID int64) error
- func (bot *BotFramework) UnregisterPhotoHandler(chatID int64) error
- func (bot *BotFramework) UnregisterPlainTextHandler(chatID int64) error
- func (bot *BotFramework) UnregisterStickerHandler(chatID int64) error
- func (bot *BotFramework) UnregisterUniversalHandler(chatID int64) error
- func (bot *BotFramework) UnregisterVenueHandler(chatID int64) error
- func (bot *BotFramework) UnregisterVideoHandler(chatID int64) error
- func (bot *BotFramework) UnregisterVideoNoteHandler(chatID int64) error
- func (bot *BotFramework) UnregisterVoiceHandler(chatID int64) error
- type CommonHandler
Constants ¶
This section is empty.
Variables ¶
var NoHandlersError = errors.New("no handlers for update")
Functions ¶
This section is empty.
Types ¶
type BotFramework ¶
type BotFramework struct { tgbotapi.BotAPI ErrorHandler func(u tgbotapi.Update, err error) // contains filtered or unexported fields }
BotFramework main object to work with. Instantiate using NewBotFramework
func NewBotFramework ¶
func NewBotFramework(api *tgbotapi.BotAPI) *BotFramework
NewBotFramework creates new bot instance
func (*BotFramework) GetChatID ¶
func (bot *BotFramework) GetChatID(update *tgbotapi.Update) int64
GetChatID returns chat ID from update message and callback query
func (*BotFramework) HandleUpdate ¶
func (bot *BotFramework) HandleUpdate(update *tgbotapi.Update) error
HandleUpdate handles single update from channel
func (*BotFramework) HandleUpdates ¶
func (bot *BotFramework) HandleUpdates(ch tgbotapi.UpdatesChannel)
HandleUpdates handles all updates from channel. save for panics
func (*BotFramework) RegisterAudioHandler ¶
func (bot *BotFramework) RegisterAudioHandler(f CommonHandler, chatID int64) error
RegisterAudioHandler binds handler for audio message from given chat If chatID = 0, command will work in any chat
func (*BotFramework) RegisterCallbackQueryHandler ¶
func (bot *BotFramework) RegisterCallbackQueryHandler(f CommonHandler, dataStartsWith string, chatID int64) error
RegisterCallbackQueryHandler binds handler for callback data If chatID = 0, command will work in any chat
func (*BotFramework) RegisterCommand ¶
func (bot *BotFramework) RegisterCommand(name string, f CommonHandler, chatID int64) error
RegisterCommand binds handler for commands If chatID=0, command will work in any chat Commands name can be any string For example:
bot.RegisterCommand("/start", SomeStartHandler, -1001234567)
binds same handler for "/start", "/start@your_bot", "/start@your_bot someReferralCode"
bot.RegisterCommand("🔔 Subscribe", SomeSubscribeHandler, 0)
binds handler for message text "🔔 Subscribe"
func (*BotFramework) RegisterContactHandler ¶
func (bot *BotFramework) RegisterContactHandler(f CommonHandler, chatID int64) error
RegisterContactHandler binds handler for contact message from given chat If chatID = 0, command will work in any chat
func (*BotFramework) RegisterFileHandler ¶
func (bot *BotFramework) RegisterFileHandler(f CommonHandler, chatID int64) error
RegisterFileHandler binds handler for file from given chat If chatID = 0, command will work in any chat
func (*BotFramework) RegisterInlineQueryHandler ¶
func (bot *BotFramework) RegisterInlineQueryHandler(f CommonHandler, query string, userID int64) error
RegisterInlineQueryHandler binds handler for query If userID = 0, command will work for any user
func (*BotFramework) RegisterLocationHandler ¶
func (bot *BotFramework) RegisterLocationHandler(f CommonHandler, chatID int64) error
RegisterLocationHandler binds handler for location message from given chat If chatID = 0, command will work in any chat
func (*BotFramework) RegisterPhotoHandler ¶
func (bot *BotFramework) RegisterPhotoHandler(f CommonHandler, chatID int64) error
RegisterPhotoHandler binds handler for photo message from given chat If chatID = 0, command will work in any chat
func (*BotFramework) RegisterPlainTextHandler ¶
func (bot *BotFramework) RegisterPlainTextHandler(f CommonHandler, chatID int64) error
RegisterPlainTextHandler binds handler for plain text message from given chat If chatID = 0, command will work in any chat
func (*BotFramework) RegisterStickerHandler ¶
func (bot *BotFramework) RegisterStickerHandler(f CommonHandler, chatID int64) error
RegisterStickerHandler binds handler for sticker from given chat If chatID = 0, command will work in any chat
func (*BotFramework) RegisterUniversalHandler ¶
func (bot *BotFramework) RegisterUniversalHandler(f CommonHandler, chatID int64) error
RegisterUniversalHandler binds handler for any message from given chat If chatID = 0, command will work in any chat
func (*BotFramework) RegisterVenueHandler ¶
func (bot *BotFramework) RegisterVenueHandler(f CommonHandler, chatID int64) error
RegisterVenueHandler binds handler for venue message from given chat If chatID = 0, command will work in any chat
func (*BotFramework) RegisterVideoHandler ¶
func (bot *BotFramework) RegisterVideoHandler(f CommonHandler, chatID int64) error
RegisterVideoHandler binds handler for video message from given chat If chatID = 0, command will work in any chat
func (*BotFramework) RegisterVideoNoteHandler ¶
func (bot *BotFramework) RegisterVideoNoteHandler(f CommonHandler, chatID int64) error
RegisterVideoNoteHandler binds handler for video_note message from given chat If chatID = 0, command will work in any chat
func (*BotFramework) RegisterVoiceHandler ¶
func (bot *BotFramework) RegisterVoiceHandler(f CommonHandler, chatID int64) error
RegisterVoiceHandler binds handler for voice message from given chat If chatID = 0, command will work in any chat
func (*BotFramework) UnregisterAudioHandler ¶
func (bot *BotFramework) UnregisterAudioHandler(chatID int64) error
UnregisterAudioHandler deletes handler for given chat
func (*BotFramework) UnregisterCallbackQueryHandler ¶
func (bot *BotFramework) UnregisterCallbackQueryHandler(dataStartsWith string, chatID int64) error
UnregisterCallbackQueryHandler deletes handler for given chat
func (*BotFramework) UnregisterCommand ¶
func (bot *BotFramework) UnregisterCommand(name string, chatID int64) error
UnregisterCommand deletes handler for command name in given chat
func (*BotFramework) UnregisterContactHandler ¶
func (bot *BotFramework) UnregisterContactHandler(chatID int64) error
UnregisterContactHandler deletes handler for given chat
func (*BotFramework) UnregisterFileHandler ¶
func (bot *BotFramework) UnregisterFileHandler(chatID int64) error
UnregisterFileHandler deletes handler for given chat
func (*BotFramework) UnregisterInlineQueryHandler ¶
func (bot *BotFramework) UnregisterInlineQueryHandler(query string, userID int64) error
UnregisterInlineQueryHandler deletes handler for given user
func (*BotFramework) UnregisterLocationHandler ¶
func (bot *BotFramework) UnregisterLocationHandler(chatID int64) error
UnregisterLocationHandler deletes handler for given chat
func (*BotFramework) UnregisterPhotoHandler ¶
func (bot *BotFramework) UnregisterPhotoHandler(chatID int64) error
UnregisterPhotoHandler deletes handler for given chat
func (*BotFramework) UnregisterPlainTextHandler ¶
func (bot *BotFramework) UnregisterPlainTextHandler(chatID int64) error
UnregisterPlainTextHandler deletes handler for given chat
func (*BotFramework) UnregisterStickerHandler ¶
func (bot *BotFramework) UnregisterStickerHandler(chatID int64) error
UnregisterStickerHandler deletes handler for given chat
func (*BotFramework) UnregisterUniversalHandler ¶
func (bot *BotFramework) UnregisterUniversalHandler(chatID int64) error
UnregisterUniversalHandler deletes handler for given chat
func (*BotFramework) UnregisterVenueHandler ¶
func (bot *BotFramework) UnregisterVenueHandler(chatID int64) error
UnregisterVenueHandler deletes handler for given chat
func (*BotFramework) UnregisterVideoHandler ¶
func (bot *BotFramework) UnregisterVideoHandler(chatID int64) error
UnregisterVideoHandler deletes handler for given chat
func (*BotFramework) UnregisterVideoNoteHandler ¶
func (bot *BotFramework) UnregisterVideoNoteHandler(chatID int64) error
UnregisterVideoNoteHandler deletes handler for given chat
func (*BotFramework) UnregisterVoiceHandler ¶
func (bot *BotFramework) UnregisterVoiceHandler(chatID int64) error
UnregisterVoiceHandler deletes handler for given chat
type CommonHandler ¶
type CommonHandler func(bot *BotFramework, update *tgbotapi.Update) error
CommonHandler is a short type alias for handler function