Documentation
¶
Index ¶
- Constants
- Variables
- type Bot
- func (bot *Bot) Action(endpoint interface{}, handler interface{})
- func (bot *Bot) AnswerCallbackQuery(queryID string, text string, extra JSONBody) (Update, error)
- func (bot *Bot) ApplyHandlers(context interface{}, update Update) (JSONBody, error)
- func (bot *Bot) DeleteMessage(chatID int64, messageID int64) (Update, error)
- func (bot *Bot) DeleteWebhook() (Update, error)
- func (bot *Bot) EditMessageText(chatID int64, messageID int64, text string, extra JSONBody) (Update, error)
- func (bot *Bot) ExportChatInviteLink(chatID int64) (Update, error)
- func (bot *Bot) ForwardMessage(chatID int64, fromChatID int64, messageID int64, extra JSONBody) (Update, error)
- func (bot *Bot) GetChat(param interface{}) (Update, error)
- func (bot *Bot) GetChatAdministrators(param interface{}) (Update, error)
- func (bot *Bot) GetChatMember(param interface{}, userID int64) (Update, error)
- func (bot *Bot) GetChatMembersCount(param interface{}) (Update, error)
- func (bot *Bot) GetFile(fileID string) (string, error)
- func (bot *Bot) GetMe() (Update, error)
- func (bot *Bot) GetUpdates(params JSONBody) (chan Update, error)
- func (bot *Bot) GetWebhookInfo() (Update, error)
- func (bot *Bot) Handle(endpoint string, handler interface{})
- func (bot *Bot) KickChatMember(chatID int64, userID int64, untilDate int64) (Update, error)
- func (bot *Bot) MakeRequest(endpoint string, params JSONBody) (Update, error)
- func (bot *Bot) PinChatMessage(chatID int64, messageID int64, extra JSONBody) (Update, error)
- func (bot *Bot) RestrictChatMember(chatID int64, userID int64, permissions map[string]bool, untilDate int64) (Update, error)
- func (bot *Bot) SendMediaGroup(chatID int64, media []JSONBody, extra JSONBody) (Update, error)
- func (bot *Bot) SendMessage(chatID int64, text string, extra JSONBody) (Update, error)
- func (bot *Bot) SendPhoto(chatID int64, fileID string, extra JSONBody) (Update, error)
- func (bot *Bot) SendVideo(chatID int64, fileID string, extra JSONBody) (Update, error)
- func (bot *Bot) SetBotID(botID int64)
- func (bot *Bot) SetBotName(name string)
- func (bot *Bot) SetWebhook(params JSONBody) (Update, error)
- func (bot *Bot) UnbanChatMember(chatID int64, userID int64) (Update, error)
- func (bot *Bot) UnpinAllChatMessages(chatID int64) (Update, error)
- func (bot *Bot) Use(middleware ...MiddlewareFunc)
- type Error
- type HandlerFunc
- type JSONBody
- type MiddlewareFunc
- type Settings
- type Update
- func (update Update) AnswerCallbackQuery(text string, extra JSONBody) JSONBody
- func (t Update) Array() []Update
- func (update Update) Chat() (Update, error)
- func (update Update) Command() (string, string)
- func (update Update) DeleteMessage() JSONBody
- func (update Update) EditMessageReplyMarkup(extra JSONBody) JSONBody
- func (update Update) EditMessageText(text string, extra JSONBody) JSONBody
- func (update Update) Entities() []Update
- func (update Update) From() (Update, error)
- func (t Update) Get(path string) Update
- func (update Update) GetType() string
- func (t Update) Map() map[string]Update
- func (update Update) Message() (Update, error)
- func (update Update) Reply(text string, extra JSONBody) JSONBody
- func (update Update) SendMediaGroup(media []JSONBody, extra JSONBody) JSONBody
- func (update Update) SendMessage(text string, extra JSONBody) JSONBody
Constants ¶
const ( // UserAgent is http user-agent header UserAgent = "EasyTGBot/1.0.0" // Endpoint is the endpoint for all API methods, // with formatting for Sprintf. Endpoint = "https://api.telegram.org/bot%s/%s" // FileEndpoint FileEndpoint = "https://api.telegram.org/file/bot%s/%s" )
Telegram constants
Variables ¶
var MessageNodes = []string{"message", "edited_message", "channel_post", "edited_channel_post", "my_chat_member", "chat_member"}
MessageNodes is message node name
var MessageQueryNodes = []string{"callback_query", "inline_query", "shipping_query", "pre_checkout_query", "chosen_inline_result"}
MessageQueryNodes is message query node name
Functions ¶
This section is empty.
Types ¶
type Bot ¶
type Bot struct { Debug bool ID int64 Name string Token string Webhook string Buffer int Timeout time.Duration Self Update // contains filtered or unexported fields }
Bot allows you to interact with the Telegram Bot API.
func (*Bot) Action ¶
func (bot *Bot) Action(endpoint interface{}, handler interface{})
Action lets you set the handler for some command name or one of the supported endpoints.
func (*Bot) AnswerCallbackQuery ¶
AnswerCallbackQuery see https://core.telegram.org/bots/api#answercallbackquery
func (*Bot) ApplyHandlers ¶
ApplyHandlers is apply handler
func (*Bot) DeleteMessage ¶
DeleteMessage see https://core.telegram.org/bots/api#deletemessage
func (*Bot) DeleteWebhook ¶
DeleteWebhook unsets the webhook.
func (*Bot) EditMessageText ¶
func (bot *Bot) EditMessageText(chatID int64, messageID int64, text string, extra JSONBody) (Update, error)
EditMessageText see https://core.telegram.org/bots/api#editmessagetext
func (*Bot) ExportChatInviteLink ¶
ExportChatInviteLink see https://core.telegram.org/bots/api#exportchatinvitelink
func (*Bot) ForwardMessage ¶
func (bot *Bot) ForwardMessage(chatID int64, fromChatID int64, messageID int64, extra JSONBody) (Update, error)
ForwardMessage send message
func (*Bot) GetChat ¶
GetChat see https://core.telegram.org/bots/api#getchat
func (*Bot) GetChatAdministrators ¶
GetChatAdministrators see https://core.telegram.org/bots/api#getchatadministrators
func (*Bot) GetChatMember ¶
GetChatMember see https://core.telegram.org/bots/api#getchatmember
func (*Bot) GetChatMembersCount ¶
GetChatMembersCount see https://core.telegram.org/bots/api#getchatmemberscount
func (*Bot) GetFile ¶
GetFile see https://core.telegram.org/bots/api#getfile
func (*Bot) GetMe ¶
GetMe fetches the currently authenticated bot.
This method is called upon creation to validate the token, and so you may get this data from Bot.Self without the need for another request.
func (*Bot) GetUpdates ¶
GetUpdates starts and returns a channel for getting updates.
func (*Bot) GetWebhookInfo ¶
GetWebhookInfo allows you to fetch information about a webhook and if one currently is set, along with pending update count and error messages.
func (*Bot) Handle ¶
Handle lets you set the handler for some command name or one of the supported endpoints.
func (*Bot) KickChatMember ¶
KickChatMember see https://core.telegram.org/bots/api#kickchatmember
func (*Bot) MakeRequest ¶
MakeRequest makes a request to a specific endpoint with our token.
func (*Bot) PinChatMessage ¶
PinChatMessage see https://core.telegram.org/bots/api#pinchatmessage
func (*Bot) RestrictChatMember ¶
func (bot *Bot) RestrictChatMember(chatID int64, userID int64, permissions map[string]bool, untilDate int64) (Update, error)
RestrictChatMember see https://core.telegram.org/bots/api#restrictchatmember
func (*Bot) SendMediaGroup ¶
SendMediaGroup see https://core.telegram.org/bots/api#sendmediagroup
func (*Bot) SendMessage ¶
SendMessage send message
func (*Bot) SetWebhook ¶
SetWebhook sets a webhook.
If this is set, GetUpdates will not get any data!
If you do not have a legitimate TLS certificate, you need to include your self signed certificate with the config.
func (*Bot) UnbanChatMember ¶
UnbanChatMember see https://core.telegram.org/bots/api#unbanchatmember
func (*Bot) UnpinAllChatMessages ¶
UnpinAllChatMessages see https://core.telegram.org/bots/api#unpinallchatmessages
type HandlerFunc ¶
HandlerFunc defines a function to serve HTTP requests.
type MiddlewareFunc ¶
type MiddlewareFunc func(HandlerFunc) HandlerFunc
MiddlewareFunc defines a function to process middleware.
type Settings ¶
type Settings struct { // debug Debug bool // default: false // Telegram API Url Endpoint string // Webhook Webhook string // Telegram token Token string // Updates channel capacity Updates int // Default: 100 // Timeout Timeout time.Duration // Default: 10s Proxy string GetMe bool }
Settings represents a utility struct for passing certain properties of a bot around and is required to make bots.
type Update ¶
Update is a response from the Telegram API with the result stored raw.
func (Update) AnswerCallbackQuery ¶
AnswerCallbackQuery is AnswerCallbackQuery
func (Update) Array ¶
Array returns back an array of values. If the result represents a non-existent value, then an empty array will be returned. If the result is not a Update array, the return value will be an array containing one result.
func (Update) DeleteMessage ¶
DeleteMessage see: https://core.telegram.org/bots/api#deletemessage
func (Update) EditMessageReplyMarkup ¶
EditMessageReplyMarkup edit message
func (Update) EditMessageText ¶
EditMessageText edit message
func (Update) Get ¶
Get searches result for the specified path. The result should be a Update array or object.
func (Update) SendMediaGroup ¶
SendMediaGroup is send media group