Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BotLogic ¶
type BotLogic interface { SetIncomingChannel(message <-chan Update) SetOutgoingChannel(message chan<- SendMessage) Run() }
BotLogic implements the logic of the bot
type Chat ¶
type Contact ¶
type Contact struct { PhoneNumber string `json:"phone_number"` FistName string `json:"first_name"` LastName string `json:"last_name"` UserID int64 `json:"user_id"` }
Contact is https://core.telegram.org/bots/api#contact
type ForceReply ¶
ForceReply is https://core.telegram.org/bots/api#forcereply
type Location ¶
Location is https://core.telegram.org/bots/api#location
type Message ¶
type Message struct { MessageID int64 `json:"message_id"` From *User `json:"from"` Date int64 `json:"date"` Chat *Chat `json:"chat"` ForwardFrom *User `json:"forward_from"` ForwardDate int64 `json:"forward_date"` ReplyToMessage *Message `json:"reply_to_message"` Text string `json:"text"` Audio *Audio `json:"audio"` Document *Document `json:"document"` Photo []PhotoSize `json:"photo"` Sticker *Sticker `json:"sticker"` Video *Video `json:"video"` Voice *Voice `json:"voice"` Caption string `json:"caption"` Contact *Contact `json:"contact"` Location *Location `json:"location"` NewChatParticipant *User `json:"new_chat_participant"` LeftChatParticipant *User `json:"left_chat_participant"` NewChatTtitle string `json:"new_chat_title"` NewChatPhoto []PhotoSize `json:"new_chat_photo"` DeleteChatPhoto bool `json:"delete_chat_photo"` GroupChatCreated bool `json:"group_chat_created"` SupergroupChatCreated bool `json:"supergroup_chat_created"` ChannelChatCreated bool `json:"channel_chat_created"` MigrateToChatID int64 `json:"migrate_to_chat_id"` MigrateFromChatID int64 `json:"migrate_from_chat_id"` }
Message is https://core.telegram.org/bots/api#message
type ReplyKeyboardHide ¶
type ReplyKeyboardHide struct { HideKeyboard bool `json:"hide_keyboard"` Selective bool `json:"selective"` }
ReplyKeyboardHide is https://core.telegram.org/bots/api#replykeyboardhide
type ReplyKeyboardMarkup ¶
type ReplyKeyboardMarkup struct { Keyboard []string `json:"keyboard"` ResizeKeyboard bool `json:"resize_keyboard"` OneTimeKeyboard bool `json:"one_time_keyboard"` Selective bool `json:"selective"` }
ReplyKeyboardMarkup is https://core.telegram.org/bots/api#replykeyboardmarkup
type SendMessage ¶
type SendMessage struct { ChatID int64 `json:"chat_id"` Text string `json:"text"` ParseMode string `json:"parse_mode"` DisableWebPagePreview string `json:"disable_web_page_preview"` ReplyToMessageID int64 `json:"reply_to_message_id"` ReplyMarkup interface{} `json:"reply_markup"` }
SendMessage holds the data necessary for the sendMessage API call.
type SetWebhook ¶
type SetWebhook struct {
URL string `json:"url"`
}
SetWebhook holds the data necessary for the setWebhook API call.
type User ¶
type WebhookBot ¶
WebhookBot is a HTTP server implementing the Telegram bot webhook.
func NewWebhookBot ¶
func NewWebhookBot(config Config, logic BotLogic) *WebhookBot
NewWebhookBot creates a new server.
func (*WebhookBot) Request ¶
func (ws *WebhookBot) Request(method string, data interface{}) error
Request makes a request to the Telegram API.
func (*WebhookBot) Run ¶
func (ws *WebhookBot) Run()
Run runs the server. This method is long-running.
func (*WebhookBot) WebhookHandler ¶
func (ws *WebhookBot) WebhookHandler(w http.ResponseWriter, req *http.Request)
WebhookHandler handles a request from the Telegram bot API.