Archived
1

Initial commit

This commit is contained in:
2018-11-29 20:32:51 +04:00
commit ca1c52fc39
365 changed files with 81160 additions and 0 deletions

24
vendor/gitlab.com/toby3d/telegram/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,24 @@
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so
# Folders
_obj
_test
# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out
*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*
_testmain.go
*.exe
*.test
*.prof

41
vendor/gitlab.com/toby3d/telegram/.gitlab-ci.yml generated vendored Normal file
View File

@@ -0,0 +1,41 @@
image: golang:alpine
cache:
paths:
- /go/src/github.com
- /go/src/gitlab.com
- /go/src/golang.org
- /go/src/google.golang.org
- /go/src/gopkg.in
stages:
- test
before_script:
- apk add --no-cache git build-base bash
- mkdir -p /go/src/gitlab.com/$CI_PROJECT_NAMESPACE /go/src/_/builds
- cp -r $CI_PROJECT_DIR /go/src/gitlab.com/$CI_PROJECT_PATH
- ln -s /go/src/gitlab.com/$CI_PROJECT_NAMESPACE /go/src/_/builds/$CI_PROJECT_NAMESPACE
- make dep
unit_tests:
stage: test
script:
- make test
.race_detector:
stage: test
script:
- make race
code_coverage:
stage: test
script:
- make coverage
lint_code:
stage: test
script:
- go get github.com/go-critic/go-critic/cmd/gocritic
- go install github.com/go-critic/go-critic/cmd/gocritic
- make lint

20
vendor/gitlab.com/toby3d/telegram/LICENSE.md generated vendored Normal file
View File

@@ -0,0 +1,20 @@
# MIT License
Copyright (c) 2017 Maxim Lebedev
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

32
vendor/gitlab.com/toby3d/telegram/Makefile generated vendored Normal file
View File

@@ -0,0 +1,32 @@
PROJECT_NAMESPACE := $(CI_PROJECT_NAMESPACE)
PROJECT_NAME := $(CI_PROJECT_NAME)
PROJECT_PATH := $(PROJECT_NAMESPACE)/$(PROJECT_NAME)
PACKAGE_NAME := "gitlab.com/$(PROJECT_PATH)"
PACKAGE_PATH := $(GOPATH)/src/$(PACKAGE_NAME)
PACKAGE_LIST := $(shell go list $(PACKAGE_NAME)/... | grep -v /vendor/)
GO_FILES := $(shell find . -name '*.go' | grep -v /vendor/ | grep -v _test.go)
.PHONY: all lint test rase coverage dep build clean
all: build
lint: ## Lint the files
@gocritic check-project $(PACKAGE_PATH)
test: ## Run unittests
@go test -short ${PACKAGE_LIST}
race: dep ## Run data race detector
@go test -race -short ${PACKAGE_LIST}
coverage: ## Generate global code coverage report
@go test -cover -v -coverpkg=$(PACKAGE_NAME) ${PACKAGE_LIST}
dep: ## Get the dependencies
@go get -v -d -t ${PACKAGE_LIST}
clean: ## Remove previous build
@rm -f $(PROJECT_NAME)
help: ## Display this help screen
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

View File

@@ -0,0 +1,60 @@
package telegram
import json "github.com/pquerna/ffjson/ffjson"
// AnswerCallbackQueryParameters represents data for AnswerCallbackQuery method.
type AnswerCallbackQueryParameters struct {
// Unique identifier for the query to be answered
CallbackQueryID string `json:"callback_query_id"`
// Text of the notification. If not specified, nothing will be shown to the
// user, 0-200 characters
Text string `json:"text,omitempty"`
// URL that will be opened by the user's client. If you have created a Game
// and accepted the conditions via @Botfather, specify the URL that opens
// your game note that this will only work if the query comes from a
// callback_game button.
//
// Otherwise, you may use links like t.me/your_bot?start=XXXX that open your
// bot with a parameter.
URL string `json:"url,omitempty"`
// If true, an alert will be shown by the client instead of a notification at
// the top of the chat screen. Defaults to false.
ShowAlert bool `json:"show_alert,omitempty"`
// The maximum amount of time in seconds that the result of the callback
// query may be cached client-side. Telegram apps will support caching
// starting in version 3.14. Defaults to 0.
CacheTime int `json:"cache_time,omitempty"`
}
// NewAnswerCallbackQuery creates AnswerCallbackQueryParameters only with
// required parameters.
func NewAnswerCallbackQuery(callbackQueryID string) *AnswerCallbackQueryParameters {
return &AnswerCallbackQueryParameters{CallbackQueryID: callbackQueryID}
}
// AnswerCallbackQuery send answers to callback queries sent from inline
// keyboards. The answer will be displayed to the user as a notification at the
// top of the chat screen or as an alert. On success, True is returned.
//
// Alternatively, the user can be redirected to the specified Game URL. For this
// option to work, you must first create a game for your bot via @Botfather and
// accept the terms. Otherwise, you may use links like t.me/your_bot?start=XXXX
// that open your bot with a parameter.
func (bot *Bot) AnswerCallbackQuery(params *AnswerCallbackQueryParameters) (ok bool, err error) {
dst, err := json.Marshal(params)
if err != nil {
return
}
resp, err := bot.request(dst, MethodAnswerCallbackQuery)
if err != nil {
return
}
err = json.Unmarshal(*resp.Result, &ok)
return
}

View File

@@ -0,0 +1,55 @@
package telegram
import json "github.com/pquerna/ffjson/ffjson"
// AnswerPreCheckoutQueryParameters represents data for AnswerPreCheckoutQuery
// method.
type AnswerPreCheckoutQueryParameters struct {
// Unique identifier for the query to be answered
PreCheckoutQueryID string `json:"pre_checkout_query_id"`
// Required if ok is False. Error message in human readable form that
// explains the reason for failure to proceed with the checkout (e.g. "Sorry,
// somebody just bought the last of our amazing black T-shirts while you were
// busy filling out your payment details. Please choose a different color or
// garment!"). Telegram will display this message to the user.
ErrorMessage string `json:"error_message,omitempty"`
// Specify True if everything is alright (goods are available, etc.) and the
// bot is ready to proceed with the order. Use False if there are any
// problems.
Ok bool `json:"ok"`
}
// NewAnswerPreCheckoutQuery creates AnswerPreCheckoutQueryParameters only with
// required parameters.
func NewAnswerPreCheckoutQuery(preCheckoutQueryID string, ok bool) *AnswerPreCheckoutQueryParameters {
return &AnswerPreCheckoutQueryParameters{
PreCheckoutQueryID: preCheckoutQueryID,
Ok: ok,
}
}
// AnswerPreCheckoutQuery respond to such pre-checkout queries.
//
// Once the user has confirmed their payment and shipping details, the Bot API
// sends the final confirmation in the form of an Update with the field
// pre_checkout_query. Use this method to respond to such pre-checkout queries.
// On success, True is returned.
//
// Note: The Bot API must receive an answer within 10 seconds after the
// pre-checkout query was sent.
func (bot *Bot) AnswerPreCheckoutQuery(params *AnswerShippingQueryParameters) (ok bool, err error) {
dst, err := json.Marshal(params)
if err != nil {
return
}
resp, err := bot.request(dst, MethodAnswerPreCheckoutQuery)
if err != nil {
return
}
err = json.Unmarshal(*resp.Result, &ok)
return
}

View File

@@ -0,0 +1,53 @@
package telegram
import json "github.com/pquerna/ffjson/ffjson"
// AnswerShippingQueryParameters represents data for AnswerShippingQuery method.
type AnswerShippingQueryParameters struct {
// Unique identifier for the query to be answered
ShippingQueryID string `json:"shipping_query_id"`
// Required if ok is False. Error message in human readable form that
// explains why it is impossible to complete the order (e.g. "Sorry, delivery
// to your desired address is unavailable'). Telegram will display this
// message to the user.
ErrorMessage string `json:"error_message,omitempty"`
// Specify True if delivery to the specified address is possible and False
// if there are any problems (for example, if delivery to the specified
// address is not possible)
Ok bool `json:"ok"`
// Required if ok is True. A JSON-serialized array of available shipping
// options.
ShippingOptions []ShippingOption `json:"shipping_options,omitempty"`
}
// NewAnswerShippingQuery creates AnswerShippingQueryParameters only with
// required parameters.
func NewAnswerShippingQuery(shippingQueryID string, ok bool) *AnswerShippingQueryParameters {
return &AnswerShippingQueryParameters{
ShippingQueryID: shippingQueryID,
Ok: ok,
}
}
// AnswerShippingQuery reply to shipping queries.
//
// If you sent an invoice requesting a shipping address and the parameter
// is_flexible was specified, the Bot API will send an Update with a
// shipping_query field to the bot. On success, True is returned.
func (bot *Bot) AnswerShippingQuery(params *AnswerShippingQueryParameters) (ok bool, err error) {
dst, err := json.Marshal(params)
if err != nil {
return
}
resp, err := bot.request(dst, MethodAnswerShippingQuery)
if err != nil {
return
}
err = json.Unmarshal(*resp.Result, &ok)
return
}

192
vendor/gitlab.com/toby3d/telegram/const.go generated vendored Normal file
View File

@@ -0,0 +1,192 @@
package telegram
// Version represents current version of Telegram API supported by this package
const Version = 4.0
// Action represents available and supported status actions of bot
const (
ActionFindLocation = "find_location"
ActionRecordAudio = "record_audio"
ActionRecordVideo = "record_video"
ActionRecordVideoNote = "record_video_note"
ActionTyping = "typing"
ActionUploadAudio = "upload_audio"
ActionUploadDocument = "upload_document"
ActionUploadPhoto = "upload_photo"
ActionUploadVideo = "upload_video"
ActionUploadVideoNote = "upload_video_note"
)
// Chat represents available and supported chat types
const (
ChatChannel = "channel"
ChatGroup = "group"
ChatPrivate = "private"
ChatSuperGroup = "supergroup"
)
// Command represents global commands which should be supported by any bot.
// You can user IsCommandEqual method of Message for checking.
//
// See: https://core.telegram.org/bots#global-commands
const (
CommandStart = "start"
CommandHelp = "help"
CommandSettings = "settings"
)
// Entity represents available and supported entity types
const (
EntityBold = "bold"
EntityBotCommand = "bot_command"
EntityCashtag = "cashtag"
EntityCode = "code"
EntityEmail = "email"
EntityHashtag = "hashtag"
EntityItalic = "italic"
EntityMention = "mention"
EntityPhoneNumber = "phone_number"
EntityPre = "pre"
EntityTextLink = "text_link"
EntityTextMention = "text_mention"
EntityURL = "url"
)
// Method represents available and supported Telegram API methods
const (
MethodAddStickerToSet = "addStickerToSet"
MethodAnswerCallbackQuery = "answerCallbackQuery"
MethodAnswerInlineQuery = "answerInlineQuery"
MethodAnswerPreCheckoutQuery = "answerPreCheckoutQuery"
MethodAnswerShippingQuery = "answerShippingQuery"
MethodCreateNewStickerSet = "createNewStickerSet"
MethodDeleteChatPhoto = "deleteChatPhoto"
MethodDeleteChatStickerSet = "deleteChatStickerSet"
MethodDeleteMessage = "deleteMessage"
MethodDeleteStickerFromSet = "deleteStickerFromSet"
MethodDeleteWebhook = "deleteWebhook"
MethodEditMessageCaption = "editMessageCaption"
MethodEditMessageLiveLocation = "editMessageLiveLocation"
MethodEditMessageMedia = "editMessageMedia"
MethodEditMessageReplyMarkup = "editMessageReplyMarkup"
MethodEditMessageText = "editMessageText"
MethodExportChatInviteLink = "exportChatInviteLink"
MethodForwardMessage = "forwardMessage"
MethodGetChat = "getChat"
MethodGetChatAdministrators = "getChatAdministrators"
MethodGetChatMember = "getChatMember"
MethodGetChatMembersCount = "getChatMembersCount"
MethodGetFile = "getFile"
MethodGetGameHighScores = "getGameHighScores"
MethodGetMe = "getMe"
MethodGetStickerSet = "getStickerSet"
MethodGetUpdates = "getUpdates"
MethodGetUserProfilePhotos = "getUserProfilePhotos"
MethodGetWebhookInfo = "getWebhookInfo"
MethodKickChatMember = "kickChatMember"
MethodLeaveChat = "leaveChat"
MethodPinChatMessage = "pinChatMessage"
MethodPromoteChatMember = "promoteChatMember"
MethodRestrictChatMember = "restrictChatMember"
MethodSendAnimation = "sendAnimation"
MethodSendAudio = "sendAudio"
MethodSendChatAction = "sendChatAction"
MethodSendContact = "sendContact"
MethodSendDocument = "sendDocument"
MethodSendGame = "sendGame"
MethodSendInvoice = "sendInvoice"
MethodSendLocation = "sendLocation"
MethodSendMediaGroup = "sendMediaGroup"
MethodSendMessage = "sendMessage"
MethodSendPhoto = "sendPhoto"
MethodSendSticker = "sendSticker"
MethodSendVenue = "sendVenue"
MethodSendVideo = "sendVideo"
MethodSendVideoNote = "sendVideoNote"
MethodSendVoice = "sendVoice"
MethodSetChatDescription = "setChatDescription"
MethodSetChatPhoto = "setChatPhoto"
MethodSetChatStickerSet = "setChatStickerSet"
MethodSetChatTitle = "setChatTitle"
MethodSetGameScore = "setGameScore"
MethodSetPassportDataErrors = "setPassportDataErrors"
MethodSetStickerPositionInSet = "setStickerPositionInSet"
MethodSetWebhook = "setWebhook"
MethodStopMessageLiveLocation = "stopMessageLiveLocation"
MethodUnbanChatMember = "unbanChatMember"
MethodUnpinChatMessage = "unpinChatMessage"
MethodUploadStickerFile = "uploadStickerFile"
)
// Mode represents available and supported parsing modes of messages
const (
StyleHTML = "html"
StyleMarkdown = "markdown"
)
// Mime represents available and supported MIME types of data
const (
MimeHTML = "text/html"
MimeMP4 = "video/mp4"
MimePDF = "application/pdf"
MimeZIP = "application/zip"
)
// Scheme represents optional schemes for URLs
const (
SchemeAttach = "attach"
SchemeTelegram = "tg"
)
// Status represents available and supported statuses of ID
const (
StatusAdministrator = "administrator"
StatusCreator = "creator"
StatusKicked = "kicked"
StatusLeft = "left"
StatusMember = "member"
StatusRestricted = "restricted"
)
// Type represents available and supported types of data
const (
TypeAddress = "address"
TypeArticle = "article"
TypeAudio = "audio"
TypeBankStatement = "bank_statement"
TypeContact = "contact"
TypeDocument = "document"
TypeDriverLicense = "driver_license"
TypeEmail = "email"
TypeGame = "game"
TypeGIF = "gif"
TypeIdentityCard = "identity_card"
TypeInternalPassport = "internal_passport"
TypeLocation = "location"
TypeMpeg4Gif = "mpeg4_gif"
TypePassport = "passport"
TypePassportRegistration = "passport_registration"
TypePersonalDetails = "personal_details"
TypePhoneNumber = "phone_number"
TypePhoto = "photo"
TypeRentalAgreement = "rental_agreement"
TypeSticker = "sticker"
TypeTemporaryRegistration = "temporary_registration"
TypeUtilityBill = "utility_bill"
TypeVenue = "venue"
TypeVideo = "video"
TypeVoice = "voice"
)
// Update represents available and supported types of updates
const (
UpdateCallbackQuery = "callback_query"
UpdateChannelPost = "channel_post"
UpdateChosenInlineResult = "chosen_inline_result"
UpdateEditedChannelPost = "edited_channel_post"
UpdateEditedMessage = "edited_message"
UpdateInlineQuery = "inline_query"
UpdateMessage = "message"
UpdatePreCheckoutQuery = "pre_checkout_query"
UpdateShippingQuery = "shipping_query"
)

30
vendor/gitlab.com/toby3d/telegram/delete_chat_photo.go generated vendored Normal file
View File

@@ -0,0 +1,30 @@
package telegram
import json "github.com/pquerna/ffjson/ffjson"
// DeleteChatPhotoParameters represents data for DeleteChatPhoto method.
type DeleteChatPhotoParameters struct {
// Unique identifier for the target chat
ChatID int64 `json:"chat_id"`
}
// DeleteChatPhoto delete a chat photo. Photos can't be changed for private
// chats. The bot must be an administrator in the chat for this to work and must
// have the appropriate admin rights. Returns True on success.
//
// Note: In regular groups (non-supergroups), this method will only work if the
// 'All Members Are Admins' setting is off in the target group.
func (bot *Bot) DeleteChatPhoto(chatID int64) (ok bool, err error) {
dst, err := json.Marshal(&DeleteChatPhotoParameters{ChatID: chatID})
if err != nil {
return
}
resp, err := bot.request(dst, MethodDeleteChatPhoto)
if err != nil {
return
}
err = json.Unmarshal(*resp.Result, &ok)
return
}

View File

@@ -0,0 +1,28 @@
package telegram
import json "github.com/pquerna/ffjson/ffjson"
// DeleteChatStickerSetParameters represents data for DeleteChatStickerSet method.
type DeleteChatStickerSetParameters struct {
// Unique identifier for the target chat
ChatID int64 `json:"chat_id"`
}
// DeleteChatStickerSet delete a group sticker set from a supergroup. The bot must be an administrator
// in the chat for this to work and must have the appropriate admin rights. Use the field
// can_set_sticker_set optionally returned in getChat requests to check if the bot can use this
// method. Returns True on success.
func (bot *Bot) DeleteChatStickerSet(chatID int64) (ok bool, err error) {
dst, err := json.Marshal(&DeleteChatStickerSetParameters{ChatID: chatID})
if err != nil {
return
}
resp, err := bot.request(dst, MethodDeleteChatStickerSet)
if err != nil {
return
}
err = json.Unmarshal(*resp.Result, &ok)
return
}

15
vendor/gitlab.com/toby3d/telegram/delete_webhook.go generated vendored Normal file
View File

@@ -0,0 +1,15 @@
package telegram
import json "github.com/pquerna/ffjson/ffjson"
// DeleteWebhook remove webhook integration if you decide to switch back to
// getUpdates. Returns True on success. Requires no parameters.
func (bot *Bot) DeleteWebhook() (ok bool, err error) {
resp, err := bot.request(nil, MethodDeleteWebhook)
if err != nil {
return
}
err = json.Unmarshal(*resp.Result, &ok)
return
}

2
vendor/gitlab.com/toby3d/telegram/doc.go generated vendored Normal file
View File

@@ -0,0 +1,2 @@
// Package telegram contains bindings for the Telegram API
package telegram

View File

@@ -0,0 +1,59 @@
package telegram
import json "github.com/pquerna/ffjson/ffjson"
// EditMessageLiveLocationParameters represents data for EditMessageLiveLocation
// method.
type EditMessageLiveLocationParameters struct {
// Required if inline_message_id is not specified. Unique identifier for the
// target chat or username of the target channel (in the format
// @channelusername)
ChatID int64 `json:"chat_id,omitempty"`
// Required if inline_message_id is not specified. Identifier of the sent
// message
MessageID int `json:"message_id,omitempty"`
// Required if chat_id and message_id are not specified. Identifier of the
// inline message
InlineMessageID string `json:"inline_message_id,omitempty"`
// Latitude of new location
Latitude float32 `json:"latitude"`
// Longitude of new location
Longitude float32 `json:"longitude"`
// A JSON-serialized object for a new inline keyboard.
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
}
// NewLiveLocation creates EditMessageLiveLocationParameters only with required
// parameters.
func NewLiveLocation(latitude, longitude float32) *EditMessageLiveLocationParameters {
return &EditMessageLiveLocationParameters{
Latitude: latitude,
Longitude: longitude,
}
}
// EditMessageLiveLocation edit live location messages sent by the bot or via the
// bot (for inline bots). A location can be edited until its live_period expires
// or editing is explicitly disabled by a call to stopMessageLiveLocation. On
// success, if the edited message was sent by the bot, the edited Message is
// returned, otherwise True is returned.
func (bot *Bot) EditMessageLiveLocation(params *EditMessageLiveLocationParameters) (msg *Message, err error) {
dst, err := json.Marshal(params)
if err != nil {
return
}
resp, err := bot.request(dst, MethodEditMessageLiveLocation)
if err != nil {
return
}
msg = new(Message)
err = json.Unmarshal(*resp.Result, msg)
return
}

View File

@@ -0,0 +1,27 @@
package telegram
import json "github.com/pquerna/ffjson/ffjson"
// ExportChatInviteLinkParameters represents data for ExportChatInviteLink method.
type ExportChatInviteLinkParameters struct {
// Unique identifier for the target chat
ChatID int64 `json:"chat_id"`
}
// ExportChatInviteLink export an invite link to a supergroup or a channel. The
// bot must be an administrator in the chat for this to work and must have the
// appropriate admin rights. Returns exported invite link as String on success.
func (bot *Bot) ExportChatInviteLink(chatID int64) (inviteLink string, err error) {
dst, err := json.Marshal(&ExportChatInviteLinkParameters{ChatID: chatID})
if err != nil {
return
}
resp, err := bot.request(dst, MethodExportChatInviteLink)
if err != nil {
return
}
err = json.Unmarshal(*resp.Result, &inviteLink)
return
}

47
vendor/gitlab.com/toby3d/telegram/forward_message.go generated vendored Normal file
View File

@@ -0,0 +1,47 @@
package telegram
import json "github.com/pquerna/ffjson/ffjson"
// ForwardMessageParameters represents data for ForwardMessage method.
type ForwardMessageParameters struct {
// Unique identifier for the target chat or username of the target
// channel (in the format @channelusername)
ChatID int64 `json:"chat_id"`
// Unique identifier for the chat where the original message was sent
// (or channel username in the format @channelusername)
FromChatID int64 `json:"from_chat_id"`
// Sends the message silently. Users will receive a notification with no
// sound.
DisableNotification bool `json:"disable_notification,omitempty"`
// Message identifier in the chat specified in from_chat_id
MessageID int `json:"message_id"`
}
// NewForwardMessage creates ForwardMessageParameters only with reqired parameters.
func NewForwardMessage(from, to int64, messageID int) *ForwardMessageParameters {
return &ForwardMessageParameters{
FromChatID: from,
ChatID: to,
MessageID: messageID,
}
}
// ForwardMessage forward messages of any kind. On success, the sent Message is returned.
func (bot *Bot) ForwardMessage(params *ForwardMessageParameters) (msg *Message, err error) {
dst, err := json.Marshal(params)
if err != nil {
return
}
resp, err := bot.request(dst, MethodForwardMessage)
if err != nil {
return
}
msg = new(Message)
err = json.Unmarshal(*resp.Result, msg)
return
}

28
vendor/gitlab.com/toby3d/telegram/get_chat.go generated vendored Normal file
View File

@@ -0,0 +1,28 @@
package telegram
import json "github.com/pquerna/ffjson/ffjson"
// GetChatParameters represents data for GetChat method.
type GetChatParameters struct {
// Unique identifier for the target chat
ChatID int64 `json:"chat_id"`
}
// GetChat get up to date information about the chat (current name of the user
// for one-on-one conversations, current username of a user, group or channel,
// etc.). Returns a Chat object on success.
func (bot *Bot) GetChat(chatID int64) (chat *Chat, err error) {
dst, err := json.Marshal(&GetChatParameters{ChatID: chatID})
if err != nil {
return
}
resp, err := bot.request(dst, MethodGetChat)
if err != nil {
return
}
chat = new(Chat)
err = json.Unmarshal(*resp.Result, chat)
return
}

View File

@@ -0,0 +1,29 @@
package telegram
import json "github.com/pquerna/ffjson/ffjson"
// GetChatAdministratorsParameters represents data for GetChatAdministrators
// method.
type GetChatAdministratorsParameters struct {
// Unique identifier for the target chat
ChatID int64 `json:"chat_id"`
}
// GetChatAdministrators get a list of administrators in a chat. On success,
// returns an Array of ChatMember objects that contains information about all
// chat administrators except other bots. If the chat is a group or a supergroup
// and no administrators were appointed, only the creator will be returned.
func (bot *Bot) GetChatAdministrators(chatID int64) (members []ChatMember, err error) {
dst, err := json.Marshal(&GetChatAdministratorsParameters{ChatID: chatID})
if err != nil {
return
}
resp, err := bot.request(dst, MethodGetChatAdministrators)
if err != nil {
return
}
err = json.Unmarshal(*resp.Result, &members)
return
}

33
vendor/gitlab.com/toby3d/telegram/get_chat_member.go generated vendored Normal file
View File

@@ -0,0 +1,33 @@
package telegram
import json "github.com/pquerna/ffjson/ffjson"
// GetChatMemberParameters represents data for GetChatMember method.
type GetChatMemberParameters struct {
// Unique identifier for the target chat
ChatID int64 `json:"chat_id"`
// Unique identifier of the target user
UserID int `json:"user_id"`
}
// GetChatMember get information about a member of a chat. Returns a ChatMember
// object on success.
func (bot *Bot) GetChatMember(chatID int64, userID int) (member *ChatMember, err error) {
dst, err := json.Marshal(&GetChatMemberParameters{
ChatID: chatID,
UserID: userID,
})
if err != nil {
return
}
resp, err := bot.request(dst, MethodGetChatMember)
if err != nil {
return
}
member = new(ChatMember)
err = json.Unmarshal(*resp.Result, member)
return
}

View File

@@ -0,0 +1,26 @@
package telegram
import json "github.com/pquerna/ffjson/ffjson"
// GetChatMembersCountParameters represents data for GetChatMembersCount method.
type GetChatMembersCountParameters struct {
// Unique identifier for the target chat
ChatID int64 `json:"chat_id"`
}
// GetChatMembersCount get the number of members in a chat. Returns Int on
// success.
func (bot *Bot) GetChatMembersCount(chatID int64) (count int, err error) {
dst, err := json.Marshal(&GetChatMembersCountParameters{ChatID: chatID})
if err != nil {
return
}
resp, err := bot.request(dst, MethodGetChatMembersCount)
if err != nil {
return
}
err = json.Unmarshal(*resp.Result, &count)
return
}

36
vendor/gitlab.com/toby3d/telegram/get_file.go generated vendored Normal file
View File

@@ -0,0 +1,36 @@
package telegram
import json "github.com/pquerna/ffjson/ffjson"
// GetFileParameters represents data for GetFile method.
type GetFileParameters struct {
// File identifier to get info about
FileID string `json:"file_id"`
}
// GetFile get basic info about a file and prepare it for downloading. For the
// moment, bots can download files of up to 20MB in size. On success, a File
// object is returned. The file can then be downloaded via the link
// https://api.telegram.org/file/bot<token>/<file_path>, where <file_path> is
// taken from the response. It is guaranteed that the link will be valid for at
// least 1 hour. When the link expires, a new one can be requested by calling
// getFile again.
//
// Note: This function may not preserve the original file name and MIME type. You
// should save the file's MIME type and name (if available) when the File object
// is received.
func (bot *Bot) GetFile(fileID string) (file *File, err error) {
dst, err := json.Marshal(&GetFileParameters{FileID: fileID})
if err != nil {
return
}
resp, err := bot.request(dst, MethodGetFile)
if err != nil {
return
}
file = new(File)
err = json.Unmarshal(*resp.Result, file)
return
}

16
vendor/gitlab.com/toby3d/telegram/get_me.go generated vendored Normal file
View File

@@ -0,0 +1,16 @@
package telegram
import json "github.com/pquerna/ffjson/ffjson"
// GetMe testing your bot's auth token. Requires no parameters. Returns basic
// information about the bot in form of a User object.
func (bot *Bot) GetMe() (me *User, err error) {
resp, err := bot.request(nil, MethodGetMe)
if err != nil {
return
}
me = new(User)
err = json.Unmarshal(*resp.Result, me)
return
}

59
vendor/gitlab.com/toby3d/telegram/get_updates.go generated vendored Normal file
View File

@@ -0,0 +1,59 @@
package telegram
import json "github.com/pquerna/ffjson/ffjson"
// GetUpdatesParameters represents data for GetUpdates method.
type GetUpdatesParameters struct {
// Identifier of the first update to be returned. Must be greater by one than
// the highest among the identifiers of previously received updates. By
// default, updates starting with the earliest unconfirmed update are
// returned. An update is considered confirmed as soon as getUpdates is
// called with an offset higher than its update_id. The negative offset can
// be specified to retrieve updates starting from -offset update from the
// end of the updates queue. All previous updates will forgotten.
Offset int `json:"offset,omitempty"`
// Limits the number of updates to be retrieved. Values between 1—100 are
// accepted. Defaults to 100.
Limit int `json:"limit,omitempty"`
// Timeout in seconds for long polling. Defaults to 0, i.e. usual short
// polling. Should be positive, short polling should be used for testing
// purposes only.
Timeout int `json:"timeout,omitempty"`
// List the types of updates you want your bot to receive. For example,
// specify [“message”, “edited_channel_post”, “callback_query”] to only
// receive updates of these types. See Update for a complete list of
// available update types. Specify an empty list to receive all updates
// regardless of type (default). If not specified, the previous setting will
// be used.
//
// Please note that this parameter doesn't affect updates created before the
// call to the getUpdates, so unwanted updates may be received for a short
// period of time.
AllowedUpdates []string `json:"allowed_updates,omitempty"`
}
// GetUpdates receive incoming updates using long polling. An Array of
// Update objects is returned.
func (bot *Bot) GetUpdates(params *GetUpdatesParameters) (updates []Update, err error) {
dst, err := json.Marshal(params)
if err != nil {
return
}
resp, err := bot.request(dst, MethodGetUpdates)
if err != nil {
return
}
if params == nil {
params = new(GetUpdatesParameters)
params.Limit = 100
}
updates = make([]Update, params.Limit)
err = json.Unmarshal(*resp.Result, &updates)
return
}

View File

@@ -0,0 +1,34 @@
package telegram
import json "github.com/pquerna/ffjson/ffjson"
// GetUserProfilePhotosParameters represents data for GetUserProfilePhotos method.
type GetUserProfilePhotosParameters struct {
// Unique identifier of the target user
UserID int `json:"user_id"`
// Sequential number of the first photo to be returned. By default, all
// photos are returned.
Offset int `json:"offset,omitempty"`
// Limits the number of photos to be retrieved. Values between 1—100 are
// accepted. Defaults to 100.
Limit int `json:"limit,omitempty"`
}
// GetUserProfilePhotos get a list of profile pictures for a user. Returns a UserProfilePhotos object.
func (bot *Bot) GetUserProfilePhotos(params *GetUserProfilePhotosParameters) (photos *UserProfilePhotos, err error) {
dst, err := json.Marshal(params)
if err != nil {
return
}
resp, err := bot.request(dst, MethodGetUserProfilePhotos)
if err != nil {
return
}
photos = new(UserProfilePhotos)
err = json.Unmarshal(*resp.Result, photos)
return
}

17
vendor/gitlab.com/toby3d/telegram/get_webhook_info.go generated vendored Normal file
View File

@@ -0,0 +1,17 @@
package telegram
import json "github.com/pquerna/ffjson/ffjson"
// GetWebhookInfo get current webhook status. Requires no parameters. On success,
// returns a WebhookInfo object. If the bot is using getUpdates, will return an
// object with the url field empty.
func (bot *Bot) GetWebhookInfo() (info *WebhookInfo, err error) {
resp, err := bot.request(nil, MethodGetWebhookInfo)
if err != nil {
return
}
info = new(WebhookInfo)
err = json.Unmarshal(*resp.Result, info)
return
}

40
vendor/gitlab.com/toby3d/telegram/kick_chat_member.go generated vendored Normal file
View File

@@ -0,0 +1,40 @@
package telegram
import json "github.com/pquerna/ffjson/ffjson"
// KickChatMemberParameters represents data for KickChatMember method.
type KickChatMemberParameters struct {
// Unique identifier for the target chat
ChatID int64 `json:"chat_id"`
// Unique identifier of the target user
UserID int `json:"user_id"`
// Date when the user will be unbanned, unix time. If user is banned for
// more than 366 days or less than 30 seconds from the current time they
// are considered to be banned forever
UntilDate int64 `json:"until_date"`
}
// KickChatMember kick a user from a group, a supergroup or a channel. In the case of supergroups and
// channels, the user will not be able to return to the group on their own using invite links, etc.,
// unless unbanned first. The bot must be an administrator in the chat for this to work and must have
// the appropriate admin rights. Returns True on success.
//
// Note: In regular groups (non-supergroups), this method will only work if the 'All Members Are
// Admins' setting is off in the target group. Otherwise members may only be removed by the group's
// creator or by the member that added them.
func (bot *Bot) KickChatMember(params *KickChatMemberParameters) (ok bool, err error) {
dst, err := json.Marshal(params)
if err != nil {
return
}
resp, err := bot.request(dst, MethodKickChatMember)
if err != nil {
return
}
err = json.Unmarshal(*resp.Result, &ok)
return
}

25
vendor/gitlab.com/toby3d/telegram/leave_chat.go generated vendored Normal file
View File

@@ -0,0 +1,25 @@
package telegram
import json "github.com/pquerna/ffjson/ffjson"
// LeaveChatParameters represents data for LeaveChat method.
type LeaveChatParameters struct {
// Unique identifier for the target chat
ChatID int64 `json:"chat_id"`
}
// LeaveChat leave a group, supergroup or channel. Returns True on success.
func (bot *Bot) LeaveChat(chatID int64) (ok bool, err error) {
dst, err := json.Marshal(&LeaveChatParameters{ChatID: chatID})
if err != nil {
return
}
resp, err := bot.request(dst, MethodLeaveChat)
if err != nil {
return
}
err = json.Unmarshal(*resp.Result, &ok)
return
}

152
vendor/gitlab.com/toby3d/telegram/methods_games.go generated vendored Normal file
View File

@@ -0,0 +1,152 @@
package telegram
import json "github.com/pquerna/ffjson/ffjson"
type (
// SendGameParameters represents data for SendGame method.
SendGameParameters struct {
// Unique identifier for the target chat
ChatID int64 `json:"chat_id"`
// Short name of the game, serves as the unique identifier for the game. Set
// up your games via Botfather.
GameShortName string `json:"game_short_name"`
// Sends the message silently. Users will receive a notification with no
// sound.
DisableNotification bool `json:"disable_notification,omitempty"`
// If the message is a reply, ID of the original message
ReplyToMessageID int `json:"reply_to_message_id,omitempty"`
// A JSON-serialized object for an inline keyboard. If empty, one Play
// game_title button will be shown. If not empty, the first button must
// launch the game.
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
}
// SetGameScoreParameters represents data for SetGameScore method.
SetGameScoreParameters struct {
// User identifier
UserID int `json:"user_id"`
// New score, must be non-negative
Score int `json:"score"`
// Required if inline_message_id is not specified. Identifier of the sent
// message
MessageID int `json:"message_id,omitempty"`
// Pass True, if the high score is allowed to decrease. This can be useful
// when fixing mistakes or banning cheaters
Force bool `json:"force,omitempty"`
// Pass True, if the game message should not be automatically edited to
// include the current scoreboard
DisableEditMessage bool `json:"disable_edit_message,omitempty"`
// Required if inline_message_id is not specified. Unique identifier for the
// target chat
ChatID int64 `json:"chat_id,omitempty"`
// Required if chat_id and message_id are not specified. Identifier of the
// inline message
InlineMessageID string `json:"inline_message_id,omitempty"`
}
// GetGameHighScoresParameters represents data for GetGameHighScores method.
GetGameHighScoresParameters struct {
// Target user id
UserID int `json:"user_id"`
// Required if inline_message_id is not specified. Identifier of the sent
// message
MessageID int `json:"message_id,omitempty"`
// Required if inline_message_id is not specified. Unique identifier for the
// target chat
ChatID int64 `json:"chat_id,omitempty"`
// Required if chat_id and message_id are not specified. Identifier of the
// inline message
InlineMessageID string `json:"inline_message_id,omitempty"`
}
)
// NewGame creates SendGameParameters only with required parameters.
func NewGame(chatID int64, gameShortName string) *SendGameParameters {
return &SendGameParameters{
ChatID: chatID,
GameShortName: gameShortName,
}
}
// SendGame send a game. On success, the sent Message is returned.
func (bot *Bot) SendGame(params *SendGameParameters) (msg *Message, err error) {
dst, err := json.Marshal(params)
if err != nil {
return
}
resp, err := bot.request(dst, MethodSendGame)
if err != nil {
return
}
msg = new(Message)
err = json.Unmarshal(*resp.Result, msg)
return
}
// NewGameScore creates SetGameScoreParameters only with required parameters.
func NewGameScore(userID, score int) *SetGameScoreParameters {
return &SetGameScoreParameters{
UserID: userID,
Score: score,
}
}
// SetGameScore set the score of the specified user in a game. On success, if the
// message was sent by the bot, returns the edited Message, otherwise returns
// True. Returns an error, if the new score is not greater than the user's
// current score in the chat and force is False.
func (bot *Bot) SetGameScore(params *SetGameScoreParameters) (msg *Message, err error) {
dst, err := json.Marshal(params)
if err != nil {
return
}
resp, err := bot.request(dst, MethodSetGameScore)
if err != nil {
return
}
msg = new(Message)
err = json.Unmarshal(*resp.Result, msg)
return
}
// NewGameHighScores creates GetGameHighScoresParameters only with required parameters.
func NewGameHighScores(userID int) *GetGameHighScoresParameters {
return &GetGameHighScoresParameters{
UserID: userID,
}
}
// GetGameHighScores get data for high score tables. Will return the score of the
// specified user and several of his neighbors in a game. On success, returns an
// Array of GameHighScore objects.
func (bot *Bot) GetGameHighScores(params *GetGameHighScoresParameters) (scores []GameHighScore, err error) {
dst, err := json.Marshal(params)
if err != nil {
return
}
resp, err := bot.request(dst, MethodGetGameHighScores)
if err != nil {
return
}
err = json.Unmarshal(*resp.Result, &scores)
return
}

View File

@@ -0,0 +1,64 @@
package telegram
import json "github.com/pquerna/ffjson/ffjson"
// AnswerInlineQueryParameters represents data for AnswerInlineQuery method.
type AnswerInlineQueryParameters struct {
// Unique identifier for the answered query
InlineQueryID string `json:"inline_query_id"`
// Pass the offset that a client should send in the next query with the same
// text to receive more results. Pass an empty string if there are no more
// results or if you dont support pagination. Offset length cant exceed 64
// bytes.
NextOffset string `json:"next_offset,omitempty"`
// If passed, clients will display a button with specified text that switches
// the user to a private chat with the bot and sends the bot a start message
// with the parameter switch_pm_parameter
SwitchPrivateMessageText string `json:"switch_pm_text,omitempty"`
// Deep-linking parameter for the /start message sent to the bot when user
// presses the switch button. 1-64 characters, only A-Z, a-z, 0-9, _ and -
// are allowed.
SwitchPrivateMessageParameter string `json:"switch_pm_parameter,omitempty"`
// A JSON-serialized array of results for the inline query
Results []interface{} `json:"results"`
// The maximum amount of time in seconds that the result of the inline query
// may be cached on the server. Defaults to 300.
CacheTime int `json:"cache_time,omitempty"`
// Pass True, if results may be cached on the server side only for the user
// that sent the query. By default, results may be returned to any user who
// sends the same query
IsPersonal bool `json:"is_personal,omitempty"`
}
// NewAnswerInlineQuery creates AnswerInlineQueryParameters only with required
// parameters.
func NewAnswerInlineQuery(inlineQueryID string, results ...interface{}) *AnswerInlineQueryParameters {
return &AnswerInlineQueryParameters{
InlineQueryID: inlineQueryID,
Results: results,
}
}
// AnswerInlineQuery send answers to an inline query. On success, True is returned.
//
// No more than 50 results per query are allowed.
func (bot *Bot) AnswerInlineQuery(params *AnswerInlineQueryParameters) (ok bool, err error) {
dst, err := json.Marshal(params)
if err != nil {
return
}
resp, err := bot.request(dst, MethodAnswerInlineQuery)
if err != nil {
return
}
err = json.Unmarshal(*resp.Result, &ok)
return
}

279
vendor/gitlab.com/toby3d/telegram/methods_stickers.go generated vendored Normal file
View File

@@ -0,0 +1,279 @@
package telegram
import (
"strconv"
"strings"
json "github.com/pquerna/ffjson/ffjson"
http "github.com/valyala/fasthttp"
)
type (
// SendStickerParameters represents data for SetSticker method.
SendStickerParameters struct {
// Unique identifier for the target chat
ChatID int64 `json:"chat_id"`
// Sticker to send
Sticker interface{} `json:"sticker"`
// Sends the message silently. Users will receive a notification
// with no sound
DisableNotification bool `json:"disable_notification,omitempty"`
// If the message is a reply, ID of the original message
ReplyToMessageID int `json:"reply_to_message_id,omitempty"`
// Additional interface options. A JSON-serialized object for an
// inline keyboard, custom reply keyboard, instructions to remove
// reply keyboard or to force a reply from the user.
ReplyMarkup interface{} `json:"reply_markup,omitempty"`
}
// GetStickerSetParameters represents data for GetStickerSet method.
GetStickerSetParameters struct {
// Name of the sticker set
Name string `json:"name"`
}
UploadStickerFileParameters struct {
// User identifier of sticker file owner
UserID int `json:"user_id"`
// Png image with the sticker, must be up to 512 kilobytes in size,
// dimensions must not exceed 512px, and either width or height
// must be exactly 512px.
PNGSticker interface{} `json:"png_sticker"`
}
CreateNewStickerSetParameters struct {
// User identifier of created sticker set owner
UserID int `json:"user_id"`
// Short name of sticker set, to be used in t.me/addstickers/ URLs
// (e.g., animals). Can contain only english letters, digits and
// underscores. Must begin with a letter, can't contain consecutive
// underscores and must end in “_by_<bot username>”. <bot_username>
// is case insensitive. 1-64 characters.
Name string `json:"name"`
// Sticker set title, 1-64 characters
Title string `json:"title"`
// Png image with the sticker, must be up to 512 kilobytes in size,
// dimensions must not exceed 512px, and either width or height must
// be exactly 512px. Pass a file_id as a String to send a file that
// already exists on the Telegram servers, pass an HTTP URL as a
// String for Telegram to get a file from the Internet, or upload
// a new one using multipart/form-data.
PNGSticker interface{} `json:"png_sticker"`
// One or more emoji corresponding to the sticker
Emojis string `json:"emojis"`
// Pass True, if a set of mask stickers should be created
ContainsMasks bool `json:"contains_masks,omitempty"`
// A JSON-serialized object for position where the mask should be
// placed on faces
MaskPosition *MaskPosition `json:"mask_position,omitempty"`
}
AddStickerToSetParameters struct {
// User identifier of sticker set owner
UserID int `json:"user_id"`
// Sticker set name
Name string `json:"name"`
// Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px. Pass a file_id as a String to send a file that already exists on the Telegram servers, pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data. More info on Sending Files »
PNGSticker interface{} `json:"png_sticker"`
// One or more emoji corresponding to the sticker
Emojis string `json:"emojis"`
// A JSON-serialized object for position where the mask should be placed on faces
MaskPosition *MaskPosition `json:"mask_position,omitempty"`
}
// SetStickerPositionInSetParameters represents data for SetStickerPositionInSet
// method.
SetStickerPositionInSetParameters struct {
// File identifier of the sticker
Sticker string `json:"sticker"`
// New sticker position in the set, zero-based
Position int `json:"position"`
}
// DeleteStickerFromSetParameters represents data for DeleteStickerFromSet method.
DeleteStickerFromSetParameters struct {
// File identifier of the sticker
Sticker string `json:"sticker"`
}
)
// SendSticker send .webp stickers. On success, the sent Message is returned.
func (b *Bot) SendSticker(params *SendStickerParameters) (*Message, error) {
args := http.AcquireArgs()
defer http.ReleaseArgs(args)
args.Set("chat_id", strconv.FormatInt(params.ChatID, 10))
args.Set("disable_notification", strconv.FormatBool(params.DisableNotification))
if params.ReplyToMessageID > 0 {
args.SetUint("reply_to_message_id", params.ReplyToMessageID)
}
if params.ReplyMarkup != nil {
rm, err := json.Marshal(params.ReplyMarkup)
if err != nil {
return nil, err
}
args.SetBytesV("reply_markup", rm)
}
resp, err := b.Upload(MethodSendSticker, TypeSticker, "sticker", params.Sticker, args)
if err != nil {
return nil, err
}
var m Message
err = json.Unmarshal(*resp.Result, &m)
return &m, err
}
// GetStickerSet get a sticker set. On success, a StickerSet object is returned.
func (bot *Bot) GetStickerSet(name string) (set *StickerSet, err error) {
dst, err := json.Marshal(&GetStickerSetParameters{Name: name})
if err != nil {
return
}
resp, err := bot.request(dst, MethodGetStickerSet)
if err != nil {
return
}
set = new(StickerSet)
err = json.Unmarshal(*resp.Result, set)
return
}
// UploadStickerFile upload a .png file with a sticker for later use in
// createNewStickerSet and addStickerToSet methods (can be used multiple times).
// Returns the uploaded File on success.
func (b *Bot) UploadStickerFile(userID int, pngSticker interface{}) (*File, error) {
args := http.AcquireArgs()
defer http.ReleaseArgs(args)
args.SetUint("user_id", userID)
resp, err := b.Upload(MethodUploadStickerFile, TypeSticker, "sticker", pngSticker, args)
if err != nil {
return nil, err
}
var f File
err = json.Unmarshal(*resp.Result, &f)
return &f, err
}
// CreateNewStickerSet create new sticker set owned by a user. The bot will be
// able to edit the created sticker set. Returns True on success.
func (b *Bot) CreateNewStickerSet(params *CreateNewStickerSetParameters) (ok bool, err error) {
args := http.AcquireArgs()
defer http.ReleaseArgs(args)
args.SetUint("user_id", params.UserID)
if !strings.HasSuffix(strings.ToLower(params.Name), strings.ToLower("_by_"+b.Username)) {
params.Name = params.Name + "_by_" + b.Username
}
args.Set("name", params.Name)
args.Set("title", params.Title)
args.Set("emojis", params.Emojis)
args.Set("contains_masks", strconv.FormatBool(params.ContainsMasks))
if params.MaskPosition != nil {
mp, err := json.Marshal(params.MaskPosition)
if err != nil {
return false, err
}
args.SetBytesV("mask_position", mp)
}
resp, err := b.Upload(MethodCreateNewStickerSet, TypeSticker, "sticker", params.PNGSticker, args)
if err != nil {
return false, err
}
err = json.Unmarshal(*resp.Result, &ok)
return
}
// AddStickerToSet add a new sticker to a set created by the bot. Returns True
// on success.
func (b *Bot) AddStickerToSet(params *AddStickerToSetParameters) (ok bool, err error) {
args := http.AcquireArgs()
defer http.ReleaseArgs(args)
args.SetUint("user_id", params.UserID)
if !strings.HasSuffix(strings.ToLower(params.Name), strings.ToLower("_by_"+b.Username)) {
params.Name = params.Name + "_by_" + b.Username
}
args.Set("emojis", params.Emojis)
if params.MaskPosition != nil {
mp, err := json.Marshal(params.MaskPosition)
if err != nil {
return false, err
}
args.SetBytesV("mask_position", mp)
}
resp, err := b.Upload(MethodAddStickerToSet, TypeSticker, "sticker", params.PNGSticker, args)
if err != nil {
return false, err
}
err = json.Unmarshal(*resp.Result, &ok)
return
}
// SetStickerPositionInSet move a sticker in a set created by the bot to a
// specific position. Returns True on success.
func (b *Bot) SetStickerPositionInSet(sticker string, position int) (ok bool, err error) {
dst, err := json.Marshal(&SetStickerPositionInSetParameters{
Sticker: sticker,
Position: position,
})
if err != nil {
return
}
resp, err := b.request(dst, MethodSetStickerPositionInSet)
if err != nil {
return
}
err = json.Unmarshal(*resp.Result, &ok)
return
}
// DeleteStickerFromSet delete a sticker from a set created by the bot. Returns
// True on success.
func (bot *Bot) DeleteStickerFromSet(sticker string) (ok bool, err error) {
dst, err := json.Marshal(&DeleteStickerFromSetParameters{Sticker: sticker})
if err != nil {
return
}
resp, err := bot.request(dst, MethodDeleteStickerFromSet)
if err != nil {
return
}
err = json.Unmarshal(*resp.Result, &ok)
return
}

View File

@@ -0,0 +1,218 @@
package telegram
import json "github.com/pquerna/ffjson/ffjson"
type (
// EditMessageTextParameters represents data for EditMessageText method.
EditMessageTextParameters struct {
// Required if inline_message_id is not specified. Unique identifier for the
// target chat or username of the target channel (in the format
// @channelusername)
ChatID int64 `json:"chat_id,omitempty"`
// Required if inline_message_id is not specified. Identifier of the sent
// message
MessageID int `json:"message_id,omitempty"`
// Required if chat_id and message_id are not specified. Identifier of the
// inline message
InlineMessageID string `json:"inline_message_id,omitempty"`
// New text of the message
Text string `json:"text"`
// Send Markdown or HTML, if you want Telegram apps to show bold, italic,
// fixed-width text or inline URLs in your bot's message.
ParseMode string `json:"parse_mode,omitempty"`
// Disables link previews for links in this message
DisableWebPagePreview bool `json:"disable_web_page_preview,omitempty"`
// A JSON-serialized object for an inline keyboard.
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
}
// EditMessageCaptionParameters represents data for EditMessageCaption method.
EditMessageCaptionParameters struct {
// Required if inline_message_id is not specified. Unique identifier for the
// target chat or username of the target channel (in the format
// @channelusername)
ChatID int64 `json:"chat_id,omitempty"`
// Required if inline_message_id is not specified. Identifier of
// the sent message
MessageID int `json:"message_id,omitempty"`
// Required if chat_id and message_id are not specified. Identifier of the
// inline message
InlineMessageID string `json:"inline_message_id,omitempty"`
// New caption of the message
Caption string `json:"caption,omitempty"`
// Send Markdown or HTML, if you want Telegram apps to show bold, italic,
// fixed-width text or inline URLs in the media caption.
ParseMode string `json:"parse_mode,omitempty"`
// A JSON-serialized object for an inline keyboard.
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
}
// EditMessageMediaParameters represents data for EditMessageMedia method.
EditMessageMediaParameters struct {
// Required if inline_message_id is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
ChatID int64 `json:"chat_id,omitempty"`
// Required if inline_message_id is not specified. Identifier of the sent message
MessageID int `json:"message_id,omitempty"`
// Required if chat_id and message_id are not specified. Identifier of the inline message
InlineMessageID string `json:"inline_message_id,omitempty"`
// A JSON-serialized object for a new media content of the message
Media interface{} `json:"media"`
// A JSON-serialized object for a new inline keyboard.
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
}
// EditMessageReplyMarkupParameters represents data for EditMessageReplyMarkup method.
EditMessageReplyMarkupParameters struct {
// Required if inline_message_id is not specified. Unique identifier for the
// target chat or username of the target channel (in the format
// @channelusername)
ChatID int64 `json:"chat_id,omitempty"`
// Required if inline_message_id is not specified. Identifier of the sent
// message
MessageID int `json:"message_id,omitempty"`
// Required if chat_id and message_id are not specified. Identifier of the
// inline message
InlineMessageID string `json:"inline_message_id,omitempty"`
// A JSON-serialized object for an inline keyboard.
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
}
// DeleteMessageParameters represents data for DeleteMessage method.
DeleteMessageParameters struct {
// Unique identifier for the target chat
ChatID int64 `json:"chat_id"`
// Identifier of the message to delete
MessageID int `json:"message_id"`
}
)
// NewMessageText creates EditMessageTextParameters only with required parameters.
func NewMessageText(text string) *EditMessageTextParameters {
return &EditMessageTextParameters{
Text: text,
}
}
// EditMessageText edit text and game messages sent by the bot or via the bot
// (for inline bots). On success, if edited message is sent by the bot, the
// edited Message is returned, otherwise True is returned.
func (bot *Bot) EditMessageText(params *EditMessageTextParameters) (msg *Message, err error) {
dst, err := json.Marshal(params)
if err != nil {
return
}
resp, err := bot.request(dst, MethodEditMessageText)
if err != nil {
return
}
msg = new(Message)
err = json.Unmarshal(*resp.Result, msg)
return
}
// EditMessageCaption edit captions of messages sent by the bot or via the bot
// (for inline bots). On success, if edited message is sent by the bot, the
// edited Message is returned, otherwise True is returned.
func (bot *Bot) EditMessageCaption(params *EditMessageCaptionParameters) (msg *Message, err error) {
dst, err := json.Marshal(params)
if err != nil {
return
}
resp, err := bot.request(dst, MethodEditMessageCaption)
if err != nil {
return
}
msg = new(Message)
err = json.Unmarshal(*resp.Result, msg)
return
}
// EditMessageMedia edit audio, document, photo, or video messages. If a message
// is a part of a message album, then it can be edited only to a photo or a video.
// Otherwise, message type can be changed arbitrarily. When inline message is
// edited, new file can't be uploaded. Use previously uploaded file via its
// file_id or specify a URL. On success, if the edited message was sent by the
// bot, the edited Message is returned, otherwise True is returned.
func (b *Bot) EditMessageMedia(emmp *EditMessageMediaParameters) (msg *Message, err error) {
var src []byte
src, err = json.Marshal(emmp)
if err != nil {
return
}
resp, err := b.request(src, MethodEditMessageMedia)
if err != nil {
return
}
msg = new(Message)
err = json.Unmarshal(*resp.Result, msg)
return
}
// EditMessageReplyMarkup edit only the reply markup of messages sent by the bot
// or via the bot (for inline bots). On success, if edited message is sent by the
// bot, the edited Message is returned, otherwise True is returned.
func (bot *Bot) EditMessageReplyMarkup(params *EditMessageReplyMarkupParameters) (msg *Message, err error) {
dst, err := json.Marshal(params)
if err != nil {
return
}
resp, err := bot.request(dst, MethodEditMessageReplyMarkup)
if err != nil {
return
}
msg = new(Message)
err = json.Unmarshal(*resp.Result, msg)
return
}
// DeleteMessage delete a message, including service messages, with the following
// limitations: A message can only be deleted if it was sent less than 48 hours
// ago; Bots can delete outgoing messages in groups and supergroups; Bots granted
// can_post_messages permissions can delete outgoing messages in channels; If the
// bot is an administrator of a group, it can delete any message there; If the
// bot has can_delete_messages permission in a supergroup or a channel, it can
// delete any message there. Returns True on success.
func (bot *Bot) DeleteMessage(chatID int64, messageID int) (ok bool, err error) {
dst, err := json.Marshal(&DeleteMessageParameters{
ChatID: chatID,
MessageID: messageID,
})
if err != nil {
return
}
resp, err := bot.request(dst, MethodDeleteMessage)
if err != nil {
return
}
err = json.Unmarshal(*resp.Result, &ok)
return
}

35
vendor/gitlab.com/toby3d/telegram/pin_chat_message.go generated vendored Normal file
View File

@@ -0,0 +1,35 @@
package telegram
import json "github.com/pquerna/ffjson/ffjson"
// PinChatMessageParameters represents data for PinChatMessage method.
type PinChatMessageParameters struct {
// Unique identifier for the target chat
ChatID int64 `json:"chat_id"`
// Identifier of a message to pin
MessageID int `json:"message_id"`
// Pass true, if it is not necessary to send a notification to all chat
// members about the new pinned message. Notifications are always
// disabled in channels.
DisableNotification bool `json:"disable_notification"`
}
// PinChatMessage pin a message in a supergroup or a channel. The bot must be an administrator in the
// chat for this to work and must have the 'can_pin_messages' admin right in the supergroup or
// 'can_edit_messages' admin right in the channel. Returns True on success.
func (bot *Bot) PinChatMessage(params *PinChatMessageParameters) (ok bool, err error) {
dst, err := json.Marshal(params)
if err != nil {
return
}
resp, err := bot.request(dst, MethodPinChatMessage)
if err != nil {
return
}
err = json.Unmarshal(*resp.Result, &ok)
return
}

59
vendor/gitlab.com/toby3d/telegram/request.go generated vendored Normal file
View File

@@ -0,0 +1,59 @@
package telegram
import (
"errors"
"path"
"strconv"
"github.com/kirillDanshin/dlog"
json "github.com/pquerna/ffjson/ffjson"
http "github.com/valyala/fasthttp"
)
var defaultClient = new(http.Client)
func (bot *Bot) request(dst []byte, method string) (response *Response, err error) {
if bot.Client == nil {
bot.SetClient(defaultClient)
}
requestURI := http.AcquireURI()
requestURI.SetScheme("https")
requestURI.SetHost("api.telegram.org")
requestURI.SetPath(path.Join("bot"+bot.AccessToken, method))
req := http.AcquireRequest()
defer http.ReleaseRequest(req)
req.Header.SetContentType("application/json; charset=utf-8")
req.Header.SetMethod("POST")
if dst == nil {
req.Header.SetMethod("GET")
}
req.Header.SetRequestURI(requestURI.String())
req.Header.SetUserAgent(path.Join("telegram", strconv.FormatInt(Version, 10)))
req.Header.SetHostBytes(requestURI.Host())
req.SetBody(dst)
resp := http.AcquireResponse()
defer http.ReleaseResponse(resp)
err = bot.Client.Do(req, resp)
dlog.Ln("Request:")
dlog.D(req)
dlog.Ln("Response:")
dlog.D(resp)
if err != nil {
return
}
response = new(Response)
if err = json.Unmarshal(resp.Body(), response); err != nil {
return
}
if !response.Ok {
err = errors.New(response.Description)
}
return
}

89
vendor/gitlab.com/toby3d/telegram/send_animation.go generated vendored Normal file
View File

@@ -0,0 +1,89 @@
package telegram
import (
"strconv"
json "github.com/pquerna/ffjson/ffjson"
http "github.com/valyala/fasthttp"
)
// SendAnimationParameters represents data for SendAnimation method.
type SendAnimationParameters struct {
// Unique identifier for the target chat or username of the target channel (in the format @channelusername)
ChatID int64 `json:"chat_id"`
// Animation to send. Pass a file_id as String to send an animation that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an animation from the Internet, or upload a new animation using multipart/form-data. More info on Sending Files »
Animation InputFile `json:"animation"`
// Duration of sent animation in seconds
Duration int `json:"duration,omitempty"`
// Animation width
Width int `json:"width,omitempty"`
// Animation height
Height int `json:"height,omitempty"`
// Thumbnail of the file sent. The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnails width and height should not exceed 90. Ignored if the file is not uploaded using multipart/form-data. Thumbnails cant be reused and can be only uploaded as a new file, so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>. More info on Sending Files »
Thumb InputFile `json:"thumb,omitempty"`
// Animation caption (may also be used when resending animation by file_id), 0-200 characters
Caption string `json:"caption,omitempty"`
// Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in the media caption.
ParseMode string `json:"parse_mode,omitempty"`
// Sends the message silently. Users will receive a notification with no sound.
DisableNotification bool `json:"disable_notification,omitempty"`
// If the message is a reply, ID of the original message
ReplyToMessageID int `json:"reply_to_message_id,omitempty"`
// Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
ReplyMarkup interface{} `json:"reply_markup,omitempty"`
}
// NewAnimation creates SendAnimationParameters only with required parameters.
func NewAnimation(chatID int64, animation interface{}) *SendAnimationParameters {
return &SendAnimationParameters{
ChatID: chatID,
Animation: animation,
}
}
// SendAnimation send animation files (GIF or H.264/MPEG-4 AVC video without
// sound). On success, the sent Message is returned. Bots can currently send
// animation files of up to 50 MB in size, this limit may be changed in the
// future.
func (bot *Bot) SendAnimation(params *SendAnimationParameters) (msg *Message, err error) {
args := http.AcquireArgs()
defer http.ReleaseArgs(args)
args.Add("chat_id", strconv.FormatInt(params.ChatID, 10))
if params.Caption != "" {
args.Add("caption", params.Caption)
}
if params.ReplyMarkup != nil {
dst, err := json.Marshal(params.ReplyMarkup)
if err != nil {
return nil, err
}
args.Add("reply_markup", string(dst))
}
if params.ReplyToMessageID != 0 {
args.Add("reply_to_message_id", strconv.Itoa(params.ReplyToMessageID))
}
args.Add("disable_notification", strconv.FormatBool(params.DisableNotification))
resp, err := bot.Upload(MethodSendAnimation, "animation", "", params.Animation, args)
if err != nil {
return
}
msg = new(Message)
err = json.Unmarshal(*resp.Result, msg)
return
}

36
vendor/gitlab.com/toby3d/telegram/send_chat_action.go generated vendored Normal file
View File

@@ -0,0 +1,36 @@
package telegram
import json "github.com/pquerna/ffjson/ffjson"
// SendChatActionParameters represents data for SendChatAction method.
type SendChatActionParameters struct {
// Unique identifier for the target chat
ChatID int64 `json:"chat_id"`
// Type of action to broadcast
Action string `json:"action"`
}
// SendChatAction tell the user that something is happening on the bot's side.
// The status is set for 5 seconds or less (when a message arrives from your bot,
// Telegram clients clear its typing status). Returns True on success.
//
// We only recommend using this method when a response from the bot will take a
// noticeable amount of time to arrive.
func (bot *Bot) SendChatAction(chatID int64, action string) (ok bool, err error) {
dst, err := json.Marshal(&SendChatActionParameters{
ChatID: chatID,
Action: action,
})
if err != nil {
return
}
resp, err := bot.request(dst, MethodSendChatAction)
if err != nil {
return
}
err = json.Unmarshal(*resp.Result, &ok)
return
}

59
vendor/gitlab.com/toby3d/telegram/send_contact.go generated vendored Normal file
View File

@@ -0,0 +1,59 @@
package telegram
import json "github.com/pquerna/ffjson/ffjson"
// SendContactParameters represents data for SendContact method.
type SendContactParameters struct {
// Unique identifier for the target private chat
ChatID int64 `json:"chat_id"`
// Contact's phone number
PhoneNumber string `json:"phone_number"`
// Contact's first name
FirstName string `json:"first_name"`
// Contact's last name
LastName string `json:"last_name"`
// Additional data about the contact in the form of a vCard, 0-2048 bytes
VCard string `json:"vcard,omitempty"`
// Sends the message silently. Users will receive a notification with no
// sound.
DisableNotification bool `json:"disable_notification,omitempty"`
// If the message is a reply, ID of the original message
ReplyToMessageID int `json:"reply_to_message_id,omitempty"`
// A JSON-serialized object for an inline keyboard. If empty, one 'Pay total
// price' button will be shown. If not empty, the first button must be a Pay
// button.
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
}
// NewContact creates SendContactParameters only with required parameters.
func NewContact(chatID int64, phoneNumber, firstName string) *SendContactParameters {
return &SendContactParameters{
ChatID: chatID,
PhoneNumber: phoneNumber,
FirstName: firstName,
}
}
// SendContact send phone contacts. On success, the sent Message is returned.
func (bot *Bot) SendContact(params *SendContactParameters) (msg *Message, err error) {
dst, err := json.Marshal(*params)
if err != nil {
return
}
resp, err := bot.request(dst, MethodSendContact)
if err != nil {
return
}
msg = new(Message)
err = json.Unmarshal(*resp.Result, msg)
return
}

79
vendor/gitlab.com/toby3d/telegram/send_document.go generated vendored Normal file
View File

@@ -0,0 +1,79 @@
package telegram
import (
"strconv"
json "github.com/pquerna/ffjson/ffjson"
http "github.com/valyala/fasthttp"
)
// SendDocumentParameters represents data for SendDocument method.
type SendDocumentParameters struct {
// Unique identifier for the target chat
ChatID int64 `json:"chat_id"`
// File to send. Pass a file_id as String to send a file that exists on the Telegram servers
// (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or
// upload a new one using multipart/form-data.
Document InputFile `json:"document"`
// Document caption (may also be used when resending documents by file_id), 0-200 characters
Caption string `json:"caption,omitempty"`
// Send Markdown or HTML, if you want Telegram apps to show bold, italic,
// fixed-width text or inline URLs in the media caption.
ParseMode string `json:"parse_mode,omitempty"`
// Sends the message silently. Users will receive a notification with no sound.
DisableNotification bool `json:"disable_notification,omitempty"`
// If the message is a reply, ID of the original message
ReplyToMessageID int `json:"reply_to_message_id,omitempty"`
// Additional interface options. A JSON-serialized object for an inline keyboard, custom reply
// keyboard, instructions to remove reply keyboard or to force a reply from the user.
ReplyMarkup interface{} `json:"reply_markup,omitempty"`
}
// NewDocument creates SendDocumentParameters only with required parameters.
func NewDocument(chatID int64, document interface{}) *SendDocumentParameters {
return &SendDocumentParameters{
ChatID: chatID,
Document: document,
}
}
// SendDocument send general files. On success, the sent Message is returned. Bots can currently send
// files of any type of up to 50 MB in size, this limit may be changed in the future.
func (bot *Bot) SendDocument(params *SendDocumentParameters) (msg *Message, err error) {
args := http.AcquireArgs()
defer http.ReleaseArgs(args)
args.Add("chat_id", strconv.FormatInt(params.ChatID, 10))
if params.Caption != "" {
args.Add("caption", params.Caption)
}
if params.ReplyMarkup != nil {
dst, err := json.Marshal(params.ReplyMarkup)
if err != nil {
return nil, err
}
args.Add("reply_markup", string(dst))
}
if params.ReplyToMessageID != 0 {
args.Add("reply_to_message_id", strconv.Itoa(params.ReplyToMessageID))
}
args.Add("disable_notification", strconv.FormatBool(params.DisableNotification))
resp, err := bot.Upload(MethodSendDocument, "document", "", params.Document, args)
if err != nil {
return
}
msg = new(Message)
err = json.Unmarshal(*resp.Result, msg)
return
}

111
vendor/gitlab.com/toby3d/telegram/send_invoice.go generated vendored Normal file
View File

@@ -0,0 +1,111 @@
package telegram
import json "github.com/pquerna/ffjson/ffjson"
// SendInvoiceParameters represents data for SendInvoice method.
type SendInvoiceParameters struct {
// Unique identifier for the target private chat
ChatID int64 `json:"chat_id"`
// Product name, 1-32 characters
Title string `json:"title"`
// Product description, 1-255 characters
Description string `json:"description"`
// Bot-defined invoice payload, 1-128 bytes. This will not be displayed to
// the user, use for your internal processes.
Payload string `json:"payload"`
// Payments provider token, obtained via Botfather
ProviderToken string `json:"provider_token"`
// Unique deep-linking parameter that can be used to generate this invoice
// when used as a start parameter
StartParameter string `json:"start_parameter"`
// Three-letter ISO 4217 currency code, see more on currencies
Currency string `json:"currency"`
// JSON-encoded data about the invoice, which will be shared with the payment
// provider. A detailed description of required fields should be provided by
// the payment provider.
ProviderData string `json:"provider_data,omitempty"`
// URL of the product photo for the invoice. Can be a photo of the goods or a
// marketing image for a service. People like it better when they see what
// they are paying for.
PhotoURL string `json:"photo_url,omitempty"`
// Price breakdown, a list of components (e.g. product price, tax, discount,
// delivery cost, delivery tax, bonus, etc.)
Prices []LabeledPrice `json:"prices"`
// Photo size
PhotoSize int `json:"photo_size,omitempty"`
// Photo width
PhotoWidth int `json:"photo_width,omitempty"`
// Photo height
PhotoHeight int `json:"photo_height,omitempty"`
// If the message is a reply, ID of the original message
ReplyToMessageID int `json:"reply_to_message_id,omitempty"`
// Pass True, if you require the user's full name to complete the order
NeedName bool `json:"need_name,omitempty"`
// Pass True, if you require the user's phone number to complete the order
NeedPhoneNumber bool `json:"need_phone_number,omitempty"`
// Pass True, if you require the user's email to complete the order
NeedEmail bool `json:"need_email,omitempty"`
// Pass True, if you require the user's shipping address to complete the
// order
NeedShippingAddress bool `json:"need_shipping_address,omitempty"`
// Pass True, if the final price depends on the shipping method
IsFlexible bool `json:"is_flexible,omitempty"`
// Sends the message silently. Users will receive a notification with no
// sound.
DisableNotification bool `json:"disable_notification,omitempty"`
// A JSON-serialized object for an inline keyboard. If empty, one 'Pay total
// price' button will be shown. If not empty, the first button must be a Pay
// button.
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
}
// NewInvoice creates SendInvoiceParameters only with required parameters.
func NewInvoice(chatID int64, title, description, payload, providerToken, startParameter, currency string, prices ...LabeledPrice) *SendInvoiceParameters {
return &SendInvoiceParameters{
ChatID: chatID,
Title: title,
Description: description,
Payload: payload,
ProviderToken: providerToken,
StartParameter: startParameter,
Currency: currency,
Prices: prices,
}
}
// SendInvoice send invoices. On success, the sent Message is returned.
func (bot *Bot) SendInvoice(params *SendInvoiceParameters) (msg *Message, err error) {
dst, err := json.Marshal(params)
if err != nil {
return
}
resp, err := bot.request(dst, MethodSendInvoice)
if err != nil {
return
}
msg = new(Message)
err = json.Unmarshal(*resp.Result, msg)
return
}

57
vendor/gitlab.com/toby3d/telegram/send_location.go generated vendored Normal file
View File

@@ -0,0 +1,57 @@
package telegram
import json "github.com/pquerna/ffjson/ffjson"
// SendLocationParameters represents data for SendLocation method.
type SendLocationParameters struct {
// Unique identifier for the target private chat
ChatID int64 `json:"chat_id"`
// Latitude of the location
Latitude float32 `json:"latitude"`
// Longitude of the location
Longitude float32 `json:"longitude"`
// Period in seconds for which the location will be updated (see Live
// Locations), should be between 60 and 86400.
LivePeriod int `json:"live_period,omitempty"`
// If the message is a reply, ID of the original message
ReplyToMessageID int `json:"reply_to_message_id,omitempty"`
// Sends the message silently. Users will receive a notification with no
// sound.
DisableNotification bool `json:"disable_notification,omitempty"`
// A JSON-serialized object for an inline keyboard. If empty, one 'Pay total
// price' button will be shown. If not empty, the first button must be a Pay
// button.
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
}
// NewLocation creates SendLocationParameters only with required parameters.
func NewLocation(chatID int64, latitude, longitude float32) *SendLocationParameters {
return &SendLocationParameters{
ChatID: chatID,
Latitude: latitude,
Longitude: longitude,
}
}
// SendLocation send point on the map. On success, the sent Message is returned.
func (bot *Bot) SendLocation(params *SendLocationParameters) (msg *Message, err error) {
dst, err := json.Marshal(params)
if err != nil {
return
}
resp, err := bot.request(dst, MethodSendLocation)
if err != nil {
return
}
msg = new(Message)
err = json.Unmarshal(*resp.Result, msg)
return
}

45
vendor/gitlab.com/toby3d/telegram/send_media_group.go generated vendored Normal file
View File

@@ -0,0 +1,45 @@
package telegram
import json "github.com/pquerna/ffjson/ffjson"
// SendMediaGroupParameters represents data for SendMediaGroup method.
type SendMediaGroupParameters struct {
// Unique identifier for the target chat.
ChatID int64 `json:"chat_id"`
// A JSON-serialized array describing photos and videos to be sent, must
// include 210 items
Media []interface{} `json:"media"`
// Sends the messages silently. Users will receive a notification with no
// sound.
DisableNotification bool `json:"disable_notification,omitempty"`
// If the messages are a reply, ID of the original message
ReplyToMessageID int `json:"reply_to_message_id,omitempty"`
}
// NewMediaGroup creates SendMediaGroupParameters only with required parameters.
func NewMediaGroup(chatID int64, media ...interface{}) *SendMediaGroupParameters {
return &SendMediaGroupParameters{
ChatID: chatID,
Media: media,
}
}
// SendMediaGroup send a group of photos or videos as an album. On success, an array of the sent
// Messages is returned.
func (bot *Bot) SendMediaGroup(params *SendMediaGroupParameters) (album []Message, err error) {
dst, err := json.Marshal(params)
if err != nil {
return
}
resp, err := bot.request(dst, MethodSendMediaGroup)
if err != nil {
return
}
err = json.Unmarshal(*resp.Result, &album)
return
}

57
vendor/gitlab.com/toby3d/telegram/send_message.go generated vendored Normal file
View File

@@ -0,0 +1,57 @@
package telegram
import json "github.com/pquerna/ffjson/ffjson"
// SendMessageParameters represents data for SendMessage method.
type SendMessageParameters struct {
// Unique identifier for the target chat or username of the target channel
// (in the format @channelusername)
ChatID int64 `json:"chat_id"`
// Text of the message to be sent
Text string `json:"text"`
// Send Markdown or HTML, if you want Telegram apps to show bold, italic,
// fixed-width text or inline URLs in your bot's message.
ParseMode string `json:"parse_mode,omitempty"`
// Disables link previews for links in this message
DisableWebPagePreview bool `json:"disable_web_page_preview,omitempty"`
// Sends the message silently. Users will receive a notification with no
// sound.
DisableNotification bool `json:"disable_notification,omitempty"`
// If the message is a reply, ID of the original message
ReplyToMessageID int `json:"reply_to_message_id,omitempty"`
// Additional interface options. A JSON-serialized object for an inline
// keyboard, custom reply keyboard, instructions to remove reply keyboard or
// to force a reply from the user.
ReplyMarkup interface{} `json:"reply_markup,omitempty"`
}
// NewMessage creates SendMessageParameters only with required parameters.
func NewMessage(chatID int64, text string) *SendMessageParameters {
return &SendMessageParameters{
ChatID: chatID,
Text: text,
}
}
// SendMessage send text messages. On success, the sent Message is returned.
func (bot *Bot) SendMessage(params *SendMessageParameters) (msg *Message, err error) {
dst, err := json.Marshal(params)
if err != nil {
return
}
resp, err := bot.request(dst, MethodSendMessage)
if err != nil {
return
}
msg = new(Message)
err = json.Unmarshal(*resp.Result, msg)
return
}

85
vendor/gitlab.com/toby3d/telegram/send_photo.go generated vendored Normal file
View File

@@ -0,0 +1,85 @@
package telegram
import (
"strconv"
json "github.com/pquerna/ffjson/ffjson"
http "github.com/valyala/fasthttp"
)
// SendPhotoParameters represents data for SendPhoto method.
type SendPhotoParameters struct {
// Unique identifier for the target chat
ChatID int64 `json:"chat_id"`
// Photo to send. Pass a file_id as String to send a photo that exists on the
// Telegram servers (recommended), pass an HTTP URL as a String for Telegram
// to get a photo from the Internet, or upload a new photo using
// multipart/form-data.
Photo InputFile `json:"photo"`
// Photo caption (may also be used when resending photos by file_id), 0-200
// characters
Caption string `json:"caption,omitempty"`
// Send Markdown or HTML, if you want Telegram apps to show bold, italic,
// fixed-width text or inline URLs in the media caption.
ParseMode string `json:"parse_mode,omitempty"`
// Disables link previews for links in this message
DisableWebPagePreview bool `json:"disable_web_page_preview,omitempty"`
// Sends the message silently. Users will receive a notification with no
// sound.
DisableNotification bool `json:"disable_notification,omitempty"`
// If the message is a reply, ID of the original message
ReplyToMessageID int `json:"reply_to_message_id,omitempty"`
// Additional interface options. A JSON-serialized object for an inline
// keyboard, custom reply keyboard, instructions to remove reply keyboard or
// to force a reply from the user.
ReplyMarkup interface{} `json:"reply_markup,omitempty"`
}
// NewPhoto creates SendPhotoParameters only with required parameters.
func NewPhoto(chatID int64, photo interface{}) *SendPhotoParameters {
return &SendPhotoParameters{
ChatID: chatID,
Photo: photo,
}
}
// SendPhoto send photos. On success, the sent Message is returned.
func (bot *Bot) SendPhoto(params *SendPhotoParameters) (msg *Message, err error) {
args := http.AcquireArgs()
defer http.ReleaseArgs(args)
args.Add("chat_id", strconv.FormatInt(params.ChatID, 10))
if params.Caption != "" {
args.Add("caption", params.Caption)
}
if params.ReplyMarkup != nil {
dst, err := json.Marshal(params.ReplyMarkup)
if err != nil {
return nil, err
}
args.Add("reply_markup", string(dst))
}
if params.ReplyToMessageID != 0 {
args.Add("reply_to_message_id", strconv.Itoa(params.ReplyToMessageID))
}
args.Add("disable_notification", strconv.FormatBool(params.DisableNotification))
resp, err := bot.Upload(MethodSendPhoto, "photo", "", params.Photo, args)
if err != nil {
return
}
msg = new(Message)
err = json.Unmarshal(*resp.Result, msg)
return
}

69
vendor/gitlab.com/toby3d/telegram/send_venue.go generated vendored Normal file
View File

@@ -0,0 +1,69 @@
package telegram
import json "github.com/pquerna/ffjson/ffjson"
// SendVenueParameters represents data for SendVenue method.
type SendVenueParameters struct {
// Unique identifier for the target private chat
ChatID int64 `json:"chat_id"`
// Latitude of the venue
Latitude float32 `json:"latitude"`
// Longitude of the venue
Longitude float32 `json:"longitude"`
// Name of the venue
Title string `json:"title"`
// Address of the venue
Address string `json:"address"`
// Foursquare identifier of the venue
FoursquareID string `json:"foursquare_id,omitempty"`
// Foursquare type of the venue, if known. (For example,
// "arts_entertainment/default", "arts_entertainment/aquarium" or
// "food/icecream".)
FoursquareType string `json:"foursquare_type,omitempty"`
// Sends the message silently. Users will receive a notification with no
// sound.
DisableNotification bool `json:"disable_notification,omitempty"`
// If the message is a reply, ID of the original message
ReplyToMessageID int `json:"reply_to_message_id,omitempty"`
// A JSON-serialized object for an inline keyboard. If empty, one 'Pay total
// price' button will be shown. If not empty, the first button must be a Pay
// button.
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
}
// NewVenue creates SendVenueParameters only with required parameters.
func NewVenue(chatID int64, latitude, longitude float32, title, address string) *SendVenueParameters {
return &SendVenueParameters{
ChatID: chatID,
Latitude: latitude,
Longitude: longitude,
Title: title,
Address: address,
}
}
// SendVenue send information about a venue. On success, the sent Message is returned.
func (bot *Bot) SendVenue(params *SendVenueParameters) (msg *Message, err error) {
dst, err := json.Marshal(params)
if err != nil {
return
}
resp, err := bot.request(dst, MethodSendVenue)
if err != nil {
return
}
msg = new(Message)
err = json.Unmarshal(*resp.Result, msg)
return
}

View File

@@ -0,0 +1,33 @@
package telegram
import json "github.com/pquerna/ffjson/ffjson"
// SetChatDescriptionParameters represents data for SetChatDescription method.
type SetChatDescriptionParameters struct {
// Unique identifier for the target chat
ChatID int64 `json:"chat_id"`
// New chat description, 0-255 characters
Description string `json:"description"`
}
// SetChatDescription change the description of a supergroup or a channel. The
// bot must be an administrator in the chat for this to work and must have the
// appropriate admin rights. Returns True on success.
func (bot *Bot) SetChatDescription(chatID int64, description string) (ok bool, err error) {
dst, err := json.Marshal(&SetChatDescriptionParameters{
ChatID: chatID,
Description: description,
})
if err != nil {
return
}
resp, err := bot.request(dst, MethodSetChatDescription)
if err != nil {
return
}
err = json.Unmarshal(*resp.Result, &ok)
return
}

37
vendor/gitlab.com/toby3d/telegram/set_chat_photo.go generated vendored Normal file
View File

@@ -0,0 +1,37 @@
package telegram
import (
"strconv"
json "github.com/pquerna/ffjson/ffjson"
http "github.com/valyala/fasthttp"
)
// SetChatPhotoParameters represents data for SetChatPhoto method.
type SetChatPhotoParameters struct {
// Unique identifier for the target chat
ChatID int64 `json:"chat_id"`
// New chat photo, uploaded using multipart/form-data
ChatPhoto interface{} `json:"chat_photo"`
}
// SetChatPhoto set a new profile photo for the chat. Photos can't be changed for private chats. The
// bot must be an administrator in the chat for this to work and must have the appropriate admin
// rights. Returns True on success.
//
// Note: In regular groups (non-supergroups), this method will only work if the 'All Members Are
// Admins' setting is off in the target group.
func (bot *Bot) SetChatPhoto(chatID int64, chatPhoto interface{}) (ok bool, err error) {
args := http.AcquireArgs()
defer http.ReleaseArgs(args)
args.Add("chat_id", strconv.FormatInt(chatID, 10))
resp, err := bot.Upload(MethodSetChatPhoto, TypePhoto, "chat_photo", chatPhoto, args)
if err != nil {
return
}
err = json.Unmarshal(*resp.Result, &ok)
return
}

View File

@@ -0,0 +1,34 @@
package telegram
import json "github.com/pquerna/ffjson/ffjson"
// SetChatStickerSetParameters represents data for SetChatStickerSet method.
type SetChatStickerSetParameters struct {
// Unique identifier for the target chat
ChatID int64 `json:"chat_id"`
// Name of the sticker set to be set as the group sticker set
StickerSetName string `json:"sticker_set_name"`
}
// SetChatStickerSet set a new group sticker set for a supergroup. The bot must be an administrator
// in the chat for this to work and must have the appropriate admin rights. Use the field
// can_set_sticker_set optionally returned in getChat requests to check if the bot can use this
// method. Returns True on success.
func (bot *Bot) SetChatStickerSet(chatID int64, stickerSetName string) (ok bool, err error) {
dst, err := json.Marshal(&SetChatStickerSetParameters{
ChatID: chatID,
StickerSetName: stickerSetName,
})
if err != nil {
return
}
resp, err := bot.request(dst, MethodSetChatStickerSet)
if err != nil {
return
}
err = json.Unmarshal(*resp.Result, &ok)
return
}

36
vendor/gitlab.com/toby3d/telegram/set_chat_title.go generated vendored Normal file
View File

@@ -0,0 +1,36 @@
package telegram
import json "github.com/pquerna/ffjson/ffjson"
// SetChatTitleParameters represents data for SetChatTitle method.
type SetChatTitleParameters struct {
// Unique identifier for the target chat
ChatID int64 `json:"chat_id"`
// New chat title, 1-255 characters
Title string `json:"title"`
}
// SetChatTitle change the title of a chat. Titles can't be changed for private
// chats. The bot must be an administrator in the chat for this to work and must
// have the appropriate admin rights. Returns True on success.
//
// Note: In regular groups (non-supergroups), this method will only work if the
// 'All Members Are Admins' setting is off in the target group.
func (bot *Bot) SetChatTitle(chatID int64, title string) (ok bool, err error) {
dst, err := json.Marshal(&SetChatTitleParameters{
ChatID: chatID,
Title: title,
})
if err != nil {
return
}
resp, err := bot.request(dst, MethodSetChatTitle)
if err != nil {
return
}
err = json.Unmarshal(*resp.Result, &ok)
return
}

View File

@@ -0,0 +1,39 @@
package telegram
import json "github.com/pquerna/ffjson/ffjson"
type SetPassportDataErrorsParameters struct {
// User identifier
UserID int `json:"user_id"`
// A JSON-serialized array describing the errors
Errors []PassportElementError `json:"errors"`
}
// SetPassportDataErrors informs a user that some of the Telegram Passport
// elements they provided contains errors. The user will not be able to re-submit
// their Passport to you until the errors are fixed (the contents of the field
// for which you returned the error must change). Returns True on success.
//
// Use this if the data submitted by the user doesn't satisfy the standards your
// service requires for any reason. For example, if a birthday date seems
// invalid, a submitted document is blurry, a scan shows evidence of tampering,
// etc. Supply some details in the error message to make sure the user knows how
// to correct the issues.
func (b *Bot) SetPassportDataErrors(userId int, errors []PassportElementError) (ok bool, err error) {
dst, err := json.Marshal(&SetPassportDataErrorsParameters{
UserID: userId,
Errors: errors,
})
if err != nil {
return
}
resp, err := b.request(dst, MethodSetPassportDataErrors)
if err != nil {
return
}
err = json.Unmarshal(*resp.Result, &ok)
return
}

88
vendor/gitlab.com/toby3d/telegram/set_webhook.go generated vendored Normal file
View File

@@ -0,0 +1,88 @@
package telegram
import (
"strconv"
"strings"
json "github.com/pquerna/ffjson/ffjson"
http "github.com/valyala/fasthttp"
)
// SetWebhookParameters represents data for SetWebhook method.
type SetWebhookParameters struct {
// HTTPS url to send updates to. Use an empty string to remove webhook
// integration
URL string `json:"url"`
// Upload your public key certificate so that the root certificate in use can
// be checked. See our self-signed guide for details.
Certificate InputFile `json:"certificate,omitempty"`
// Maximum allowed number of simultaneous HTTPS connections to the webhook
// for update delivery, 1-100. Defaults to 40. Use lower values to limit the
// load on your bots server, and higher values to increase your bots
// throughput.
MaxConnections int `json:"max_connections,omitempty"`
// List the types of updates you want your bot to receive. For example,
// specify [“message”, “edited_channel_post”, “callback_query”] to only
// receive updates of these types. See Update for a complete list of
// available update types. Specify an empty list to receive all updates
// regardless of type (default). If not specified, the previous setting will
// be used.
//
// Please note that this parameter doesn't affect updates created before the
// call to the setWebhook, so unwanted updates may be received for a short
// period of time.
AllowedUpdates []string `json:"allowed_updates,omitempty"`
}
// NewWebhook creates new SetWebhookParameters only with required parameters.
func NewWebhook(url string, file interface{}) *SetWebhookParameters {
return &SetWebhookParameters{
URL: url,
Certificate: file,
}
}
// SetWebhook specify a url and receive incoming updates via an outgoing webhook.
// Whenever there is an update for the bot, we will send an HTTPS POST request to
// the specified url, containing a JSON-serialized Update. In case of an
// unsuccessful request, we will give up after a reasonable amount of attempts.
// Returns true.
//
// If you'd like to make sure that the Webhook request comes from Telegram, we
// recommend using a secret path in the URL, e.g. https://www.example.com/<token>.
// Since nobody else knows your bots token, you can be pretty sure its us.
func (bot *Bot) SetWebhook(params *SetWebhookParameters) (ok bool, err error) {
args := http.AcquireArgs()
defer http.ReleaseArgs(args)
args.Add("url", params.URL)
if len(params.AllowedUpdates) > 0 {
args.Add("allowed_updates", strings.Join(params.AllowedUpdates, ","))
}
if params.MaxConnections > 0 &&
params.MaxConnections <= 100 {
args.Add("max_connections", strconv.Itoa(params.MaxConnections))
}
var resp *Response
if params.Certificate != nil {
resp, err = bot.Upload(MethodSetWebhook, "certificate", "cert.pem", params.Certificate, args)
} else {
var dst []byte
dst, err = json.Marshal(params)
if err != nil {
return
}
resp, err = bot.request(dst, MethodSetWebhook)
}
if err != nil {
return
}
err = json.Unmarshal(*resp.Result, &ok)
return
}

994
vendor/gitlab.com/toby3d/telegram/types.go generated vendored Normal file
View File

@@ -0,0 +1,994 @@
package telegram
import "encoding/json"
type (
// Response represents a response from the Telegram API with the result
// stored raw. If ok equals true, the request was successful, and the result
// of the query can be found in the result field. In case of an unsuccessful
// request, ok equals false, and the error is explained in the error field.
Response struct {
Ok bool `json:"ok"`
ErrorCode int `json:"error_code,omitempty"`
Description string `json:"description,omitempty"`
Result *json.RawMessage `json:"result,omitempty"`
Parameters *ResponseParameters `json:"parameters,omitempty"`
}
// Update represents an incoming update.
//
// At most one of the optional parameters can be present in any given update.
Update struct {
// The updates unique identifier. Update identifiers start from a
// certain positive number and increase sequentially. This ID becomes
// especially handy if youre using Webhooks, since it allows you to
// ignore repeated updates or to restore the correct update sequence,
// should they get out of order.
ID int `json:"update_id"`
// New incoming message of any kind — text, photo, sticker, etc.
Message *Message `json:"message,omitempty"`
// New version of a message that is known to the bot and was edited
EditedMessage *Message `json:"edited_message,omitempty"`
// New incoming channel post of any kind — text, photo, sticker, etc.
ChannelPost *Message `json:"channel_post,omitempty"`
// New version of a channel post that is known to the bot and was edited
EditedChannelPost *Message `json:"adited_channel_post,omitempty"`
// New incoming inline query
InlineQuery *InlineQuery `json:"inline_query,omitempty"`
// The result of an inline query that was chosen by a user and sent to
// their chat partner.
ChosenInlineResult *ChosenInlineResult `json:"chosen_inline_result,omitempty"`
// New incoming callback query
CallbackQuery *CallbackQuery `json:"callback_query,omitempty"`
// New incoming shipping query. Only for invoices with flexible price
ShippingQuery *ShippingQuery `json:"shipping_query,omitempty"`
// New incoming pre-checkout query. Contains full information about
// checkout
PreCheckoutQuery *PreCheckoutQuery `json:"pre_checkout_query,omitempty"`
}
// WebhookInfo contains information about the current status of a webhook.
WebhookInfo struct {
// Webhook URL, may be empty if webhook is not set up
URL string `json:"url"`
// Error message in human-readable format for the most recent error that
// happened when trying to deliver an update via webhook
LastErrorMessage string `json:"last_error_message,omitempty"`
// True, if a custom certificate was provided for webhook certificate
// checks
HasCustomCertificate bool `json:"has_custom_certificate"`
// Number of updates awaiting delivery
PendingUpdateCount int `json:"pending_update_count"`
// Maximum allowed number of simultaneous HTTPS connections to the
// webhook for update delivery
MaxConnections int `json:"max_connections,omitempty"`
// Unix time for the most recent error that happened when trying to
// deliver an update via webhook
LastErrorDate int64 `json:"last_error_date,omitempty"`
// A list of update types the bot is subscribed to. Defaults to all
// update types
AllowedUpdates []string `json:"allowed_updates,omitempty"`
}
// User represents a Telegram user or bot.
User struct {
// Unique identifier for this user or bot
ID int `json:"id"`
// True, if this user is a bot
IsBot bool `json:"is_bot"`
// Users or bots first name
FirstName string `json:"first_name"`
// Users or bots last name
LastName string `json:"last_name,omitempty"`
// Users or bots username
Username string `json:"username,omitempty"`
// IETF language tag of the user's language
LanguageCode string `json:"language_code,omitempty"`
}
// Chat represents a chat.
Chat struct {
// Unique identifier for this chat.
ID int64 `json:"id"`
// Type of chat, can be either "private", "group", "supergroup" or
// "channel"
Type string `json:"type"`
// Title, for supergroups, channels and group chats
Title string `json:"title,omitempty"`
// Username, for private chats, supergroups and channels if available
Username string `json:"username,omitempty"`
// First name of the other party in a private chat
FirstName string `json:"first_name,omitempty"`
// Last name of the other party in a private chat
LastName string `json:"last_name,omitempty"`
// Description, for supergroups and channel chats. Returned only in
// getChat.
Description string `json:"description,omitempty"`
// Chat invite link, for supergroups and channel chats. Returned only in
// getChat.
InviteLink string `json:"invite_link,omitempty"`
// For supergroups, name of Group sticker set. Returned only in getChat.
StickerSetName string `json:"sticker_set_name,omitempty"`
// True if a group has All Members Are Admins enabled.
AllMembersAreAdministrators bool `json:"all_members_are_administrators,omitempty"`
// True, if the bot can change group the sticker set. Returned only in
// getChat.
CanSetStickerSet bool `json:"can_set_sticker_set,omitempty"`
// Chat photo. Returned only in getChat.
Photo *ChatPhoto `json:"photo,omitempty"`
// Pinned message, for supergroups. Returned only in getChat.
PinnedMessage *Message `json:"pinned_message,omitempty"`
}
// Message represents a message.
Message struct {
// Unique message identifier inside this chat
ID int `json:"message_id"`
// For messages forwarded from channels, identifier of the original
// message in the channel
ForwardFromMessageID int `json:"forward_from_message_id,omitempty"`
// Sender, empty for messages sent to channels
From *User `json:"from,omitempty"`
// For forwarded messages, sender of the original message
ForwardFrom *User `json:"forward_from,omitempty"`
// A member was removed from the group, information about them (this
// member may be the bot itself)
LeftChatMember *User `json:"left_chat_member,omitempty"`
// Date the message was sent in Unix time
Date int64 `json:"date"`
// For forwarded messages, date the original message was sent in Unix
// time
ForwardDate int64 `json:"forward_date,omitempty"`
// Date the message was last edited in Unix time
EditDate int64 `json:"edit_date,omitempty"`
// The group has been migrated to a supergroup with the specified
// identifier.
MigrateToChatID int64 `json:"migrate_to_chat_id,omitempty"`
// The supergroup has been migrated from a group with the specified
// identifier.
MigrateFromChatID int64 `json:"migrate_from_chat_id,omitempty"`
// Conversation the message belongs to
Chat *Chat `json:"chat"`
// For messages forwarded from channels, information about the original
// channel
ForwardFromChat *Chat `json:"forward_from_chat,omitempty"`
// For messages forwarded from channels, signature of the post author if
// present
ForwardSignature string `json:"forward_signature,omitempty"`
// The unique identifier of a media message group this message belongs to
MediaGroupID string `json:"media_group_id,omitempty"`
// Signature of the post author for messages in channels
AuthorSignature string `json:"author_signature,omitempty"`
// For text messages, the actual UTF-8 text of the message, 0-4096
// characters.
Text string `json:"text,omitempty"`
// Caption for the document, photo or video, 0-200 characters
Caption string `json:"caption,omitempty"`
// A chat title was changed to this value
NewChatTitle string `json:"new_chat_title,omitempty"`
// The domain name of the website on which the user has logged in.
ConnectedWebsite string `json:"connected_website,omitempty"`
// For replies, the original message. Note that the Message object in
// this field will not contain further reply_to_message fields even if it
// itself is a reply.
ReplyToMessage *Message `json:"reply_to_message,omitempty"`
// Specified message was pinned. Note that the Message object in this
// field will not contain further reply_to_message fields even if it is
// itself a reply.
PinnedMessage *Message `json:"pinned_message,omitempty"`
// For text messages, special entities like usernames, URLs, bot
// commands, etc. that appear in the text
Entities []MessageEntity `json:"entities,omitempty"`
// For messages with a caption, special entities like usernames, URLs,
// bot commands, etc. that appear in the caption
CaptionEntities []MessageEntity `json:"caption_entities,omitempty"`
// Message is an audio file, information about the file
Audio *Audio `json:"audio,omitempty"`
// Message is a general file, information about the file
Document *Document `json:"document,omitempty"`
// Message is an animation, information about the animation. For backward
// compatibility, when this field is set, the document field will also be
// set
Animation *Animation `json:"animation,omitempty"`
// Message is a game, information about the game.
Game *Game `json:"game,omitempty"`
// Message is a photo, available sizes of the photo
Photo []PhotoSize `json:"photo,omitempty"`
// A chat photo was change to this value
NewChatPhoto []PhotoSize `json:"new_chat_photo,omitempty"`
// Message is a sticker, information about the sticker
Sticker *Sticker `json:"sticker,omitempty"`
// Message is a video, information about the video
Video *Video `json:"video,omitempty"`
// Message is a voice message, information about the file
Voice *Voice `json:"voice,omitempty"`
// Message is a video note, information about the video message
VideoNote *VideoNote `json:"video_note,omitempty"`
// Message is a shared contact, information about the contact
Contact *Contact `json:"contact,omitempty"`
// Message is a shared location, information about the location
Location *Location `json:"location,omitempty"`
// Message is a venue, information about the venue
Venue *Venue `json:"venue,omitempty"`
// New members that were added to the group or supergroup and information
// about them (the bot itself may be one of these members)
NewChatMembers []User `json:"new_chat_members,omitempty"`
// Service message: the chat photo was deleted
DeleteChatPhoto bool `json:"delete_chat_photo,omitempty"`
// Service message: the group has been created
GroupChatCreated bool `json:"group_chat_created,omitempty"`
// Service message: the supergroup has been created. This field cant be
// received in a message coming through updates, because bot cant be a
// member of a supergroup when it is created. It can only be found in
// reply_to_message if someone replies to a very first message in a
// directly created supergroup.
SupergroupChatCreated bool `json:"supergroup_chat_created,omitempty"`
// Service message: the channel has been created. This field cant be
// received in a message coming through updates, because bot cant be a
// member of a channel when it is created. It can only be found in
// reply_to_message if someone replies to a very first message in a
// channel.
ChannelChatCreated bool `json:"channel_chat_created,omitempty"`
// Message is an invoice for a payment, information about the invoice.
Invoice *Invoice `json:"invoice,omitempty"`
// Message is a service message about a successful payment, information
// about the payment.
SuccessfulPayment *SuccessfulPayment `json:"successful_payment,omitempty"`
// Telegram Passport data
PassportData *PassportData `json:"passport_data,omitempty"`
}
// MessageEntity represents one special entity in a text message. For
// example, hashtags, usernames, URLs, etc.
MessageEntity struct {
// Type of the entity. Can be mention (@username), hashtag, bot_command,
// url, email, bold (bold text), italic (italic text), code (monowidth
// string), pre (monowidth block), text_link (for clickable text URLs),
// text_mention (for users without usernames)
Type string `json:"type"`
// For "text_link" only, url that will be opened after user taps on the
// text
URL string `json:"url,omitempty"`
// Offset in UTF-16 code units to the start of the entity
Offset int `json:"offset"`
// Length of the entity in UTF-16 code units
Length int `json:"length"`
// For "text_mention" only, the mentioned user
User *User `json:"user,omitempty"`
}
// PhotoSize represents one size of a photo or a file / sticker thumbnail.
PhotoSize struct {
// Unique identifier for this file
FileID string `json:"file_id"`
// Photo width
Width int `json:"width"`
// Photo height
Height int `json:"height"`
// File size
FileSize int `json:"file_size,omitempty"`
}
// Audio represents an audio file to be treated as music by the Telegram
// clients.
Audio struct {
// Unique identifier for this file
FileID string `json:"file_id"`
// Performer of the audio as defined by sender or by audio tags
Performer string `json:"performer,omitempty"`
// Title of the audio as defined by sender or by audio tags
Title string `json:"title,omitempty"`
// MIME type of the file as defined by sender
MimeType string `json:"mime_type,omitempty"`
// Duration of the audio in seconds as defined by sender
Duration int `json:"duration"`
// File size
FileSize int `json:"file_size,omitempty"`
// Thumbnail of the album cover to which the music file belongs
Thumb *PhotoSize `json:"thumb,omitempty"`
}
// Document represents a general file (as opposed to photos, voice messages
// and audio files).
Document struct {
// Unique file identifier
FileID string `json:"file_id"`
// Original filename as defined by sender
FileName string `json:"file_name,omitempty"`
// MIME type of the file as defined by sender
MimeType string `json:"mime_type,omitempty"`
// Document thumbnail as defined by sender
Thumb *PhotoSize `json:"thumb,omitempty"`
// File size
FileSize int `json:"file_size,omitempty"`
}
// Video represents a video file.
Video struct {
// Unique identifier for this file
FileID string `json:"file_id"`
// Mime type of a file as defined by sender
MimeType string `json:"mime_type,omitempty"`
// Video width as defined by sender
Width int `json:"width"`
// Video height as defined by sender
Height int `json:"height"`
// Duration of the video in seconds as defined by sender
Duration int `json:"duration"`
// File size
FileSize int `json:"file_size,omitempty"`
// Video thumbnail
Thumb *PhotoSize `json:"thumb,omitempty"`
}
// Voice represents a voice note.
Voice struct {
// Unique identifier for this file
FileID string `json:"file_id"`
// MIME type of the file as defined by sender
MimeType string `json:"mime_type,omitempty"`
// Duration of the audio in seconds as defined by sender
Duration int `json:"duration"`
// File size
FileSize int `json:"file_size,omitempty"`
}
// VideoNote represents a video message (available in Telegram apps as of
// v.4.0).
VideoNote struct {
// Unique identifier for this file
FileID string `json:"file_id"`
// Video width and height (diameter of the video message) as defined by sender
Length int `json:"length"`
// Duration of the video in seconds as defined by sender
Duration int `json:"duration"`
// File size
FileSize int `json:"file_size,omitempty"`
// Video thumbnail
Thumb *PhotoSize `json:"thumb,omitempty"`
}
// Contact represents a phone contact.
Contact struct {
// Contact's phone number
PhoneNumber string `json:"phone_number"`
// Contact's first name
FirstName string `json:"first_name"`
// Contact's last name
LastName string `json:"last_name,omitempty"`
// Contact's user identifier in Telegram
UserID int `json:"user_id,omitempty"`
// Additional data about the contact in the form of a vCard
VCard string `json:"vcard,omitempty"`
}
// Location represents a point on the map.
Location struct {
// Longitude as defined by sender
Longitude float32 `json:"longitude"`
// Latitude as defined by sender
Latitude float32 `json:"latitude"`
}
// Venue represents a venue.
Venue struct {
// Venue location
Location *Location `json:"location"`
// Name of the venue
Title string `json:"title"`
// Address of the venue
Address string `json:"address"`
// Foursquare identifier of the venue
FoursquareID string `json:"foursquare_id,omitempty"`
// Foursquare type of the venue. (For example,
// "arts_entertainment/default", "arts_entertainment/aquarium" or
// "food/icecream".)
FoursquareType string `json:"foursquare_type,omitempty"`
}
// UserProfilePhotos represent a user's profile pictures.
UserProfilePhotos struct {
// Total number of profile pictures the target user has
TotalCount int `json:"total_count"`
// Requested profile pictures (in up to 4 sizes each)
Photos [][]PhotoSize `json:"photos"`
}
// File represents a file ready to be downloaded. The file can be downloaded
// via the link https://api.telegram.org/file/bot<token>/<file_path>. It is
// guaranteed that the link will be valid for at least 1 hour. When the link
// expires, a new one can be requested by calling getFile.
//
// Maximum file size to download is 20 MB
File struct {
// Unique identifier for this file
FileID string `json:"file_id"`
// File path. Use https://api.telegram.org/file/bot<token>/<file_path> to
// get the file.
FilePath string `json:"file_path,omitempty"`
// File size, if known
FileSize int `json:"file_size,omitempty"`
}
// ReplyKeyboardMarkup represents a custom keyboard with reply options (see
// Introduction to bots for details and examples).
ReplyKeyboardMarkup struct {
// Array of button rows, each represented by an Array of KeyboardButton
// objects
Keyboard [][]KeyboardButton `json:"keyboard"`
// Requests clients to resize the keyboard vertically for optimal fit
// (e.g., make the keyboard smaller if there are just two rows of
// buttons). Defaults to false, in which case the custom keyboard is
// always of the same height as the app's standard keyboard.
ResizeKeyboard bool `json:"resize_keyboard,omitempty"`
// Requests clients to hide the keyboard as soon as it's been used. The
// keyboard will still be available, but clients will automatically
// display the usual letter-keyboard in the chat the user can press a
// special button in the input field to see the custom keyboard again.
// Defaults to false.
OneTimeKeyboard bool `json:"one_time_keyboard,omitempty"`
// Use this parameter if you want to show the keyboard to specific users
// only. Targets: 1) users that are @mentioned in the text of the Message
// object; 2) if the bot's message is a reply (has reply_to_message_id),
// sender of the original message.
//
// Example: A user requests to change the bots language, bot replies to
// the request with a keyboard to select the new language. Other users in
// the group dont see the keyboard.
Selective bool `json:"selective,omitempty"`
}
// KeyboardButton represents one button of the reply keyboard. For simple
// text buttons String can be used instead of this object to specify text of
// the button. Optional fields are mutually exclusive.
KeyboardButton struct {
// Text of the button. If none of the optional fields are used, it will
// be sent to the bot as a message when the button is pressed
Text string `json:"text"`
// If True, the user's phone number will be sent as a contact when the
// button is pressed. Available in private chats only
RequestContact bool `json:"request_contact,omitempty"`
// If True, the user's current location will be sent when the button is
// pressed. Available in private chats only
RequestLocation bool `json:"request_location,omitempty"`
}
// ReplyKeyboardRemove will remove the current custom keyboard and display
// the default letter-keyboard. By default, custom keyboards are displayed
// until a new keyboard is sent by a bot. An exception is made for one-time
// keyboards that are hidden immediately after the user presses a button
// (see ReplyKeyboardMarkup).
ReplyKeyboardRemove struct {
// Requests clients to remove the custom keyboard (user will not be able
// to summon this keyboard; if you want to hide the keyboard from sight
// but keep it accessible, use one_time_keyboard in ReplyKeyboardMarkup)
RemoveKeyboard bool `json:"remove_keyboard"`
// Use this parameter if you want to remove the keyboard for specific
// users only. Targets: 1) users that are @mentioned in the text of the
// Message object; 2) if the bot's message is a reply (has
// reply_to_message_id), sender of the original message.
//
// Example: A user votes in a poll, bot returns confirmation message in
// reply to the vote and removes the keyboard for that user, while still
// showing the keyboard with poll options to users who haven't voted yet.
Selective bool `json:"selective,omitempty"`
}
// InlineKeyboardMarkup represents an inline keyboard that appears right next
// to the message it belongs to.
InlineKeyboardMarkup struct {
// Array of button rows, each represented by an Array of
// InlineKeyboardButton objects
InlineKeyboard [][]InlineKeyboardButton `json:"inline_keyboard"`
}
// InlineKeyboardButton represents one button of an inline keyboard. You
// must use exactly one of the optional fields.
InlineKeyboardButton struct {
// Label text on the button
Text string `json:"text"`
// HTTP url to be opened when button is pressed
URL string `json:"url,omitempty"`
// Data to be sent in a callback query to the bot when button is pressed,
// 1-64 bytes
CallbackData string `json:"callback_data,omitempty"`
// If set, pressing the button will prompt the user to select one of
// their chats, open that chat and insert the bots username and the
// specified inline query in the input field. Can be empty, in which
// case just the bots username will be inserted.
//
// Note: This offers an easy way for users to start using your bot in
// inline mode when they are currently in a private chat with it.
// Especially useful when combined with switch_pm… actions in this case
// the user will be automatically returned to the chat they switched
// from, skipping the chat selection screen.
SwitchInlineQuery string `json:"switch_inline_query,omitempty"`
// If set, pressing the button will insert the bots username and the
// specified inline query in the current chat's input field. Can be
// empty, in which case only the bots username will be inserted.
//
// This offers a quick way for the user to open your bot in inline mode
// in the same chat good for selecting something from multiple options.
SwitchInlineQueryCurrentChat string `json:"switch_inline_query_current_chat,omitempty"`
// Description of the game that will be launched when the user presses
// the button.
//
// NOTE: This type of button must always be the first button in the
// first row.
CallbackGame *CallbackGame `json:"callback_game,omitempty"`
// Specify True, to send a Pay button.
//
// NOTE: This type of button must always be the first button in the
// first row.
Pay bool `json:"pay,omitempty"`
}
// CallbackQuery represents an incoming callback query from a callback button
// in an inline keyboard. If the button that originated the query was
// attached to a message sent by the bot, the field message will be present.
// If the button was attached to a message sent via the bot (in inline mode),
// the field inline_message_id will be present. Exactly one of the fields
// data or game_short_name will be present.
//
// NOTE: After the user presses a callback button, Telegram clients will
// display a progress bar until you call answerCallbackQuery. It is,
// therefore, necessary to react by calling answerCallbackQuery even if no
// notification to the user is needed (e.g., without specifying any of the
// optional parameters).
CallbackQuery struct {
// Unique identifier for this query
ID string `json:"id"`
// Identifier of the message sent via the bot in inline mode, that
// originated the query.
InlineMessageID string `json:"inline_message_id,omitempty"`
// Global identifier, uniquely corresponding to the chat to which the
// message with the callback button was sent. Useful for high scores in
// games.
ChatInstance string `json:"chat_instance"`
// Data associated with the callback button. Be aware that a bad client
// can send arbitrary data in this field.
Data string `json:"data,omitempty"`
// Short name of a Game to be returned, serves as the unique identifier
// for the game
GameShortName string `json:"game_short_name,omitempty"`
// Sender
From *User `json:"from"`
// Message with the callback button that originated the query. Note that
// message content and message date will not be available if the message
// is too old
Message *Message `json:"message,omitempty"`
}
// ForceReply display a reply interface to the user (act as if the user has
// selected the bots message and tapped Reply'). This can be extremely
// useful if you want to create user-friendly step-by-step interfaces without
// having to sacrifice privacy mode.
ForceReply struct {
// Shows reply interface to the user, as if they manually selected the
// bots message and tapped Reply'
ForceReply bool `json:"force_reply"`
// Use this parameter if you want to force reply from specific users
// only. Targets: 1) users that are @mentioned in the text of the Message
// object; 2) if the bot's message is a reply (has reply_to_message_id),
// sender of the original message.
Selective bool `json:"selective,omitempty"`
}
// ChatPhoto represents a chat photo.
ChatPhoto struct {
// Unique file identifier of small (160x160) chat photo. This file_id can
// be used only for photo download.
SmallFileID string `json:"small_file_id"`
// Unique file identifier of big (640x640) chat photo. This file_id can
// be used only for photo download.
BigFileID string `json:"big_file_id"`
}
// ChatMember contains information about one member of a chat.
ChatMember struct {
// Information about the user
User *User `json:"user"`
// The member's status in the chat. Can be "creator", "administrator",
// "member", "restricted", "left" or "kicked"
Status string `json:"status"`
// Restictred and kicked only. Date when restrictions will be lifted for
// this user, unix time
UntilDate int64 `json:"until_date,omitempty"`
// Administrators only. True, if the bot is allowed to edit administrator
// privileges of that user
CanBeEdited bool `json:"can_be_edited,omitempty"`
// Administrators only. True, if the administrator can change the chat
// title, photo and other settings
CanChangeInfo bool `json:"can_change_info,omitempty"`
// Administrators only. True, if the administrator can post in the
// channel, channels only
CanPostMessages bool `json:"can_post_messages,omitempty"`
// Administrators only. True, if the administrator can edit messages of
// other users, channels only
CanEditMessages bool `json:"can_edit_messages,omitempty"`
// Administrators only. True, if the administrator can delete messages of
// other users
CanDeleteMessages bool `json:"can_delete_messages,omitempty"`
// Administrators only. True, if the administrator can invite new users
// to the chat
CanInviteUsers bool `json:"can_invite_users,omitempty"`
// Administrators only. True, if the administrator can restrict, ban or
// unban chat members
CanRestrictMembers bool `json:"can_restrict_members,omitempty"`
// Administrators only. True, if the administrator can pin messages,
// supergroups only
CanPinMessages bool `json:"can_pin_messages,omitempty"`
// Administrators only. True, if the administrator can add new
// administrators with a subset of his own privileges or demote
// administrators that he has promoted, directly or indirectly (promoted
// by administrators that were appointed by the user)
CanPromoteMembers bool `json:"can_promote_members,omitempty"`
// Restricted only. True, if the user can send text messages, contacts,
// locations and venues
CanSendMessages bool `json:"can_send_messages,omitempty"`
// Restricted only. True, if the user can send audios, documents, photos,
// videos, video notes and voice notes, implies can_send_messages
CanSendMediaMessages bool `json:"can_send_media_messages,omitempty"`
// Restricted only. True, if the user can send animations, games,
// stickers and use inline bots, implies can_send_media_messages
CanSendOtherMessages bool `json:"can_send_other_messages,omitempty"`
// Restricted only. True, if user may add web page previews to his
// messages, implies can_send_media_messages
CanAddWebPagePreviews bool `json:"can_add_web_page_previews,omitempty"`
}
// ResponseParameters contains information about why a request was
// unsuccessful.
ResponseParameters struct {
// The group has been migrated to a supergroup with the specified
// identifier.
MigrateToChatID int64 `json:"migrate_to_chat_id,omitempty"`
// In case of exceeding flood control, the number of seconds left to wait
// before the request can be repeated
RetryAfter int `json:"retry_after,omitempty"`
}
// InputMedia represents the content of a media message to be sent.
InputMedia interface {
File() string
InputMediaCaption() string
InputMediaParseMode() string
InputMediaType() string
}
// InputMediaPhoto represents a photo to be sent.
InputMediaPhoto struct {
// Type of the result, must be photo
Type string `json:"type"`
// File to send. Pass a file_id to send a file that exists on the
// Telegram servers (recommended), pass an HTTP URL for Telegram to get
// a file from the Internet, or pass "attach://<file_attach_name>" to
// upload a new one using multipart/form-data under <file_attach_name>
// name.
Media string `json:"media"`
// Caption of the photo to be sent, 0-200 characters
Caption string `json:"caption,omitempty"`
// Send Markdown or HTML, if you want Telegram apps to show bold, italic,
// fixed-width text or inline URLs in the media caption.
ParseMode string `json:"parse_mode,omitempty"`
}
// InputMediaVideo represents a video to be sent.
InputMediaVideo struct {
// Type of the result, must be video
Type string `json:"type"`
// File to send. Pass a file_id to send a file that exists on the
// Telegram servers (recommended), pass an HTTP URL for Telegram to get
// a file from the Internet, or pass "attach://<file_attach_name>" to
// upload a new one using multipart/form-data under <file_attach_name>
// name.
Media string `json:"media"`
// Caption of the video to be sent, 0-200 characters
Caption string `json:"caption,omitempty"`
// Send Markdown or HTML, if you want Telegram apps to show bold, italic,
// fixed-width text or inline URLs in the media caption.
ParseMode string `json:"parse_mode,omitempty"`
// Video width
Width int `json:"width,omitempty"`
// Video height
Height int `json:"height,omitempty"`
// Video duration
Duration int `json:"duration,omitempty"`
// Pass true, if the uploaded video is suitable for streaming
SupportsStreaming bool `json:"supports_streaming,omitempty"`
}
// InputMediaAnimation represents an animation file (GIF or H.264/MPEG-4 AVC
// video without sound) to be sent.
InputMediaAnimation struct {
// Type of the result, must be animation
Type string `json:"type"`
// File to send. Pass a file_id to send a file that exists on the
// Telegram servers (recommended), pass an HTTP URL for Telegram to get
// a file from the Internet, or pass "attach://<file_attach_name>" to
// upload a new one using multipart/form-data under <file_attach_name
// name.
Media string `json:"media"`
// Thumbnail of the file sent. The thumbnail should be in JPEG format and
// less than 200 kB in size. A thumbnails width and height should not
// exceed 90. Ignored if the file is not uploaded using
// multipart/form-data. Thumbnails cant be reused and can be only
// uploaded as a new file, so you can pass "attach://<file_attach_name>"
// if the thumbnail was uploaded using multipart/form-data under
// <file_attach_name>.
Thumb InputFile `json:"thumb,omitempty"`
// Caption of the animation to be sent, 0-200 characters
Caption string `json:"caption,omitempty"`
// Send Markdown or HTML, if you want Telegram apps to show bold, italic,
// fixed-width text or inline URLs in the media caption.
ParseMode string `json:"parse_mode,omitempty"`
// Animation width
Width int `json:"width,omitempty"`
// Animation height
Height int `json:"height,omitempty"`
// Animation duration
Duration int `json:"duration,omitempty"`
}
// InputMediaAudio represents an audio file to be treated as music to be sent.
InputMediaAudio struct {
// Type of the result, must be audio
Type string `json:"type"`
// File to send. Pass a file_id to send a file that exists on the
// Telegram servers (recommended), pass an HTTP URL for Telegram to get
// a file from the Internet, or pass "attach://<file_attach_name>" to
// upload a new one using multipart/form-data under <file_attach_name>
// name.
Media string `json:"media"`
// Thumbnail of the file sent. The thumbnail should be in JPEG format and
// less than 200 kB in size. A thumbnails width and height should not
// exceed 90. Ignored if the file is not uploaded using
// multipart/form-data. Thumbnails cant be reused and can be only
// uploaded as a new file, so you can pass "attach://<file_attach_name>"
// if the thumbnail was uploaded using multipart/form-data under
// <file_attach_name>.
Thumb InputFile `json:"thumb,omitempty"`
// Caption of the audio to be sent, 0-200 characters
Caption string `json:"caption,omitempty"`
// Send Markdown or HTML, if you want Telegram apps to show bold, italic,
// fixed-width text or inline URLs in the media caption.
ParseMode string `json:"parse_mode,omitempty"`
// Duration of the audio in seconds
Duration int `json:"duration,omitempty"`
// Performer of the audio
Performer string `json:"performer,omitempty"`
// Title of the audio
Title string `json:"title,omitempty"`
}
// InputMediaDocument represents a general file to be sent.
InputMediaDocument struct {
// Type of the result, must be document
Type string `json:"type"`
// File to send. Pass a file_id to send a file that exists on the
// Telegram servers (recommended), pass an HTTP URL for Telegram to get
// a file from the Internet, or pass "attach://<file_attach_name>" to
// upload a new one using multipart/form-data under <file_attach_name>
// name.
Media string `json:"media"`
// Thumbnail of the file sent. The thumbnail should be in JPEG format and
// less than 200 kB in size. A thumbnails width and height should not
// exceed 90. Ignored if the file is not uploaded using
// multipart/form-data. Thumbnails cant be reused and can be only
// uploaded as a new file, so you can pass "attach://<file_attach_name>"
// if the thumbnail was uploaded using multipart/form-data under
// <file_attach_name>.
Thumb InputFile `json:"thumb,omitempty"`
// Caption of the document to be sent, 0-200 characters
Caption string `json:"caption,omitempty"`
// Send Markdown or HTML, if you want Telegram apps to show bold, italic,
// fixed-width text or inline URLs in the media caption.
ParseMode string `json:"parse_mode,omitempty"`
}
// InputFile represents the contents of a file to be uploaded. Must be posted
// using multipart/form-data in the usual way that files are uploaded via the
// browser.
InputFile interface{}
// Animation provide an animation for your game so that it looks stylish in
// chats (check out Lumberjack for an example). This object represents an
// animation file to be displayed in the message containing a game.
Animation struct {
// Unique file identifier
FileID string `json:"file_id"`
// Original animation filename as defined by sender
FileName string `json:"file_name,omitempty"`
// MIME type of the file as defined by sender
MimeType string `json:"mime_type,omitempty"`
// Animation thumbnail as defined by sender
Thumb *PhotoSize `json:"thumb,omitempty"`
// File size
FileSize int `json:"file_size,omitempty"`
}
)

46
vendor/gitlab.com/toby3d/telegram/types_games.go generated vendored Normal file
View File

@@ -0,0 +1,46 @@
package telegram
type (
// Game represents a game. Use BotFather to create and edit games, their
// short names will act as unique identifiers.
Game struct {
// Title of the game
Title string `json:"title"`
// Description of the game
Description string `json:"description"`
// Brief description of the game or high scores included in the game
// message. Can be automatically edited to include current high scores
// for the game when the bot calls setGameScore, or manually edited
// using editMessageText. 0-4096 characters.
Text string `json:"text,omitempty"`
// Photo that will be displayed in the game message in chats.
Photo []PhotoSize `json:"photo"`
// Special entities that appear in text, such as usernames, URLs, bot
// commands, etc.
TextEntities []MessageEntity `json:"text_entities,omitempty"`
// Animation that will be displayed in the game message in chats. Upload
// via BotFather
Animation *Animation `json:"animation,omitempty"`
}
// CallbackGame a placeholder, currently holds no information. Use BotFather
// to set up your game.
CallbackGame struct{}
// GameHighScore represents one row of the high scores table for a game.
GameHighScore struct {
// Position in high score table for the game
Position int `json:"position"`
// Score
Score int `json:"score"`
// User
User *User `json:"user"`
}
)

840
vendor/gitlab.com/toby3d/telegram/types_inline_mode.go generated vendored Normal file
View File

@@ -0,0 +1,840 @@
package telegram
type (
// InlineQuery represents an incoming inline query. When the user sends an
// empty query, your bot could return some default or trending results.
InlineQuery struct {
// Unique identifier for this query
ID string `json:"id"`
// Text of the query (up to 512 characters)
Query string `json:"query"`
// Offset of the results to be returned, can be controlled by the bot
Offset string `json:"offset"`
// Sender
From *User `json:"from"`
// Sender location, only for bots that request user location
Location *Location `json:"location,omitempty"`
}
// InlineQueryResult represents one result of an inline query.
InlineQueryResult interface {
ResultID() string
ResultType() string
ResultReplyMarkup() *InlineKeyboardMarkup
}
// InlineQueryResultArticle represents a link to an article or web page.
InlineQueryResultArticle struct {
// Type of the result, must be article
Type string `json:"type"`
// Unique identifier for this result, 1-64 Bytes
ID string `json:"id"`
// Title of the result
Title string `json:"title"`
// URL of the result
URL string `json:"url,omitempty"`
// Short description of the result
Description string `json:"description,omitempty"`
// Url of the thumbnail for the result
ThumbURL string `json:"thumb_url,omitempty"`
// Content of the message to be sent
InputMessageContent interface{} `json:"input_message_content"`
// Inline keyboard attached to the message
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// Pass True, if you don't want the URL to be shown in the message
HideURL bool `json:"hide_url,omitempty"`
// Thumbnail width
ThumbWidth int `json:"thumb_width,omitempty"`
// Thumbnail height
ThumbHeight int `json:"thumb_height,omitempty"`
}
// InlineQueryResultPhoto represents a link to a photo. By default, this
// photo will be sent by the user with optional caption. Alternatively, you
// can use input_message_content to send a message with the specified content
// instead of the photo.
InlineQueryResultPhoto struct {
// Type of the result, must be photo
Type string `json:"type"`
// Unique identifier for this result, 1-64 bytes
ID string `json:"id"`
// A valid URL of the photo. Photo must be in jpeg format. Photo size
// must not exceed 5MB
PhotoURL string `json:"photo_url"`
// URL of the thumbnail for the photo
ThumbURL string `json:"thumb_url"`
// Title for the result
Title string `json:"title,omitempty"`
// Short description of the result
Description string `json:"description,omitempty"`
// Caption of the photo to be sent, 0-200 characters
Caption string `json:"caption,omitempty"`
// Send Markdown or HTML, if you want Telegram apps to show bold, italic,
// fixed-width text or inline URLs in the media caption.
ParseMode string `json:"parse_mode,omitempty"`
// Width of the photo
PhotoWidth int `json:"photo_width,omitempty"`
// Height of the photo
PhotoHeight int `json:"photo_height,omitempty"`
// Inline keyboard attached to the message
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// Content of the message to be sent instead of the photo
InputMessageContent interface{} `json:"input_message_content,omitempty"`
}
// InlineQueryResultGif represents a link to an animated GIF file. By
// default, this animated GIF file will be sent by the user with optional
// caption. Alternatively, you can use input_message_content to send a
// message with the specified content instead of the animation.
InlineQueryResultGif struct {
// Type of the result, must be gif
Type string `json:"type"`
// Unique identifier for this result, 1-64 bytes
ID string `json:"id"`
// A valid URL for the GIF file. File size must not exceed 1MB
GifURL string `json:"gif_url"`
// URL of the static thumbnail for the result (jpeg or gif)
ThumbURL string `json:"thumb_url"`
// Title for the result
Title string `json:"title,omitempty"`
// Caption of the GIF file to be sent, 0-200 characters
Caption string `json:"caption,omitempty"`
// Send Markdown or HTML, if you want Telegram apps to show bold, italic,
// fixed-width text or inline URLs in the media caption.
ParseMode string `json:"parse_mode,omitempty"`
// Width of the GIF
GifWidth int `json:"gif_width,omitempty"`
// Height of the GIF
GifHeight int `json:"gif_height,omitempty"`
// Duration of the GIF
GifDuration int `json:"gif_duration,omitempty"`
// Inline keyboard attached to the message
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// Content of the message to be sent instead of the GIF animation
InputMessageContent interface{} `json:"input_message_content,omitempty"`
}
// InlineQueryResultMpeg4Gif represents a link to a video animation
// (H.264/MPEG-4 AVC video without sound). By default, this animated MPEG-4
// file will be sent by the user with optional caption. Alternatively, you
// can use input_message_content to send a message with the specified content
// instead of the animation.
InlineQueryResultMpeg4Gif struct {
// Type of the result, must be mpeg4_gif
Type string `json:"type"`
// Unique identifier for this result, 1-64 bytes
ID string `json:"id"`
// A valid URL for the MP4 file. File size must not exceed 1MB
Mpeg4URL string `json:"mpeg4_url"`
// URL of the static thumbnail (jpeg or gif) for the result
ThumbURL string `json:"thumb_url"`
// Title for the result
Title string `json:"title,omitempty"`
// Caption of the MPEG-4 file to be sent, 0-200 characters
Caption string `json:"caption,omitempty"`
// Video width
Mpeg4Width int `json:"mpeg4_width,omitempty"`
// Video height
Mpeg4Height int `json:"mpeg4_height,omitempty"`
// Video duration
Mpeg4Duration int `json:"mpeg4_duration,omitempty"`
// Inline keyboard attached to the message
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// Content of the message to be sent instead of the video animation
InputMessageContent interface{} `json:"input_message_content,omitempty"`
}
// InlineQueryResultVideo represents a link to a page containing an embedded
// video player or a video file. By default, this video file will be sent by
// the user with an optional caption. Alternatively, you can use
// input_message_content to send a message with the specified content
// instead of the video.
//
// If an InlineQueryResultVideo message contains an embedded video (e.g.,
// YouTube), you must replace its content using input_message_content.
InlineQueryResultVideo struct {
// Type of the result, must be video
Type string `json:"type"`
// Unique identifier for this result, 1-64 bytes
ID string `json:"id"`
// A valid URL for the embedded video player or video file
VideoURL string `json:"video_url"`
// Mime type of the content of video url, "text/html" or "video/mp4"
MimeType string `json:"mime_type"`
// URL of the thumbnail (jpeg only) for the video
ThumbURL string `json:"thumb_url"`
// Title for the result
Title string `json:"title"`
// Caption of the video to be sent, 0-200 characters
Caption string `json:"caption,omitempty"`
// Send Markdown or HTML, if you want Telegram apps to show bold, italic,
// fixed-width text or inline URLs in the media caption.
ParseMode string `json:"parse_mode,omitempty"`
// Short description of the result
Description string `json:"description,omitempty"`
// Video width
VideoWidth int `json:"video_width,omitempty"`
// Video height
VideoHeight int `json:"video_height,omitempty"`
// Video duration in seconds
VideoDuration int `json:"video_duration,omitempty"`
// Inline keyboard attached to the message
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// Content of the message to be sent instead of the video. This field is
// required if InlineQueryResultVideo is used to send an HTML-page as a
// result (e.g., a YouTube video).
InputMessageContent interface{} `json:"input_message_content,omitempty"`
}
// InlineQueryResultAudio represents a link to an mp3 audio file. By default,
// this audio file will be sent by the user. Alternatively, you can use
// input_message_content to send a message with the specified content
// instead of the audio.
InlineQueryResultAudio struct {
// Type of the result, must be audio
Type string `json:"type"`
// Unique identifier for this result, 1-64 bytes
ID string `json:"id"`
// A valid URL for the audio file
AudioURL string `json:"audio_url"`
// Title
Title string `json:"title"`
// Caption, 0-200 characters
Caption string `json:"caption,omitempty"`
// Send Markdown or HTML, if you want Telegram apps to show bold, italic,
// fixed-width text or inline URLs in the media caption.
ParseMode string `json:"parse_mode,omitempty"`
// Performer
Performer string `json:"performer,omitempty"`
// Audio duration in seconds
AudioDuration int `json:"audio_duration,omitempty"`
// Inline keyboard attached to the message
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// Content of the message to be sent instead of the audio
InputMessageContent interface{} `json:"input_message_content,omitempty"`
}
// InlineQueryResultVoice represents a link to a voice recording in an .ogg
// container encoded with OPUS. By default, this voice recording will be
// sent by the user. Alternatively, you can use input_message_content to
// send a message with the specified content instead of the the voice message.
InlineQueryResultVoice struct {
// Type of the result, must be voice
Type string `json:"type"`
// Unique identifier for this result, 1-64 bytes
ID string `json:"id"`
// A valid URL for the voice recording
VoiceURL string `json:"voice_url"`
// Recording title
Title string `json:"title"`
// Caption, 0-200 characters
Caption string `json:"caption,omitempty"`
// Send Markdown or HTML, if you want Telegram apps to show bold, italic,
// fixed-width text or inline URLs in the media caption.
ParseMode string `json:"parse_mode,omitempty"`
// Recording duration in seconds
VoiceDuration int `json:"voice_duration,omitempty"`
// Inline keyboard attached to the message
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// Content of the message to be sent instead of the voice recording
InputMessageContent interface{} `json:"input_message_content,omitempty"`
}
// InlineQueryResultDocument represents a link to a file. By default, this
// file will be sent by the user with an optional caption. Alternatively,
// you can use input_message_content to send a message with the specified
// content instead of the file. Currently, only .PDF and .ZIP files can be
// sent using this method.
InlineQueryResultDocument struct {
// Type of the result, must be document
Type string `json:"type"`
// Unique identifier for this result, 1-64 bytes
ID string `json:"id"`
// Title for the result
Title string `json:"title"`
// Caption of the document to be sent, 0-200 characters
Caption string `json:"caption,omitempty"`
// Send Markdown or HTML, if you want Telegram apps to show bold, italic,
// fixed-width text or inline URLs in the media caption.
ParseMode string `json:"parse_mode,omitempty"`
// A valid URL for the file
DocumentURL string `json:"document_url"`
// Mime type of the content of the file, either "application/pdf" or
// "application/zip"
MimeType string `json:"mime_type"`
// Short description of the result
Description string `json:"description,omitempty"`
// URL of the thumbnail (jpeg only) for the file
ThumbURL string `json:"thumb_url,omitempty"`
// Inline keyboard attached to the message
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// Content of the message to be sent instead of the file
InputMessageContent interface{} `json:"input_message_content,omitempty"`
// Thumbnail width
ThumbWidth int `json:"thumb_width,omitempty"`
// Thumbnail height
ThumbHeight int `json:"thumb_height,omitempty"`
}
// InlineQueryResultLocation represents a location on a map. By default, the
// location will be sent by the user. Alternatively, you can use
// input_message_content to send a message with the specified content
// instead of the location.
InlineQueryResultLocation struct {
// Type of the result, must be location
Type string `json:"type"`
// Unique identifier for this result, 1-64 Bytes
ID string `json:"id"`
// Location title
Title string `json:"title"`
// Url of the thumbnail for the result
ThumbURL string `json:"thumb_url,omitempty"`
// Location latitude in degrees
Latitude float32 `json:"latitude"`
// Location longitude in degrees
Longitude float32 `json:"longitude"`
// Inline keyboard attached to the message
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// Content of the message to be sent instead of the location
InputMessageContent interface{} `json:"input_message_content,omitempty"`
// Thumbnail width
ThumbWidth int `json:"thumb_width,omitempty"`
// Thumbnail height
ThumbHeight int `json:"thumb_height,omitempty"`
}
// InlineQueryResultVenue represents a venue. By default, the venue will be
// sent by the user. Alternatively, you can use input_message_content to
// send a message with the specified content instead of the venue.
InlineQueryResultVenue struct {
// Type of the result, must be venue
Type string `json:"type"`
// Unique identifier for this result, 1-64 Bytes
ID string `json:"id"`
// Title of the venue
Title string `json:"title"`
// Address of the venue
Address string `json:"address"`
// Foursquare identifier of the venue if known
FoursquareID string `json:"foursquare_id,omitempty"`
// Foursquare type of the venue, if known. (For example,
// "arts_entertainment/default", "arts_entertainment/aquarium" or
// "food/icecream".)
FoursquareType string `json:"foursquare_type,omitempty"`
// Url of the thumbnail for the result
ThumbURL string `json:"thumb_url,omitempty"`
// Latitude of the venue location in degrees
Latitude float32 `json:"latitude"`
// Longitude of the venue location in degrees
Longitude float32 `json:"longitude"`
// Inline keyboard attached to the message
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// Content of the message to be sent instead of the venue
InputMessageContent interface{} `json:"input_message_content,omitempty"`
// Thumbnail width
ThumbWidth int `json:"thumb_width,omitempty"`
// Thumbnail height
ThumbHeight int `json:"thumb_height,omitempty"`
}
// InlineQueryResultContact represents a contact with a phone number. By
// default, this contact will be sent by the user. Alternatively, you can
// use input_message_content to send a message with the specified content
// instead of the contact.
InlineQueryResultContact struct {
// Type of the result, must be contact
Type string `json:"type"`
// Unique identifier for this result, 1-64 Bytes
ID string `json:"id"`
// Contact's phone number
PhoneNumber string `json:"phone_number"`
// Contact's first name
FirstName string `json:"first_name"`
// Contact's last name
LastName string `json:"last_name,omitempty"`
// Additional data about the contact in the form of a vCard, 0-2048 bytes
VCard string `json:"vcard,omitempty"`
// Url of the thumbnail for the result
ThumbURL string `json:"thumb_url,omitempty"`
// Inline keyboard attached to the message
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// Content of the message to be sent instead of the contact
InputMessageContent interface{} `json:"input_message_content,omitempty"`
// Thumbnail width
ThumbWidth int `json:"thumb_width,omitempty"`
// Thumbnail height
ThumbHeight int `json:"thumb_height,omitempty"`
}
// InlineQueryResultGame represents a Game.
InlineQueryResultGame struct {
// Type of the result, must be game
Type string `json:"type"`
// Unique identifier for this result, 1-64 bytes
ID string `json:"id"`
// Short name of the game
GameShortName string `json:"game_short_name"`
// Inline keyboard attached to the message
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
}
// InlineQueryResultCachedPhoto represents a link to a photo stored on the
// Telegram servers. By default, this photo will be sent by the user with an
// optional caption. Alternatively, you can use input_message_content to
// send a message with the specified content instead of the photo.
InlineQueryResultCachedPhoto struct {
// Type of the result, must be photo
Type string `json:"type"`
// Unique identifier for this result, 1-64 bytes
ID string `json:"id"`
// A valid file identifier of the photo
PhotoFileID string `json:"photo_file_id"`
// Title for the result
Title string `json:"title,omitempty"`
// Short description of the result
Description string `json:"description,omitempty"`
// Caption of the photo to be sent, 0-200 characters
Caption string `json:"caption,omitempty"`
// Send Markdown or HTML, if you want Telegram apps to show bold, italic,
// fixed-width text or inline URLs in the media caption.
ParseMode string `json:"parse_mode,omitempty"`
// Inline keyboard attached to the message
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// Content of the message to be sent instead of the photo
InputMessageContent interface{} `json:"input_message_content,omitempty"`
}
// InlineQueryResultCachedGif represents a link to an animated GIF file
// stored on the Telegram servers. By default, this animated GIF file will
// be sent by the user with an optional caption. Alternatively, you can use
// input_message_content to send a message with specified content instead of
// the animation.
InlineQueryResultCachedGif struct {
// Type of the result, must be gif
Type string `json:"type"`
// Unique identifier for this result, 1-64 bytes
ID string `json:"id"`
// A valid file identifier for the GIF file
GifFileID string `json:"gif_file_id"`
// Title for the result
Title string `json:"title,omitempty"`
// Caption of the GIF file to be sent, 0-200 characters
Caption string `json:"caption,omitempty"`
// Send Markdown or HTML, if you want Telegram apps to show bold, italic,
// fixed-width text or inline URLs in the media caption.
ParseMode string `json:"parse_mode,omitempty"`
// Inline keyboard attached to the message
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// Content of the message to be sent instead of the GIF animation
InputMessageContent interface{} `json:"input_message_content,omitempty"`
}
// InlineQueryResultCachedMpeg4Gif represents a link to a video animation
// (H.264/MPEG-4 AVC video without sound) stored on the Telegram servers. By
// default, this animated MPEG-4 file will be sent by the user with an
// optional caption. Alternatively, you can use input_message_content to
// send a message with the specified content instead of the animation.
InlineQueryResultCachedMpeg4Gif struct {
// Type of the result, must be mpeg4_gif
Type string `json:"type"`
// Unique identifier for this result, 1-64 bytes
ID string `json:"id"`
// A valid file identifier for the MP4 file
Mpeg4FileID string `json:"mpeg4_file_id"`
// Title for the result
Title string `json:"title,omitempty"`
// Caption of the MPEG-4 file to be sent, 0-200 characters
Caption string `json:"caption,omitempty"`
// Send Markdown or HTML, if you want Telegram apps to show bold, italic,
// fixed-width text or inline URLs in the media caption.
ParseMode string `json:"parse_mode,omitempty"`
// Inline keyboard attached to the message
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// Content of the message to be sent instead of the video animation
InputMessageContent interface{} `json:"input_message_content,omitempty"`
}
// InlineQueryResultCachedSticker represents a link to a sticker stored on
// the Telegram servers. By default, this sticker will be sent by the user.
// Alternatively, you can use input_message_content to send a message with
// the specified content instead of the sticker.
InlineQueryResultCachedSticker struct {
// Type of the result, must be sticker
Type string `json:"type"`
// Unique identifier for this result, 1-64 bytes
ID string `json:"id"`
// A valid file identifier of the sticker
StickerFileID string `json:"sticker_file_id"`
// Inline keyboard attached to the message
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// Content of the message to be sent instead of the sticker
InputMessageContent interface{} `json:"input_message_content,omitempty"`
}
// InlineQueryResultCachedDocument represents a link to a file stored on the
// Telegram servers. By default, this file will be sent by the user with an
// optional caption. Alternatively, you can use input_message_content to
// send a message with the specified content instead of the file.
InlineQueryResultCachedDocument struct {
// Type of the result, must be document
Type string `json:"type"`
// Unique identifier for this result, 1-64 bytes
ID string `json:"id"`
// Title for the result
Title string `json:"title"`
// A valid file identifier for the file
DocumentFileID string `json:"document_file_id"`
// Short description of the result
Description string `json:"description,omitempty"`
// Caption of the document to be sent, 0-200 characters
Caption string `json:"caption,omitempty"`
// Send Markdown or HTML, if you want Telegram apps to show bold, italic,
// fixed-width text or inline URLs in the media caption.
ParseMode string `json:"parse_mode,omitempty"`
// Inline keyboard attached to the message
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// Content of the message to be sent instead of the file
InputMessageContent interface{} `json:"input_message_content,omitempty"`
}
// InlineQueryResultCachedVideo represents a link to a video file stored on
// the Telegram servers. By default, this video file will be sent by the
// user with an optional caption. Alternatively, you can use
// input_message_content to send a message with the specified content
// instead of the video.
InlineQueryResultCachedVideo struct {
// Type of the result, must be video
Type string `json:"type"`
// Unique identifier for this result, 1-64 bytes
ID string `json:"id"`
// A valid file identifier for the video file
VideoFileID string `json:"video_file_id"`
// Title for the result
Title string `json:"title"`
// Short description of the result
Description string `json:"description,omitempty"`
// Caption of the video to be sent, 0-200 characters
Caption string `json:"caption,omitempty"`
// Send Markdown or HTML, if you want Telegram apps to show bold, italic,
// fixed-width text or inline URLs in the media caption.
ParseMode string `json:"parse_mode,omitempty"`
// Inline keyboard attached to the message
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// Content of the message to be sent instead of the video
InputMessageContent interface{} `json:"input_message_content,omitempty"`
}
// InlineQueryResultCachedVoice represents a link to a voice message stored
// on the Telegram servers. By default, this voice message will be sent by
// the user. Alternatively, you can use input_message_content to send a
// message with the specified content instead of the voice message.
InlineQueryResultCachedVoice struct {
// Type of the result, must be voice
Type string `json:"type"`
// Unique identifier for this result, 1-64 bytes
ID string `json:"id"`
// A valid file identifier for the voice message
VoiceFileID string `json:"voice_file_id"`
// Voice message title
Title string `json:"title"`
// Caption, 0-200 characters
Caption string `json:"caption,omitempty"`
// Send Markdown or HTML, if you want Telegram apps to show bold, italic,
// fixed-width text or inline URLs in the media caption.
ParseMode string `json:"parse_mode,omitempty"`
// Inline keyboard attached to the message
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// Content of the message to be sent instead of the voice message
InputMessageContent interface{} `json:"input_message_content,omitempty"`
}
// InlineQueryResultCachedAudio represents a link to an mp3 audio file
// stored on the Telegram servers. By default, this audio file will be sent
// by the user. Alternatively, you can use input_message_content to send a
// message with the specified content instead of the audio.
InlineQueryResultCachedAudio struct {
// Type of the result, must be audio
Type string `json:"type"`
// Unique identifier for this result, 1-64 bytes
ID string `json:"id"`
// A valid file identifier for the audio file
AudioFileID string `json:"audio_file_id"`
// Caption, 0-200 characters
Caption string `json:"caption,omitempty"`
// Send Markdown or HTML, if you want Telegram apps to show bold, italic,
// fixed-width text or inline URLs in the media caption.
ParseMode string `json:"parse_mode,omitempty"`
// Inline keyboard attached to the message
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
// Content of the message to be sent instead of the audio
InputMessageContent interface{} `json:"input_message_content,omitempty"`
}
// InputMessageContent represents the content of a message to be sent as a result
// of an inline query.
InputMessageContent interface {
IsInputMessageContent() bool
}
// InputTextMessageContent represents the content of a text message to be
// sent as the result of an inline query.
InputTextMessageContent struct {
// Text of the message to be sent, 1-4096 characters
MessageText string `json:"message_text"`
// Send Markdown or HTML, if you want Telegram apps to show bold, italic,
// fixed-width text or inline URLs in your bot's message.
ParseMode string `json:"parse_mode,omitempty"`
// Disables link previews for links in the sent message
DisableWebPagePreview bool `json:"disable_web_page_preview,omitempty"`
}
// InputLocationMessageContent represents the content of a location message
// to be sent as the result of an inline query.
InputLocationMessageContent struct {
// Latitude of the location in degrees
Latitude float32 `json:"latitude"`
// Longitude of the location in degrees
Longitude float32 `json:"longitude"`
}
// InputVenueMessageContent represents the content of a venue message to be
// sent as the result of an inline query.
InputVenueMessageContent struct {
// Latitude of the venue in degrees
Latitude float32 `json:"latitude"`
// Longitude of the venue in degrees
Longitude float32 `json:"longitude"`
// Name of the venue
Title string `json:"title"`
// Address of the venue
Address string `json:"address"`
// Foursquare identifier of the venue, if known
FoursquareID string `json:"foursquare_id,omitempty"`
// Foursquare type of the venue, if known. (For example,
// "arts_entertainment/default", "arts_entertainment/aquarium" or
// "food/icecream".)
FoursquareType string `json:"foursquare_type,omitempty"`
}
// InputContactMessageContent represents the content of a contact message to
// be sent as the result of an inline query.
InputContactMessageContent struct {
// Contact's phone number
PhoneNumber string `json:"phone_number"`
// Contact's first name
FirstName string `json:"first_name"`
// Contact's last name
LastName string `json:"last_name,omitempty"`
// Additional data about the contact in the form of a vCard, 0-2048 bytes
VCard string `json:"vcard,omitempty"`
}
// ChosenInlineResult represents a result of an inline query that was chosen
// by the user and sent to their chat partner.
ChosenInlineResult struct {
// The unique identifier for the result that was chosen
ResultID string `json:"result_id"`
// Identifier of the sent inline message. Available only if there is an
// inline keyboard attached to the message. Will be also received in
// callback queries and can be used to edit the message.
InlineMessageID string `json:"inline_message_id,omitempty"`
// The query that was used to obtain the result
Query string `json:"query"`
// The user that chose the result
From *User `json:"from"`
// Sender location, only for bots that require user location
Location *Location `json:"location,omitempty"`
}
)

262
vendor/gitlab.com/toby3d/telegram/types_passport.go generated vendored Normal file
View File

@@ -0,0 +1,262 @@
package telegram
type (
// PassportData contains information about Telegram Passport data shared with
// the bot by the user.
PassportData struct {
// Array with information about documents and other Telegram Passport
// elements that was shared with the bot
Data []EncryptedPassportElement `json:"data"`
// Encrypted credentials required to decrypt the data
Credentials *EncryptedCredentials `json:"credentials"`
}
// PassportFile represents a file uploaded to Telegram Passport. Currently all
// Telegram Passport files are in JPEG format when decrypted and don't exceed
// 10MB.
PassportFile struct {
// Unique identifier for this file
FileID string `json:"file_id"`
// File size
FileSize int `json:"file_size"`
// Unix time when the file was uploaded
FileDate int64 `json:"file_date"`
}
// EncryptedPassportElement contains information about documents or other
// Telegram Passport elements shared with the bot by the user.
EncryptedPassportElement struct {
// Element type.
Type string `json:"type"`
// Base64-encoded encrypted Telegram Passport element data provided by
// the user, available for "personal_details", "passport",
// "driver_license", "identity_card", "identity_passport" and "address"
// types. Can be decrypted and verified using the accompanying
// EncryptedCredentials.
Data string `json:"data,omitempty"`
// User's verified phone number, available only for "phone_number" type
PhoneNumber string `json:"phone_number,omitempty"`
// User's verified email address, available only for "email" type
Email string `json:"email,omitempty"`
// Array of encrypted files with documents provided by the user,
// available for "utility_bill", "bank_statement", "rental_agreement",
// "passport_registration" and "temporary_registration" types. Files can
// be decrypted and verified using the accompanying EncryptedCredentials.
Files []PassportFile `json:"files,omitempty"`
// Encrypted file with the front side of the document, provided by the
// user. Available for "passport", "driver_license", "identity_card" and
// "internal_passport". The file can be decrypted and verified using the
// accompanying EncryptedCredentials.
FrontSide *PassportFile `json:"front_side,omitempty"`
// Encrypted file with the reverse side of the document, provided by the
// user. Available for "driver_license" and "identity_card". The file can
// be decrypted and verified using the accompanying EncryptedCredentials.
ReverseSide *PassportFile `json:"reverse_side,omitempty"`
// Encrypted file with the selfie of the user holding a document,
// provided by the user; available for "passport", "driver_license",
// "identity_card" and "internal_passport". The file can be decrypted
// and verified using the accompanying EncryptedCredentials.
Selfie *PassportFile `json:"selfie,omitempty"`
}
// EncryptedCredentials contains data required for decrypting and
// authenticating EncryptedPassportElement. See the Telegram Passport
// Documentation for a complete description of the data decryption and
// authentication processes.
EncryptedCredentials struct {
// Base64-encoded encrypted JSON-serialized data with unique user's
// payload, data hashes and secrets required for EncryptedPassportElement
// decryption and authentication
Data string `json:"data"`
// Base64-encoded data hash for data authentication
Hash string `json:"hash"`
// Base64-encoded secret, encrypted with the bot's public RSA key,
// required for data decryption
Secret string `json:"secret"`
}
// PassportElementError represents an error in the Telegram Passport element
// which was submitted that should be resolved by the user.
PassportElementError interface{}
// PassportElementErrorDataField represents an issue in one of the data
// fields that was provided by the user. The error is considered resolved
// when the field's value changes.
PassportElementErrorDataField struct {
// Error source, must be data
Source string `json:"source"`
// The section of the user's Telegram Passport which has the error, one
// of "personal_details", "passport", "driver_license", "identity_card",
// "internal_passport", "address"
Type string `json:"type"`
// Name of the data field which has the error
FieldName string `json:"field_name"`
// Base64-encoded data hash
DataHash string `json:"data_hash"`
// Error message
Message string `json:"message"`
}
// PassportElementErrorFrontSide represents an issue with the front side of
// a document. The error is considered resolved when the file with the front
// side of the document changes.
PassportElementErrorFrontSide struct {
// Error source, must be front_side
Source string `json:"source"`
// The section of the user's Telegram Passport which has the issue, one
// of "passport", "driver_license", "identity_card", "internal_passport"
Type string `json:"type"`
// Base64-encoded hash of the file with the front side of the document
FileHash string `json:"file_hash"`
// Error message
Message string `json:"message"`
}
// PassportElementErrorReverseSide represents an issue with the reverse side
// of a document. The error is considered resolved when the file with reverse
// side of the document changes.
PassportElementErrorReverseSide struct {
// Error source, must be reverse_side
Source string `json:"source"`
// The section of the user's Telegram Passport which has the issue, one
// of "driver_license", "identity_card"
Type string `json:"type"`
// Base64-encoded hash of the file with the reverse side of the document
FileHash string `json:"file_hash"`
// Error message
Message string `json:"message"`
}
// PassportElementErrorSelfie represents an issue with the selfie with a
// document. The error is considered resolved when the file with the selfie
// changes.
PassportElementErrorSelfie struct {
// Error source, must be selfie
Source string `json:"source"`
// The section of the user's Telegram Passport which has the issue, one
// of "passport", "driver_license", "identity_card", "internal_passport"
Type string `json:"type"`
// Base64-encoded hash of the file with the selfie
FileHash string `json:"file_hash"`
// Error message
Message string `json:"message"`
}
// PassportElementErrorFile represents an issue with a document scan. The
// error is considered resolved when the file with the document scan changes.
PassportElementErrorFile struct {
// Error source, must be file
Source string `json:"source"`
// The section of the user's Telegram Passport which has the issue, one
// of "utility_bill", "bank_statement", "rental_agreement",
// "passport_registration", "temporary_registration"
Type string `json:"type"`
// Base64-encoded file hash
FileHash string `json:"file_hash"`
// Error message
Message string `json:"message"`
}
// PassportElementErrorFiles represents an issue with a list of scans. The
// error is considered resolved when the list of files containing the scans
// changes.
PassportElementErrorFiles struct {
// Error source, must be files
Source string `json:"source"`
// The section of the user's Telegram Passport which has the issue, one
// of "utility_bill", "bank_statement", "rental_agreement",
// "passport_registration", "temporary_registration"
Type string `json:"type"`
// List of base64-encoded file hashes
FileHashes []string `json:"file_hashes"`
// Error message
Message string `json:"message"`
}
// PassportElementErrorTranslationFile represents an issue with one of the
// files that constitute the translation of a document. The error is
// considered resolved when the file changes.
PassportElementErrorTranslationFile struct {
// Error source, must be translation_file
Source string `json:"source"`
// Type of element of the user's Telegram Passport which has the issue,
// one of “passport”, “driver_license”, “identity_card”,
// “internal_passport”, “utility_bill”, “bank_statement”,
// “rental_agreement”, “passport_registration”, “temporary_registration”
Type string `json:"type"`
// Base64-encoded file hash
FileHash string `json:"file_hash"`
// Error message
Message string `json:"message"`
}
// PassportElementErrorTranslationFiles represents an issue with the translated
// version of a document. The error is considered resolved when a file with the
// document translation change.
PassportElementErrorTranslationFiles struct {
// Error source, must be translation_files
Source string `json:"source"`
// Type of element of the user's Telegram Passport which has the issue,
// one of “passport”, “driver_license”, “identity_card”,
// “internal_passport”, “utility_bill”, “bank_statement”,
// “rental_agreement”, “passport_registration”, “temporary_registration”
Type string `json:"type"`
// List of base64-encoded file hashes
FileHashes []string `json:"file_hashes"`
// Error message
Message string `json:"message"`
}
// PassportElementErrorUnspecified represents an issue in an unspecified place.
// The error is considered resolved when new data is added.
PassportElementErrorUnspecified struct {
// Error source, must be unspecified
Source string `json:"source"`
// Type of element of the user's Telegram Passport which has the issue
Type string `json:"type"`
// Base64-encoded element hash
ElementHash string `json:"element_hash"`
// Error message
Message string `json:"message"`
}
)

158
vendor/gitlab.com/toby3d/telegram/types_payments.go generated vendored Normal file
View File

@@ -0,0 +1,158 @@
package telegram
type (
// LabeledPrice represents a portion of the price for goods or services.
LabeledPrice struct {
// Portion label
Label string `json:"label"`
// Price of the product in the smallest units of the currency (integer,
// not float/double). For example, for a price of US$ 1.45 pass amount =
// 145. See the exp parameter in currencies.json, it shows the number of
// digits past the decimal point for each currency (2 for the majority
// of currencies).
Amount int `json:"amount"`
}
// Invoice contains basic information about an invoice.
Invoice struct {
// Product name
Title string `json:"title"`
// Product description
Description string `json:"description"`
// Unique bot deep-linking parameter that can be used to generate this
// invoice
StartParameter string `json:"start_parameter"`
// Three-letter ISO 4217 currency code
Currency string `json:"currency"`
// Total price in the smallest units of the currency (integer, not
// float/double). For example, for a price of US$ 1.45 pass amount = 145.
// See the exp parameter in currencies.json, it shows the number of
// digits past the decimal point for each currency (2 for the majority
// of currencies).
TotalAmount int `json:"total_amount"`
}
// ShippingAddress represents a shipping address.
ShippingAddress struct {
// ISO 3166-1 alpha-2 country code
CountryCode string `json:"country_code"`
// State, if applicable
State string `json:"state"`
// City
City string `json:"city"`
// First line for the address
StreetLine1 string `json:"street_line1"`
// Second line for the address
StreetLine2 string `json:"street_line2"`
// Address post code
PostCode string `json:"post_code"`
}
// OrderInfo represents information about an order.
OrderInfo struct {
// User name
Name string `json:"name,omitempty"`
// User's phone number
PhoneNumber string `json:"phone_number,omitempty"`
// User email
Email string `json:"email,omitempty"`
// User shipping address
ShippingAddress *ShippingAddress `json:"shipping_address,omitempty"`
}
// ShippingOption represents one shipping option.
ShippingOption struct {
// Shipping option identifier
ID string `json:"id"`
// Option title
Title string `json:"title"`
// List of price portions
Prices []LabeledPrice `json:"prices"`
}
// SuccessfulPayment contains basic information about a successful payment.
SuccessfulPayment struct {
// Three-letter ISO 4217 currency code
Currency string `json:"currency"`
// Bot specified invoice payload
InvoicePayload string `json:"invoice_payload"`
// Identifier of the shipping option chosen by the user
ShippingOptionID string `json:"shipping_option_id,omitempty"`
// Telegram payment identifier
TelegramPaymentChargeID string `json:"telegram_payment_charge_id"`
// Provider payment identifier
ProviderPaymentChargeID string `json:"provider_payment_charge_id"`
// Total price in the smallest units of the currency (integer, not
// float/double). For example, for a price of US$ 1.45 pass amount = 145.
// See the exp parameter in currencies.json, it shows the number of
// digits past the decimal point for each currency (2 for the majority
// of currencies).
TotalAmount int `json:"total_amount"`
// Order info provided by the user
OrderInfo *OrderInfo `json:"order_info,omitempty"`
}
// ShippingQuery contains information about an incoming shipping query.
ShippingQuery struct {
// Unique query identifier
ID string `json:"id"`
// Bot specified invoice payload
InvoicePayload string `json:"invoice_payload"`
// User who sent the query
From *User `json:"from"`
// User specified shipping address
ShippingAddress *ShippingAddress `json:"shipping_address"`
}
// PreCheckoutQuery contains information about an incoming pre-checkout query.
PreCheckoutQuery struct {
// Unique query identifier
ID string `json:"id"`
// Three-letter ISO 4217 currency code
Currency string `json:"currency"`
// Bot specified invoice payload
InvoicePayload string `json:"invoice_payload"`
// Identifier of the shipping option chosen by the user
ShippingOptionID string `json:"shipping_option_id,omitempty"`
// User who sent the query
From *User `json:"from"`
// Total price in the smallest units of the currency (integer, not
// float/double). For example, for a price of US$ 1.45 pass amount = 145.
// See the exp parameter in currencies.json, it shows the number of
// digits past the decimal point for each currency (2 for the majority of
// currencies).
TotalAmount int `json:"total_amount"`
// Order info provided by the user
OrderInfo *OrderInfo `json:"order_info,omitempty"`
}
)

66
vendor/gitlab.com/toby3d/telegram/types_stickers.go generated vendored Normal file
View File

@@ -0,0 +1,66 @@
package telegram
type (
// Sticker represents a sticker.
Sticker struct {
// Unique identifier for this file
FileID string `json:"file_id"`
// Emoji associated with the sticker
Emoji string `json:"emoji,omitempty"`
// Name of the sticker set to which the sticker belongs
SetName string `json:"set_name,omitempty"`
// Sticker width
Width int `json:"width"`
// Sticker height
Height int `json:"height"`
// File size
FileSize int `json:"file_size,omitempty"`
// Sticker thumbnail in the .webp or .jpg format
Thumb *PhotoSize `json:"thumb,omitempty"`
// For mask stickers, the position where the mask should be placed
MaskPosition *MaskPosition `json:"mask_position,omitempty"`
}
// StickerSet represents a sticker set.
StickerSet struct {
// Sticker set name
Name string `json:"name"`
// Sticker set title
Title string `json:"title"`
// True, if the sticker set contains masks
ContainsMasks bool `json:"contains_masks"`
// List of all set stickers
Stickers []Sticker `json:"stickers"`
}
// MaskPosition describes the position on faces where a mask should be placed
// by default.
MaskPosition struct {
// The part of the face relative to which the mask should be placed. One
// of "forehead", "eyes", "mouth", or "chin".
Point string `json:"point"`
// Shift by X-axis measured in widths of the mask scaled to the face
// size, from left to right. For example, choosing -1.0 will place mask
// just to the left of the default mask position.
XShift float32 `json:"x_shift"`
// Shift by Y-axis measured in heights of the mask scaled to the face
// size, from top to bottom. For example, 1.0 will place the mask just
// below the default mask position.
YShift float32 `json:"y_shift"`
// Mask scaling coefficient. For example, 2.0 means double size.
Scale float32 `json:"scale"`
}
)

33
vendor/gitlab.com/toby3d/telegram/unban_chat_member.go generated vendored Normal file
View File

@@ -0,0 +1,33 @@
package telegram
import json "github.com/pquerna/ffjson/ffjson"
// UnbanChatMemberParameters represents data for UnbanChatMember method.
type UnbanChatMemberParameters struct {
// Unique identifier for the target chat
ChatID int64 `json:"chat_id"`
UserID int `json:"user_id"`
}
// UnbanChatMember unban a previously kicked user in a supergroup or channel. The
// user will not return to the group or channel automatically, but will be able
// to join via link, etc. The bot must be an administrator for this to work.
// Returns True on success.
func (bot *Bot) UnbanChatMember(chatID int64, userID int) (ok bool, err error) {
dst, err := json.Marshal(&UnbanChatMemberParameters{
ChatID: chatID,
UserID: userID,
})
if err != nil {
return
}
resp, err := bot.request(dst, MethodUnbanChatMember)
if err != nil {
return
}
err = json.Unmarshal(*resp.Result, &ok)
return
}

View File

@@ -0,0 +1,27 @@
package telegram
import json "github.com/pquerna/ffjson/ffjson"
// UnpinChatMessageParameters represents data for UnpinChatMessage method.
type UnpinChatMessageParameters struct {
// Unique identifier for the target chat
ChatID int64 `json:"chat_id"`
}
// UnpinChatMessage unpin a message in a supergroup chat. The bot must be an
// administrator in the chat for this to work and must have the appropriate admin
// rights. Returns True on success.
func (bot *Bot) UnpinChatMessage(chatID int64) (ok bool, err error) {
dst, err := json.Marshal(&UnpinChatMessageParameters{ChatID: chatID})
if err != nil {
return
}
resp, err := bot.request(dst, MethodUnpinChatMessage)
if err != nil {
return
}
err = json.Unmarshal(*resp.Result, &ok)
return
}

169
vendor/gitlab.com/toby3d/telegram/upload.go generated vendored Normal file
View File

@@ -0,0 +1,169 @@
package telegram
import (
"bytes"
"errors"
"io"
"mime/multipart"
"os"
"path"
"strconv"
log "github.com/kirillDanshin/dlog"
json "github.com/pquerna/ffjson/ffjson"
http "github.com/valyala/fasthttp"
)
// ErrBadFileType describes error of the unsupported file data type for uploading
var ErrBadFileType = errors.New("bad file type")
/*
Upload is a helper method which provide are three ways to send files (photos, stickers, audio,
media, etc.):
1. If the file is already stored somewhere on the Telegram servers, you don't need to reupload it:
each file object has a file_id field, simply pass this file_id as a parameter instead of uploading.
There are no limits for files sent this way.
2. Provide Telegram with an *fasthttp.URI for the file to be sent. Telegram will download and send the
file. 5 MB max size for photos and 20 MB max for other types of content.
3. Post the file using multipart/form-data in the usual way that files are uploaded via the
browser. Use []byte or io.Reader for this. 10 MB max size for photos, 50 MB for other files.
Sending by FileID
* It is not possible to change the file type when resending by file_id. I.e. a video can't be sent
as a photo, a photo can't be sent as a document, etc.
* It is not possible to resend thumbnails.
* Resending a photo by file_id will send all of its sizes.
* file_id is unique for each individual bot and can't be transferred from one bot to another.
Sending by URL
* When sending by *fasthttp.URI the target file must have the correct MIME type (e.g., audio/mpeg for
sendAudio, etc.).
* In sendDocument, sending by URL will currently only work for gif, pdf and zip files.
* To use SendVoice, the file must have the type audio/ogg and be no more than 1MB in size. 120MB
voice notes will be sent as files.
* Other configurations may work but we can't guarantee that they will.
*/
func (b *Bot) Upload(method, key, name string, file InputFile, args *http.Args) (response *Response, err error) {
buffer := bytes.NewBuffer(nil)
multi := multipart.NewWriter(buffer)
requestURI := http.AcquireURI()
requestURI.SetScheme("https")
requestURI.SetHost("api.telegram.org")
requestURI.SetPath(path.Join("bot"+b.AccessToken, method))
args.VisitAll(func(key, value []byte) {
_ = multi.WriteField(string(key), string(value))
})
if err = createFileField(multi, file, key, name); err != nil {
return
}
if err = multi.Close(); err != nil {
return
}
req := http.AcquireRequest()
defer http.ReleaseRequest(req)
req.SetBody(buffer.Bytes())
req.Header.SetContentType(multi.FormDataContentType())
req.Header.SetMethod("POST")
req.Header.SetRequestURI(requestURI.String())
req.Header.SetUserAgent(path.Join("telegram", strconv.FormatInt(Version, 10)))
req.Header.SetHostBytes(requestURI.Host())
log.Ln("Request:")
log.D(req)
resp := http.AcquireResponse()
defer http.ReleaseResponse(resp)
err = http.Do(req, resp)
log.Ln("Resp:")
log.D(resp)
if err != nil {
return
}
response = new(Response)
if err = json.Unmarshal(resp.Body(), response); err != nil {
return
}
if !response.Ok {
err = errors.New(response.Description)
}
return
}
func createFileField(w *multipart.Writer, file interface{}, key, val string) (err error) {
switch src := file.(type) {
case string: // Send FileID of file on disk path
err = createFileFieldString(w, key, src)
case *http.URI: // Send by URL
err = w.WriteField(key, src.String())
case []byte: // Upload new
err = createFileFieldRaw(w, key, val, bytes.NewReader(src))
case io.Reader: // Upload new
err = createFileFieldRaw(w, key, val, src)
default:
err = ErrBadFileType
}
return
}
func createFileFieldString(w *multipart.Writer, key, src string) (err error) {
_, err = os.Stat(src)
switch {
case os.IsNotExist(err):
err = w.WriteField(key, src)
case os.IsExist(err):
err = uploadFromDisk(w, key, src)
}
return
}
func uploadFromDisk(w *multipart.Writer, key, src string) error {
file, err := os.Open(src)
if err != nil {
return err
}
defer func() {
_ = file.Close()
}()
var formFile io.Writer
formFile, err = w.CreateFormFile(key, file.Name())
if err != nil {
return err
}
_, err = io.Copy(formFile, file)
return err
}
func createFileFieldRaw(w *multipart.Writer, key, value string, src io.Reader) error {
field, err := w.CreateFormFile(key, value)
if err != nil {
return err
}
_, err = io.Copy(field, src)
return err
}

69
vendor/gitlab.com/toby3d/telegram/utils.go generated vendored Normal file
View File

@@ -0,0 +1,69 @@
package telegram
import http "github.com/valyala/fasthttp"
// NewForceReply calls the response interface to the message.
func NewForceReply() *ForceReply {
return &ForceReply{ForceReply: true}
}
// NewInlineMentionURL creates a url.URL for the mention user without username.
func NewInlineMentionURL(userID int) *http.URI {
link := http.AcquireURI()
link.SetScheme(SchemeTelegram)
link.SetPath("user")
q := link.QueryArgs()
q.SetUint("id", userID)
link.SetQueryStringBytes(q.QueryString())
return link
}
func NewMarkdownBold(text string) string {
return "*" + text + "*"
}
func NewMarkdownItalic(text string) string {
return "_" + text + "_"
}
func NewMarkdownURL(text string, link *http.URI) string {
return "[" + text + "](" + link.String() + ")"
}
func NewMarkdownMention(text string, id int) string {
return NewMarkdownURL(text, NewInlineMentionURL(id))
}
func NewMarkdownCode(text string) string {
return "`" + text + "`"
}
func NewMarkdownCodeBlock(text string) string {
return "```" + text + "```"
}
func NewHtmlBold(text string) string {
return "<b>" + text + "</b>"
}
func NewHtmlItalic(text string) string {
return "<i>" + text + "</i>"
}
func NewHtmlURL(text string, link *http.URI) string {
return `<a href="` + link.String() + `">` + text + `</a>`
}
func NewHtmlMention(text string, id int) string {
return NewHtmlURL(text, NewInlineMentionURL(id))
}
func NewHtmlCode(text string) string {
return "<code>" + text + "</code>"
}
func NewHtmlCodeBlock(text string) string {
return "<pre>" + text + "</pre>"
}

16
vendor/gitlab.com/toby3d/telegram/utils_animation.go generated vendored Normal file
View File

@@ -0,0 +1,16 @@
package telegram
func (a *Animation) HasThumb() bool {
return a != nil && a.Thumb != nil
}
func (a *Animation) File() *File {
if a == nil {
return nil
}
return &File{
FileID: a.FileID,
FileSize: a.FileSize,
}
}

37
vendor/gitlab.com/toby3d/telegram/utils_audio.go generated vendored Normal file
View File

@@ -0,0 +1,37 @@
package telegram
func (a *Audio) FullName(sep string) (name string) {
if !a.HasTitle() {
return
}
if a.HasPerformer() {
name += a.Performer + sep
}
name += a.Title
return
}
func (a *Audio) HasPerformer() bool {
return a != nil && a.Performer != ""
}
func (a *Audio) HasTitle() bool {
return a != nil && a.Title != ""
}
func (a *Audio) HasThumb() bool {
return a != nil && a.Thumb != nil
}
func (a *Audio) File() *File {
if a == nil {
return nil
}
return &File{
FileID: a.FileID,
FileSize: a.FileSize,
}
}

167
vendor/gitlab.com/toby3d/telegram/utils_bot.go generated vendored Normal file
View File

@@ -0,0 +1,167 @@
package telegram
import (
"path"
"strings"
http "github.com/valyala/fasthttp"
)
// Bot represents a bot user with access token getted from @BotFather and
// fasthttp.Client for requests.
type Bot struct {
*User
AccessToken string
Client *http.Client
}
// SetClient allow set custom fasthttp.Client (for proxy traffic, for example).
func (b *Bot) SetClient(newClient *http.Client) {
if b == nil {
b = new(Bot)
}
b.Client = newClient
}
// New creates a new default Bot structure based on the input access token.
func New(accessToken string) (*Bot, error) {
var err error
b := new(Bot)
b.SetClient(defaultClient)
b.AccessToken = accessToken
b.User, err = b.GetMe()
return b, err
}
// IsMessageFromMe checks that the input message is a message from the current
// bot.
func (b *Bot) IsMessageFromMe(m *Message) bool {
return b != nil && b.User != nil &&
m != nil && m.From != nil && m.From.ID == b.ID
}
// IsForwardFromMe checks that the input message is a forwarded message from the
// current bot.
func (b *Bot) IsForwardFromMe(m *Message) bool {
return b != nil && b.User != nil &&
m.IsForward() && m.ForwardFrom.ID == b.ID
}
// IsReplyToMe checks that the input message is a reply to the current bot.
func (b *Bot) IsReplyToMe(m *Message) bool {
return m.Chat.IsPrivate() ||
(m.IsReply() && b.IsMessageFromMe(m.ReplyToMessage))
}
// IsCommandToMe checks that the input message is a command for the current bot.
func (b *Bot) IsCommandToMe(m *Message) bool {
if !m.IsCommand() {
return false
}
if m.Chat.IsPrivate() {
return true
}
parts := strings.Split(m.RawCommand(), "@")
if len(parts) <= 1 {
return false
}
return strings.EqualFold(parts[1], b.User.Username)
}
// IsMessageMentionsMe checks that the input message mentions the current bot.
func (b *Bot) IsMessageMentionsMe(m *Message) bool {
if b == nil || b.User == nil ||
m == nil {
return false
}
if b.IsCommandToMe(m) {
return true
}
var entities []MessageEntity
switch {
case m.HasMentions():
entities = m.Entities
case m.HasCaptionMentions():
entities = m.CaptionEntities
}
for _, entity := range entities {
if entity.IsMention() && entity.User.ID == b.ID {
return true
}
}
return false
}
// IsForwardMentionsMe checks that the input forwarded message mentions the
// current bot.
func (b *Bot) IsForwardMentionsMe(m *Message) bool {
return m.IsForward() && b.IsMessageMentionsMe(m)
}
// IsReplyMentionsMe checks that the input message mentions the current bot.
func (b *Bot) IsReplyMentionsMe(m *Message) bool {
return m.IsReply() && b.IsMessageMentionsMe(m.ReplyToMessage)
}
// IsMessageToMe checks that the input message is addressed to the current bot.
func (b *Bot) IsMessageToMe(m *Message) bool {
if m == nil || m.Chat == nil {
return false
}
if m.Chat.IsPrivate() ||
b.IsCommandToMe(m) ||
b.IsReplyToMe(m) ||
b.IsMessageMentionsMe(m) {
return true
}
return false
}
// NewFileURL creates a url.URL to file with path getted from GetFile method.
func (b *Bot) NewFileURL(filePath string) *http.URI {
if b == nil || b.AccessToken == "" ||
filePath == "" {
return nil
}
result := http.AcquireURI()
result.SetScheme("https")
result.SetHost("api.telegram.org")
result.SetPath(path.Join("file", "bot"+b.AccessToken, filePath))
return result
}
// NewRedirectURL creates new url.URL for redirecting from one chat to another.
func (b *Bot) NewRedirectURL(param string, group bool) *http.URI {
if b == nil || b.User == nil || b.User.Username == "" {
return nil
}
link := http.AcquireURI()
link.SetScheme("https")
link.SetHost("t.me")
link.SetPath(b.User.Username)
q := link.QueryArgs()
key := "start"
if group {
key += "group"
}
q.Set(key, param)
link.SetQueryStringBytes(q.QueryString())
return link
}

78
vendor/gitlab.com/toby3d/telegram/utils_chat.go generated vendored Normal file
View File

@@ -0,0 +1,78 @@
package telegram
import "strings"
// IsPrivate checks that the current chat is a private chat with single user.
func (c *Chat) IsPrivate() bool {
return c != nil && strings.EqualFold(c.Type, ChatPrivate)
}
// IsGroup checks that the current chat is a group.
func (c *Chat) IsGroup() bool {
return c != nil && strings.EqualFold(c.Type, ChatGroup)
}
// IsSuperGroup checks that the current chat is a supergroup.
func (c *Chat) IsSuperGroup() bool {
return c != nil && strings.EqualFold(c.Type, ChatSuperGroup)
}
// IsChannel checks that the current chat is a channel.
func (c *Chat) IsChannel() bool {
return c != nil && strings.EqualFold(c.Type, ChatChannel)
}
// HasPinnedMessage checks that the current chat has a pinned message.
func (c *Chat) HasPinnedMessage() bool {
return c != nil && c.PinnedMessage != nil
}
// HasStickerSet checks that the current chat has a sticker set.
func (c *Chat) HasStickerSet() bool {
return c != nil && c.StickerSetName != ""
}
// StickerSet return StickerSet structure if StickerSetName is available.
func (c *Chat) StickerSet(bot *Bot) *StickerSet {
if !c.HasStickerSet() || bot == nil {
return nil
}
set, err := bot.GetStickerSet(c.StickerSetName)
if err != nil {
return nil
}
return set
}
// FullName returns the full name of chat or FirstName if LastName is not available.
func (c *Chat) FullName() string {
if c == nil {
return ""
}
if c.HasLastName() {
return c.FirstName + " " + c.LastName
}
return c.FirstName
}
// HaveLastName checks what the current user has a LastName.
func (c *Chat) HasLastName() bool {
return c != nil && c.LastName != ""
}
// HaveUsername checks what the current user has a username.
func (c *Chat) HasUsername() bool {
return c != nil && c.Username != ""
}
func (c *Chat) HasDescription() bool {
return c != nil && c.Description != ""
}
func (c *Chat) HasInviteLink() bool {
return c != nil && c.InviteLink != ""
}

View File

@@ -0,0 +1,5 @@
package telegram
func (cir *ChosenInlineResult) HasLocation() bool {
return cir != nil && cir.Location != nil
}

28
vendor/gitlab.com/toby3d/telegram/utils_contact.go generated vendored Normal file
View File

@@ -0,0 +1,28 @@
package telegram
// FullName returns the full name of contact or FirstName if LastName is not
// available.
func (c *Contact) FullName() string {
if c == nil {
return ""
}
if c.HasLastName() {
return c.FirstName + " " + c.LastName
}
return c.FirstName
}
// HaveLastName checks what the current contact has a LastName.
func (c *Contact) HasLastName() bool {
return c != nil && c.LastName != ""
}
func (c *Contact) HasTelegram() bool {
return c != nil && c.UserID != 0
}
func (c *Contact) HasVCard() bool {
return c != nil && c.VCard != ""
}

12
vendor/gitlab.com/toby3d/telegram/utils_document.go generated vendored Normal file
View File

@@ -0,0 +1,12 @@
package telegram
func (d *Document) HasThumb() bool {
return d != nil && d.Thumb != nil
}
func (d *Document) File() *File {
return &File{
FileID: d.FileID,
FileSize: d.FileSize,
}
}

93
vendor/gitlab.com/toby3d/telegram/utils_entity.go generated vendored Normal file
View File

@@ -0,0 +1,93 @@
package telegram
import (
"strings"
http "github.com/valyala/fasthttp"
)
// ParseURL selects URL from entered text of message and parse it as fasthttp.URI.
func (e *MessageEntity) ParseURL(messageText string) *http.URI {
if e == nil || !e.IsURL() || messageText == "" {
return nil
}
from := e.Offset
to := from + e.Length
text := []rune(messageText)
if len(text) < to {
return nil
}
link := http.AcquireURI()
link.Update(string(text[from:to]))
return link
}
// IsBold checks that the current entity is a bold tag.
func (e *MessageEntity) IsBold() bool {
return e != nil && strings.EqualFold(e.Type, EntityBold)
}
// IsBotCommand checks that the current entity is a bot command.
func (e *MessageEntity) IsBotCommand() bool {
return e != nil && strings.EqualFold(e.Type, EntityBotCommand)
}
// IsCode checks that the current entity is a code tag.
func (e *MessageEntity) IsCode() bool {
return e != nil && strings.EqualFold(e.Type, EntityCode)
}
// IsEmail checks that the current entity is a email.
func (e *MessageEntity) IsEmail() bool {
return e != nil && strings.EqualFold(e.Type, EntityEmail)
}
// IsHashtag checks that the current entity is a hashtag.
func (e *MessageEntity) IsHashtag() bool {
return e != nil && strings.EqualFold(e.Type, EntityHashtag)
}
// IsItalic checks that the current entity is a italic tag.
func (e *MessageEntity) IsItalic() bool {
return e != nil && strings.EqualFold(e.Type, EntityItalic)
}
// IsMention checks that the current entity is a username mention.
func (e *MessageEntity) IsMention() bool {
return e != nil && strings.EqualFold(e.Type, EntityMention)
}
// IsPre checks that the current entity is a pre tag.
func (e *MessageEntity) IsPre() bool {
return e != nil && strings.EqualFold(e.Type, EntityPre)
}
// IsTextLink checks that the current entity is a text link.
func (e *MessageEntity) IsTextLink() bool {
return e != nil && strings.EqualFold(e.Type, EntityTextLink)
}
// IsTextMention checks that the current entity is a mention without username.
func (e *MessageEntity) IsTextMention() bool {
return e != nil && strings.EqualFold(e.Type, EntityTextMention)
}
// IsURL checks that the current entity is a URL
func (e *MessageEntity) IsURL() bool {
return e != nil && strings.EqualFold(e.Type, EntityURL)
}
// TextLink parse current text link entity as fasthttp.URI.
func (e *MessageEntity) TextLink() *http.URI {
if e == nil {
return nil
}
link := http.AcquireURI()
link.Update(e.URL)
return link
}

View File

@@ -0,0 +1,70 @@
package telegram
// NewInlineKeyboardMarkup creates a new inline keyboard markup for message.
func NewInlineKeyboardMarkup(rows ...[]InlineKeyboardButton) *InlineKeyboardMarkup {
var keyboard [][]InlineKeyboardButton
keyboard = append(keyboard, rows...)
return &InlineKeyboardMarkup{
InlineKeyboard: keyboard,
}
}
// NewInlineKeyboardRow creates a new inline keyboard row for buttons.
func NewInlineKeyboardRow(buttons ...InlineKeyboardButton) []InlineKeyboardButton {
var row []InlineKeyboardButton
row = append(row, buttons...)
return row
}
// NewInlineKeyboardButton creates a new inline keyboard callback button.
func NewInlineKeyboardButton(text, data string) InlineKeyboardButton {
return InlineKeyboardButton{
Text: text,
CallbackData: data,
}
}
// NewInlineKeyboardButtonURL creates a new inline keyboard button with URL.
func NewInlineKeyboardButtonURL(text, url string) InlineKeyboardButton {
return InlineKeyboardButton{
Text: text,
URL: url,
}
}
// NewInlineKeyboardButtonSwitch creates a new inline keyboard button to make
// specific inline query in other chat.
func NewInlineKeyboardButtonSwitch(text, query string) InlineKeyboardButton {
return InlineKeyboardButton{
Text: text,
SwitchInlineQuery: query,
}
}
// NewInlineKeyboardButtonSwitchSelf creates a new inline keyboard button to make
// specific inline query in same chat.
func NewInlineKeyboardButtonSwitchSelf(text, query string) InlineKeyboardButton {
return InlineKeyboardButton{
Text: text,
SwitchInlineQueryCurrentChat: query,
}
}
// NewInlineKeyboardButtonGame creates a new inline keyboard button with game
// callback.
func NewInlineKeyboardButtonGame(text string) InlineKeyboardButton {
var game CallbackGame
return InlineKeyboardButton{
Text: text,
CallbackGame: &game,
}
}
// NewInlineKeyboardButtonPay creates a new inline keyboard button with pay
// callback.
func NewInlineKeyboardButtonPay(text string) InlineKeyboardButton {
return InlineKeyboardButton{
Text: text,
Pay: true,
}
}

View File

@@ -0,0 +1,16 @@
package telegram
// HasLocation checks what current InlineQuery has Location info.
func (iq *InlineQuery) HasLocation() bool {
return iq != nil && iq.Location != nil
}
// HasOffset checks what current InlineQuery has Offset.
func (iq *InlineQuery) HasOffset() bool {
return iq != nil && iq.Offset != ""
}
// HasQuery checks what current InlineQuery has Query string.
func (iq *InlineQuery) HasQuery() bool {
return iq != nil && iq.Query != ""
}

View File

@@ -0,0 +1,449 @@
package telegram
// NewInlineQueryResultCachedAudio creates a new inline query result with cached
// audio.
func NewInlineQueryResultCachedAudio(resultID, fileID string) *InlineQueryResultCachedAudio {
return &InlineQueryResultCachedAudio{
Type: TypeAudio,
ID: resultID,
AudioFileID: fileID,
}
}
// NewInlineQueryResultCachedDocument creates a new inline query result with
// cached document.
func NewInlineQueryResultCachedDocument(resultID, fileID, title string) *InlineQueryResultCachedDocument {
return &InlineQueryResultCachedDocument{
Type: TypeDocument,
ID: resultID,
Title: title,
DocumentFileID: fileID,
}
}
// NewInlineQueryResultCachedGif creates a new inline query result with cached
// GIF.
func NewInlineQueryResultCachedGif(resultID, fileID string) *InlineQueryResultCachedGif {
return &InlineQueryResultCachedGif{
Type: TypeGIF,
ID: resultID,
GifFileID: fileID,
}
}
// NewInlineQueryResultCachedMpeg4Gif creates a new inline query result with
// cached MPEG GIF.
func NewInlineQueryResultCachedMpeg4Gif(resultID, fileID string) *InlineQueryResultCachedMpeg4Gif {
return &InlineQueryResultCachedMpeg4Gif{
Type: TypeMpeg4Gif,
ID: resultID,
Mpeg4FileID: fileID,
}
}
// NewInlineQueryResultCachedPhoto creates a new inline query result with cached
// photo.
func NewInlineQueryResultCachedPhoto(resultID, fileID string) *InlineQueryResultCachedPhoto {
return &InlineQueryResultCachedPhoto{
Type: TypePhoto,
ID: resultID,
PhotoFileID: fileID,
}
}
// NewInlineQueryResultCachedSticker creates a new inline query result with
// cached sticker.
func NewInlineQueryResultCachedSticker(resultID, fileID string) *InlineQueryResultCachedSticker {
return &InlineQueryResultCachedSticker{
Type: TypeSticker,
ID: resultID,
StickerFileID: fileID,
}
}
// NewInlineQueryResultCachedVideo creates a new inline query result with cached
// video.
func NewInlineQueryResultCachedVideo(resultID, fileID, title string) *InlineQueryResultCachedVideo {
return &InlineQueryResultCachedVideo{
Type: TypeVideo,
ID: resultID,
VideoFileID: fileID,
Title: title,
}
}
// NewInlineQueryResultCachedVoice creates a new inline query result with cached
// voice.
func NewInlineQueryResultCachedVoice(resultID, fileID, title string) *InlineQueryResultCachedVoice {
return &InlineQueryResultCachedVoice{
Type: TypeVoice,
ID: resultID,
VoiceFileID: fileID,
Title: title,
}
}
// NewInlineQueryResultArticle creates a new inline query result with article.
func NewInlineQueryResultArticle(resultID, title string, content interface{}) *InlineQueryResultArticle {
return &InlineQueryResultArticle{
Type: TypeArticle,
ID: resultID,
Title: title,
InputMessageContent: content,
}
}
// NewInlineQueryResultAudio creates a new inline query result with audio.
func NewInlineQueryResultAudio(resultID, audioURL, title string) *InlineQueryResultAudio {
return &InlineQueryResultAudio{
Type: TypeAudio,
ID: resultID,
AudioURL: audioURL,
Title: title,
}
}
// NewInlineQueryResultContact creates a new inline query result with contact.
func NewInlineQueryResultContact(resultID, phoneNumber, firstName string) *InlineQueryResultContact {
return &InlineQueryResultContact{
Type: TypeContact,
ID: resultID,
PhoneNumber: phoneNumber,
FirstName: firstName,
}
}
// NewInlineQueryResultGame creates a new inline query result with game.
func NewInlineQueryResultGame(resultID, gameShortName string) *InlineQueryResultGame {
return &InlineQueryResultGame{
Type: TypeGame,
ID: resultID,
GameShortName: gameShortName,
}
}
// NewInlineQueryResultDocument creates a new inline query result with document.
func NewInlineQueryResultDocument(resultID, title, documentURL, mimeType string) *InlineQueryResultDocument {
return &InlineQueryResultDocument{
Type: TypeDocument,
ID: resultID,
Title: title,
DocumentURL: documentURL,
MimeType: mimeType,
}
}
// NewInlineQueryResultGif creates a new inline query result with GIF.
func NewInlineQueryResultGif(resultID, gifURL, thumbURL string) *InlineQueryResultGif {
return &InlineQueryResultGif{
Type: TypeGIF,
ID: resultID,
GifURL: gifURL,
ThumbURL: thumbURL,
}
}
// NewInlineQueryResultLocation creates a new inline query result with location.
func NewInlineQueryResultLocation(resultID, title string, latitude, longitude float32) *InlineQueryResultLocation {
return &InlineQueryResultLocation{
Type: TypeLocation,
ID: resultID,
Latitude: latitude,
Longitude: longitude,
Title: title,
}
}
// NewInlineQueryResultMpeg4Gif creates a new inline query result with MPEG GIF.
func NewInlineQueryResultMpeg4Gif(resultID, mpeg4URL, thumbURL string) *InlineQueryResultMpeg4Gif {
return &InlineQueryResultMpeg4Gif{
Type: TypeMpeg4Gif,
ID: resultID,
Mpeg4URL: mpeg4URL,
ThumbURL: thumbURL,
}
}
// NewInlineQueryResultPhoto creates a new inline query result with photo.
func NewInlineQueryResultPhoto(resultID, photoURL, thumbURL string) *InlineQueryResultPhoto {
return &InlineQueryResultPhoto{
Type: TypePhoto,
ID: resultID,
PhotoURL: photoURL,
ThumbURL: thumbURL,
}
}
// NewInlineQueryResultVenue creates a new inline query result with venue.
func NewInlineQueryResultVenue(resultID, title, address string, latitude, longitude float32) *InlineQueryResultVenue {
return &InlineQueryResultVenue{
Type: TypeVenue,
ID: resultID,
Latitude: latitude,
Longitude: longitude,
Title: title,
Address: address,
}
}
// NewInlineQueryResultVideo creates a new inline query result with video.
func NewInlineQueryResultVideo(resultID, videoURL, mimeType, thumbURL, title string) *InlineQueryResultVideo {
return &InlineQueryResultVideo{
Type: TypeVideo,
ID: resultID,
VideoURL: videoURL,
MimeType: mimeType,
ThumbURL: thumbURL,
Title: title,
}
}
// NewInlineQueryResultVoice creates a new inline query result with voice.
func NewInlineQueryResultVoice(resultID, voiceURL, title string) *InlineQueryResultVoice {
return &InlineQueryResultVoice{
Type: TypeVoice,
ID: resultID,
VoiceURL: voiceURL,
Title: title,
}
}
func (iqra *InlineQueryResultArticle) ResultID() string {
return iqra.ID
}
func (iqra *InlineQueryResultArticle) ResultType() string {
return iqra.Type
}
func (iqra *InlineQueryResultArticle) ResultReplyMarkup() *InlineKeyboardMarkup {
return iqra.ReplyMarkup
}
func (iqrp *InlineQueryResultPhoto) ResultID() string {
return iqrp.ID
}
func (iqrp *InlineQueryResultPhoto) ResultType() string {
return iqrp.Type
}
func (iqrp *InlineQueryResultPhoto) ResultReplyMarkup() *InlineKeyboardMarkup {
return iqrp.ReplyMarkup
}
func (iqrg *InlineQueryResultGif) ResultID() string {
return iqrg.ID
}
func (iqrg *InlineQueryResultGif) ResultType() string {
return iqrg.Type
}
func (iqrg *InlineQueryResultGif) ResultReplyMarkup() *InlineKeyboardMarkup {
return iqrg.ReplyMarkup
}
func (iqrm4g *InlineQueryResultMpeg4Gif) ResultID() string {
return iqrm4g.ID
}
func (iqrm4g *InlineQueryResultMpeg4Gif) ResultType() string {
return iqrm4g.Type
}
func (iqrm4g *InlineQueryResultMpeg4Gif) ResultReplyMarkup() *InlineKeyboardMarkup {
return iqrm4g.ReplyMarkup
}
func (iqrv *InlineQueryResultVideo) ResultID() string {
return iqrv.ID
}
func (iqrv *InlineQueryResultVideo) ResultType() string {
return iqrv.Type
}
func (iqrv *InlineQueryResultVideo) ResultReplyMarkup() *InlineKeyboardMarkup {
return iqrv.ReplyMarkup
}
func (iqra *InlineQueryResultAudio) ResultID() string {
return iqra.ID
}
func (iqra *InlineQueryResultAudio) ResultType() string {
return iqra.Type
}
func (iqra *InlineQueryResultAudio) ResultReplyMarkup() *InlineKeyboardMarkup {
return iqra.ReplyMarkup
}
func (iqrv *InlineQueryResultVoice) ResultID() string {
return iqrv.ID
}
func (iqrv *InlineQueryResultVoice) ResultType() string {
return iqrv.Type
}
func (iqrv *InlineQueryResultVoice) ResultReplyMarkup() *InlineKeyboardMarkup {
return iqrv.ReplyMarkup
}
func (iqrd *InlineQueryResultDocument) ResultID() string {
return iqrd.ID
}
func (iqrd *InlineQueryResultDocument) ResultType() string {
return iqrd.Type
}
func (iqrd *InlineQueryResultDocument) ResultReplyMarkup() *InlineKeyboardMarkup {
return iqrd.ReplyMarkup
}
func (iqrl *InlineQueryResultLocation) ResultID() string {
return iqrl.ID
}
func (iqrl *InlineQueryResultLocation) ResultType() string {
return iqrl.Type
}
func (iqrl *InlineQueryResultLocation) ResultReplyMarkup() *InlineKeyboardMarkup {
return iqrl.ReplyMarkup
}
func (iqrv *InlineQueryResultVenue) ResultID() string {
return iqrv.ID
}
func (iqrv *InlineQueryResultVenue) ResultType() string {
return iqrv.Type
}
func (iqrv *InlineQueryResultVenue) ResultReplyMarkup() *InlineKeyboardMarkup {
return iqrv.ReplyMarkup
}
func (iqrc *InlineQueryResultContact) ResultID() string {
return iqrc.ID
}
func (iqrc *InlineQueryResultContact) ResultType() string {
return iqrc.Type
}
func (iqrc *InlineQueryResultContact) ResultReplyMarkup() *InlineKeyboardMarkup {
return iqrc.ReplyMarkup
}
func (iqrg *InlineQueryResultGame) ResultID() string {
return iqrg.ID
}
func (iqrg *InlineQueryResultGame) ResultType() string {
return iqrg.Type
}
func (iqrg *InlineQueryResultGame) ResultReplyMarkup() *InlineKeyboardMarkup {
return iqrg.ReplyMarkup
}
func (iqrcp *InlineQueryResultCachedPhoto) ResultID() string {
return iqrcp.ID
}
func (iqrcp *InlineQueryResultCachedPhoto) ResultType() string {
return iqrcp.Type
}
func (iqrcp *InlineQueryResultCachedPhoto) ResultReplyMarkup() *InlineKeyboardMarkup {
return iqrcp.ReplyMarkup
}
func (iqrcg *InlineQueryResultCachedGif) ResultID() string {
return iqrcg.ID
}
func (iqrcg *InlineQueryResultCachedGif) ResultType() string {
return iqrcg.Type
}
func (iqrcg *InlineQueryResultCachedGif) ResultReplyMarkup() *InlineKeyboardMarkup {
return iqrcg.ReplyMarkup
}
func (iqrcm4g *InlineQueryResultCachedMpeg4Gif) ResultID() string {
return iqrcm4g.ID
}
func (iqrcm4g *InlineQueryResultCachedMpeg4Gif) ResultType() string {
return iqrcm4g.Type
}
func (iqrcm4g *InlineQueryResultCachedMpeg4Gif) ResultReplyMarkup() *InlineKeyboardMarkup {
return iqrcm4g.ReplyMarkup
}
func (iqrcs *InlineQueryResultCachedSticker) ResultID() string {
return iqrcs.ID
}
func (iqrcs *InlineQueryResultCachedSticker) ResultType() string {
return iqrcs.Type
}
func (iqrcs *InlineQueryResultCachedSticker) ResultReplyMarkup() *InlineKeyboardMarkup {
return iqrcs.ReplyMarkup
}
func (iqrcd *InlineQueryResultCachedDocument) ResultID() string {
return iqrcd.ID
}
func (iqrcd *InlineQueryResultCachedDocument) ResultType() string {
return iqrcd.Type
}
func (iqrcd *InlineQueryResultCachedDocument) ResultReplyMarkup() *InlineKeyboardMarkup {
return iqrcd.ReplyMarkup
}
func (iqrcv *InlineQueryResultCachedVideo) ResultID() string {
return iqrcv.ID
}
func (iqrcv *InlineQueryResultCachedVideo) ResultType() string {
return iqrcv.Type
}
func (iqrcv *InlineQueryResultCachedVideo) ResultReplyMarkup() *InlineKeyboardMarkup {
return iqrcv.ReplyMarkup
}
func (iqrcv *InlineQueryResultCachedVoice) ResultID() string {
return iqrcv.ID
}
func (iqrcv *InlineQueryResultCachedVoice) ResultType() string {
return iqrcv.Type
}
func (iqrcv *InlineQueryResultCachedVoice) ResultReplyMarkup() *InlineKeyboardMarkup {
return iqrcv.ReplyMarkup
}
func (iqrca *InlineQueryResultCachedAudio) ResultID() string {
return iqrca.ID
}
func (iqrca *InlineQueryResultCachedAudio) ResultType() string {
return iqrca.Type
}
func (iqrca *InlineQueryResultCachedAudio) ResultReplyMarkup() *InlineKeyboardMarkup {
return iqrca.ReplyMarkup
}

50
vendor/gitlab.com/toby3d/telegram/utils_input.go generated vendored Normal file
View File

@@ -0,0 +1,50 @@
package telegram
// NewInputTextMessageContent creates a new text of message.
func NewInputTextMessageContent(messageText string) *InputTextMessageContent {
return &InputTextMessageContent{
MessageText: messageText,
}
}
// NewInputLocationMessageContent creates a new location.
func NewInputLocationMessageContent(latitude, longitude float32) *InputLocationMessageContent {
return &InputLocationMessageContent{
Latitude: latitude,
Longitude: longitude,
}
}
// NewInputVenueMessageContent creates a new venue.
func NewInputVenueMessageContent(latitude, longitude float32, title, address string) *InputVenueMessageContent {
return &InputVenueMessageContent{
Latitude: latitude,
Longitude: longitude,
Title: title,
Address: address,
}
}
// NewInputContactMessageContent creates a new contact.
func NewInputContactMessageContent(phoneNumber, firstName string) *InputContactMessageContent {
return &InputContactMessageContent{
PhoneNumber: phoneNumber,
FirstName: firstName,
}
}
// NewInputMediaPhoto creates a new photo in media album.
func NewInputMediaPhoto(media string) *InputMediaPhoto {
return &InputMediaPhoto{
Type: TypePhoto,
Media: media,
}
}
// NewInputMediaVideo creates a new video in media album.
func NewInputMediaVideo(media string) *InputMediaVideo {
return &InputMediaVideo{
Type: TypeVideo,
Media: media,
}
}

161
vendor/gitlab.com/toby3d/telegram/utils_input_media.go generated vendored Normal file
View File

@@ -0,0 +1,161 @@
package telegram
func (ima *InputMediaAnimation) File() string {
if ima == nil {
return ""
}
return ima.Media
}
func (ima *InputMediaAnimation) InputMediaCaption() string {
if ima == nil {
return ""
}
return ima.Caption
}
func (ima *InputMediaAnimation) InputMediaParseMode() string {
if ima == nil {
return ""
}
return ima.ParseMode
}
func (ima *InputMediaAnimation) InputMediaType() string {
if ima == nil {
return ""
}
return ima.Type
}
func (imd *InputMediaDocument) File() string {
if imd == nil {
return ""
}
return imd.Media
}
func (imd *InputMediaDocument) InputMediaCaption() string {
if imd == nil {
return ""
}
return imd.Caption
}
func (imd *InputMediaDocument) InputMediaParseMode() string {
if imd == nil {
return ""
}
return imd.ParseMode
}
func (imd *InputMediaDocument) InputMediaType() string {
if imd == nil {
return ""
}
return imd.Type
}
func (ima *InputMediaAudio) File() string {
if ima == nil {
return ""
}
return ima.Media
}
func (ima *InputMediaAudio) InputMediaCaption() string {
if ima == nil {
return ""
}
return ima.Caption
}
func (ima *InputMediaAudio) InputMediaParseMode() string {
if ima == nil {
return ""
}
return ima.ParseMode
}
func (ima *InputMediaAudio) InputMediaType() string {
if ima == nil {
return ""
}
return ima.Type
}
func (imp *InputMediaPhoto) File() string {
if imp == nil {
return ""
}
return imp.Media
}
func (imp *InputMediaPhoto) InputMediaCaption() string {
if imp == nil {
return ""
}
return imp.Caption
}
func (imp *InputMediaPhoto) InputMediaParseMode() string {
if imp == nil {
return ""
}
return imp.ParseMode
}
func (imp *InputMediaPhoto) InputMediaType() string {
if imp == nil {
return ""
}
return imp.Type
}
func (imv *InputMediaVideo) File() string {
if imv == nil {
return ""
}
return imv.Media
}
func (imv *InputMediaVideo) InputMediaCaption() string {
if imv == nil {
return ""
}
return imv.Caption
}
func (imv *InputMediaVideo) InputMediaParseMode() string {
if imv == nil {
return ""
}
return imv.ParseMode
}
func (imv *InputMediaVideo) InputMediaType() string {
if imv == nil {
return ""
}
return imv.Type
}

View File

@@ -0,0 +1,9 @@
package telegram
func (itmc *InputTextMessageContent) IsInputMessageContent() bool { return true }
func (ilmc *InputLocationMessageContent) IsInputMessageContent() bool { return true }
func (ivmc *InputVenueMessageContent) IsInputMessageContent() bool { return true }
func (icmc *InputContactMessageContent) IsInputMessageContent() bool { return true }

48
vendor/gitlab.com/toby3d/telegram/utils_keyboard.go generated vendored Normal file
View File

@@ -0,0 +1,48 @@
package telegram
// NewReplyKeyboardRemove just hides keyboard.
func NewReplyKeyboardRemove(selective bool) *ReplyKeyboardRemove {
return &ReplyKeyboardRemove{
RemoveKeyboard: true,
Selective: selective,
}
}
// NewReplyKeyboardMarkup creates new keyboard markup of simple buttons.
func NewReplyKeyboardMarkup(rows ...[]KeyboardButton) *ReplyKeyboardMarkup {
var keyboard [][]KeyboardButton
keyboard = append(keyboard, rows...)
return &ReplyKeyboardMarkup{Keyboard: keyboard}
}
// NewReplyKeyboardRow creates new keyboard row for buttons.
func NewReplyKeyboardRow(buttons ...KeyboardButton) []KeyboardButton {
var row []KeyboardButton
row = append(row, buttons...)
return row
}
// NewReplyKeyboardButton creates new button with custom text for sending it.
func NewReplyKeyboardButton(text string) KeyboardButton {
return KeyboardButton{
Text: text,
}
}
// NewReplyKeyboardButtonContact creates new button with custom text for sending
// user contact.
func NewReplyKeyboardButtonContact(text string) KeyboardButton {
return KeyboardButton{
Text: text,
RequestContact: true,
}
}
// NewReplyKeyboardButtonLocation creates new button with custom text for sending
// user location.
func NewReplyKeyboardButtonLocation(text string) KeyboardButton {
return KeyboardButton{
Text: text,
RequestLocation: true,
}
}

46
vendor/gitlab.com/toby3d/telegram/utils_member.go generated vendored Normal file
View File

@@ -0,0 +1,46 @@
package telegram
import (
"strings"
"time"
)
// IsCreator checks that current member is creator.
func (m *ChatMember) IsCreator() bool {
return m != nil && strings.EqualFold(m.Status, StatusCreator)
}
// IsAdministrator checks that current member is administrator.
func (m *ChatMember) IsAdministrator() bool {
return m != nil && strings.EqualFold(m.Status, StatusAdministrator)
}
// IsMember checks that current member is a m.
func (m *ChatMember) IsMember() bool {
return m != nil && strings.EqualFold(m.Status, StatusMember)
}
// IsRestricted checks that current member has been restricted.
func (m *ChatMember) IsRestricted() bool {
return m != nil && strings.EqualFold(m.Status, StatusRestricted)
}
// IsLeft checks that current member has left the chat.
func (m *ChatMember) IsLeft() bool {
return m != nil && strings.EqualFold(m.Status, StatusLeft)
}
// IsKicked checks that current member has been kicked.
func (m *ChatMember) IsKicked() bool {
return m != nil && strings.EqualFold(m.Status, StatusKicked)
}
// UntilTime parse UntilDate of restrictions and returns time.Time.
func (m *ChatMember) UntilTime() *time.Time {
if m == nil {
return nil
}
ut := time.Unix(m.UntilDate, 0)
return &ut
}

371
vendor/gitlab.com/toby3d/telegram/utils_message.go generated vendored Normal file
View File

@@ -0,0 +1,371 @@
package telegram
import (
"sort"
"strings"
"time"
)
// IsCommand checks that the current message is a bot command.
func (m *Message) IsCommand() bool {
if !m.IsText() || !m.HasEntities() {
return false
}
entity := m.Entities[0]
return entity.IsBotCommand() && entity.Offset == 0
}
// IsCommandEqual checks that the current message is a specific bot command.
func (m *Message) IsCommandEqual(command string) bool {
return m.IsCommand() && strings.EqualFold(m.Command(), command)
}
// Command returns identifier of the bot command without bot username, if it was
// available
func (m *Message) Command() string {
if !m.IsCommand() {
return ""
}
return strings.Split(m.RawCommand(), "@")[0]
}
// RawCommand returns identifier of the bot command with bot username, if it was
// available
func (m *Message) RawCommand() string {
if !m.IsCommand() {
return ""
}
return string([]rune(m.Text)[1:m.Entities[0].Length])
}
// HasCommandArgument checks that the current command message contains argument.
func (m *Message) HasCommandArgument() bool {
if !m.IsCommand() {
return false
}
entity := m.Entities[0]
if !entity.IsBotCommand() {
return false
}
return len([]rune(m.Text)) != entity.Length
}
// CommandArgument returns raw command argument.
func (m *Message) CommandArgument() string {
if !m.HasCommandArgument() {
return ""
}
return string([]rune(m.Text)[m.Entities[0].Length+1:])
}
// IsReply checks that the current message is a reply on other message.
func (m *Message) IsReply() bool {
return m != nil && m.ReplyToMessage != nil
}
// IsForward checks that the current message is a forward of other message.
func (m *Message) IsForward() bool {
return m != nil && m.ForwardFrom != nil
}
// Time parse current message Date and returns time.Time.
func (m *Message) Time() *time.Time {
if m == nil {
return nil
}
t := time.Unix(m.Date, 0)
return &t
}
// ForwardTime parse current message ForwardDate and returns time.Time.
func (m *Message) ForwardTime() *time.Time {
if m == nil {
return nil
}
ft := time.Unix(m.ForwardDate, 0)
return &ft
}
// EditTime parse current message EditDate and returns time.Time.
func (m *Message) EditTime() *time.Time {
if m == nil || !m.HasBeenEdited() {
return nil
}
et := time.Unix(m.EditDate, 0)
return &et
}
// HasBeenEdited checks that the current message has been edited.
func (m *Message) HasBeenEdited() bool {
return m != nil && m.EditDate > 0
}
// IsText checks that the current message is just a text message.
func (m *Message) IsText() bool {
return m != nil && m.Text != ""
}
// IsAudio checks that the current message is a audio.
func (m *Message) IsAudio() bool {
return m != nil && m.Audio != nil
}
// IsDocument checks that the current message is a document.
func (m *Message) IsDocument() bool {
return m != nil && m.Document != nil
}
// IsGame checks that the current message is a game.
func (m *Message) IsGame() bool {
return m != nil && m.Game != nil
}
// IsPhoto checks that the current message is a photo.
func (m *Message) IsPhoto() bool {
return m != nil && len(m.Photo) > 0
}
// IsSticker checks that the current message is a sticker.
func (m *Message) IsSticker() bool {
return m != nil && m.Sticker != nil
}
// IsVideo checks that the current message is a video.
func (m *Message) IsVideo() bool {
return m != nil && m.Video != nil
}
// IsVoice checks that the current message is a voice.
func (m *Message) IsVoice() bool {
return m != nil && m.Voice != nil
}
// IsVideoNote checks that the current message is a video note.
func (m *Message) IsVideoNote() bool {
return m != nil && m.VideoNote != nil
}
// IsContact checks that the current message is a contact.
func (m *Message) IsContact() bool {
return m != nil && m.Contact != nil
}
// IsLocation checks that the current message is a location.
func (m *Message) IsLocation() bool {
return m != nil && m.Location != nil
}
// IsVenue checks that the current message is a venue.
func (m *Message) IsVenue() bool {
return m != nil && m.Venue != nil
}
// IsAnimation checks that the current message is a animation.
func (m *Message) IsAnimation() bool {
return m != nil && m.Animation != nil
}
// IsNewChatMembersEvent checks that the current message is a event of entry of
// new members.
func (m *Message) IsNewChatMembersEvent() bool {
return m != nil && len(m.NewChatMembers) > 0
}
// IsLeftChatMemberEvent checks that the current message is a event of members
// exit.
func (m *Message) IsLeftChatMemberEvent() bool {
return m != nil && m.LeftChatMember != nil
}
// IsNewChatTitleEvent checks that the current message is a event of setting a
// new chat title.
func (m *Message) IsNewChatTitleEvent() bool {
return m != nil && !strings.EqualFold(m.NewChatTitle, "")
}
// IsNewChatPhotoEvent checks that the current message is a event of setting a
// new chat avatar.
func (m *Message) IsNewChatPhotoEvent() bool {
return m != nil && len(m.NewChatPhoto) > 0
}
// IsDeleteChatPhotoEvent checks that the current message is a event of deleting
// a chat avatar.
func (m *Message) IsDeleteChatPhotoEvent() bool {
return m != nil && m.DeleteChatPhoto
}
// IsGroupChatCreatedEvent checks that the current message is a event of creating
// a new group.
func (m *Message) IsGroupChatCreatedEvent() bool {
return m != nil && m.GroupChatCreated
}
// IsSupergroupChatCreatedEvent checks that the current message is a event of
// creating a new supergroup.
func (m *Message) IsSupergroupChatCreatedEvent() bool {
return m != nil && m.SupergroupChatCreated
}
// IsChannelChatCreatedEvent checks that the current message is a event of
// creating a new channel.
func (m *Message) IsChannelChatCreatedEvent() bool {
return m != nil && m.ChannelChatCreated
}
// IsPinnedMessage checks that the current message is a event of pinning another
// message.
func (m *Message) IsPinnedMessage() bool {
return m != nil && m.PinnedMessage != nil
}
// IsInvoice checks that the current message is a invoice.
func (m *Message) IsInvoice() bool {
return m != nil && m.Invoice != nil
}
// IsSuccessfulPayment checks that the current message is a event of successful
// payment.
func (m *Message) IsSuccessfulPayment() bool {
return m != nil && m.SuccessfulPayment != nil
}
// HasEntities checks that the current message contains entities.
func (m *Message) HasEntities() bool {
return m != nil && len(m.Entities) > 0
}
// HasCaptionEntities checks that the current media contains entities in caption.
func (m *Message) HasCaptionEntities() bool {
return m != nil && len(m.CaptionEntities) > 0
}
// HasMentions checks that the current message contains mentions.
func (m *Message) HasMentions() bool {
if !m.HasEntities() {
return false
}
for _, entity := range m.Entities {
if entity.IsMention() || entity.IsTextMention() {
return true
}
}
return false
}
// HasCaptionMentions checks that the current media contains mentions in caption.
func (m *Message) HasCaptionMentions() bool {
if !m.HasCaptionEntities() {
return false
}
for _, entity := range m.CaptionEntities {
if entity.IsMention() || entity.IsTextMention() {
return true
}
}
return false
}
// HasCaption checks that the current media has caption.
func (m *Message) HasCaption() bool {
return m != nil && m.Caption != ""
}
// HasAuthorSignature checks that the current channel post has author signature.
func (m *Message) HasAuthorSignature() bool {
return m != nil && m.AuthorSignature != ""
}
// IsEvent checks what current message is a any chat event.
func (m *Message) IsEvent() bool {
return m.IsChannelChatCreatedEvent() ||
m.IsDeleteChatPhotoEvent() ||
m.IsGroupChatCreatedEvent() ||
m.IsLeftChatMemberEvent() ||
m.IsNewChatMembersEvent() ||
m.IsNewChatTitleEvent() ||
m.IsSupergroupChatCreatedEvent() ||
m.IsNewChatPhotoEvent()
}
func sortPhotos(ps []PhotoSize, reverse bool) []PhotoSize {
buf := make([]PhotoSize, len(ps))
copy(buf, ps)
sort.Slice(buf, func(i, j int) bool {
if reverse {
return buf[i].Width > buf[j].Width &&
buf[i].Height > buf[j].Height
}
return buf[i].Width < buf[j].Width &&
buf[i].Height < buf[j].Height
})
return buf
}
func (m *Message) BigPhoto() *PhotoSize {
if m == nil || !m.IsPhoto() {
return nil
}
if len(m.Photo) == 1 {
return &m.Photo[0]
}
sp := sortPhotos(m.Photo, true)
return &sp[0]
}
func (m *Message) SmallPhoto() *PhotoSize {
if m == nil || !m.IsPhoto() {
return nil
}
if len(m.Photo) == 1 {
return &m.Photo[0]
}
sp := sortPhotos(m.Photo, false)
return &sp[0]
}
func (m *Message) BigChatPhoto() *PhotoSize {
if m == nil || !m.IsNewChatPhotoEvent() {
return nil
}
if len(m.NewChatPhoto) == 1 {
return &m.NewChatPhoto[0]
}
sp := sortPhotos(m.NewChatPhoto, true)
return &sp[0]
}
func (m *Message) SmallChatPhoto() *PhotoSize {
if m == nil || !m.IsNewChatPhotoEvent() {
return nil
}
if len(m.NewChatPhoto) == 1 {
return &m.NewChatPhoto[0]
}
sp := sortPhotos(m.NewChatPhoto, false)
return &sp[0]
}

48
vendor/gitlab.com/toby3d/telegram/utils_sticker.go generated vendored Normal file
View File

@@ -0,0 +1,48 @@
package telegram
// InSet checks that the current sticker in the stickers set.
//
// For uploaded WebP files this return false.
func (s *Sticker) InSet() bool {
return s != nil && s.SetName != ""
}
// IsWebP check that the current sticker is a WebP file uploaded by user.
func (s *Sticker) IsWebP() bool {
return s != nil && s.SetName == ""
}
// Set use bot for getting parent StickerSet if SetName is present.
//
// Return nil if current sticker has been uploaded by user as WebP file.
func (s *Sticker) Set(bot *Bot) *StickerSet {
if s.IsWebP() || bot == nil {
return nil
}
set, err := bot.GetStickerSet(s.SetName)
if err != nil {
return nil
}
return set
}
func (s *Sticker) HasThumb() bool {
return s != nil && s.Thumb != nil
}
func (s *Sticker) IsMask() bool {
return s != nil && s.MaskPosition != nil
}
func (s *Sticker) File() *File {
if s == nil {
return nil
}
return &File{
FileID: s.FileID,
FileSize: s.FileSize,
}
}

170
vendor/gitlab.com/toby3d/telegram/utils_update.go generated vendored Normal file
View File

@@ -0,0 +1,170 @@
package telegram
import (
"bytes"
"log"
"time"
"github.com/kirillDanshin/dlog"
json "github.com/pquerna/ffjson/ffjson"
http "github.com/valyala/fasthttp"
)
// UpdatesChannel is a channel for reading updates of bot.
type UpdatesChannel <-chan Update
// NewLongPollingChannel creates channel for receive incoming updates using long
// polling.
func (b *Bot) NewLongPollingChannel(params *GetUpdatesParameters) UpdatesChannel {
if params == nil {
params = &GetUpdatesParameters{
Offset: 0,
Limit: 100,
Timeout: 60,
}
}
channel := make(chan Update, params.Limit)
go func() {
for {
updates, err := b.GetUpdates(params)
if err != nil {
dlog.Ln(err.Error())
dlog.Ln("Failed to get updates, retrying in 3 seconds...")
time.Sleep(time.Second * 3)
continue
}
for _, update := range updates {
if update.ID >= params.Offset {
params.Offset = update.ID + 1
channel <- update
}
}
}
}()
return channel
}
// NewWebhookChannel creates channel for receive incoming updates via an outgoing
// webhook.
func (b *Bot) NewWebhookChannel(setURL *http.URI, params *SetWebhookParameters, certFile, keyFile, serveAddr string) (updates UpdatesChannel) {
if params == nil {
params = &SetWebhookParameters{
URL: setURL.String(),
MaxConnections: 40,
}
}
var err error
channel := make(chan Update, 100)
handleFunc := func(ctx *http.RequestCtx) {
dlog.Ln("Request path:", string(ctx.Path()))
if !bytes.HasPrefix(ctx.Path(), setURL.Path()) {
dlog.Ln("Unsupported request path:", string(ctx.Path()))
return
}
dlog.Ln("Catched supported request path:", string(ctx.Path()))
var update Update
if err = json.Unmarshal(ctx.Request.Body(), &update); err != nil {
return
}
channel <- update
}
go func() {
if certFile != "" && keyFile != "" {
dlog.Ln("Creating TLS router...")
err = http.ListenAndServeTLS(serveAddr, certFile, keyFile, handleFunc)
} else {
dlog.Ln("Creating simple router...")
err = http.ListenAndServe(serveAddr, handleFunc)
}
if err != nil {
log.Fatalln(err.Error())
}
}()
if _, err = b.SetWebhook(params); err != nil {
log.Fatalln(err.Error())
}
return channel
}
// IsMessage checks that the current update is a message creation event.
func (u *Update) IsMessage() bool {
return u != nil && u.Message != nil
}
// IsEditedMessage checks that the current update is a editing message event.
func (u *Update) IsEditedMessage() bool {
return u != nil && u.EditedMessage != nil
}
// IsChannelPost checks that the current update is a post channel creation event.
func (u *Update) IsChannelPost() bool {
return u != nil && u.ChannelPost != nil
}
// IsEditedChannelPost checks that the current update is a editing post channel
// event.
func (u *Update) IsEditedChannelPost() bool {
return u != nil && u.EditedChannelPost != nil
}
// IsInlineQuery checks that the current update is a inline query update.
func (u *Update) IsInlineQuery() bool {
return u != nil && u.InlineQuery != nil
}
// IsChosenInlineResult checks that the current update is a chosen inline result
// update.
func (u *Update) IsChosenInlineResult() bool {
return u != nil && u.ChosenInlineResult != nil
}
// IsCallbackQuery checks that the current update is a callback query update.
func (u *Update) IsCallbackQuery() bool {
return u != nil && u.CallbackQuery != nil
}
// IsShippingQuery checks that the current update is a shipping query update.
func (u *Update) IsShippingQuery() bool {
return u != nil && u.ShippingQuery != nil
}
// IsPreCheckoutQuery checks that the current update is a pre checkout query
// update.
func (u *Update) IsPreCheckoutQuery() bool {
return u != nil && u.PreCheckoutQuery != nil
}
// Type return update type for current update.
func (u *Update) Type() string {
switch {
case u.IsCallbackQuery():
return UpdateCallbackQuery
case u.IsChannelPost():
return UpdateChannelPost
case u.IsChosenInlineResult():
return UpdateChosenInlineResult
case u.IsEditedChannelPost():
return UpdateEditedChannelPost
case u.IsEditedMessage():
return UpdateEditedMessage
case u.IsInlineQuery():
return UpdateInlineQuery
case u.IsMessage():
return UpdateMessage
case u.IsPreCheckoutQuery():
return UpdatePreCheckoutQuery
case u.IsShippingQuery():
return UpdateShippingQuery
default:
return ""
}
}

49
vendor/gitlab.com/toby3d/telegram/utils_user.go generated vendored Normal file
View File

@@ -0,0 +1,49 @@
package telegram
import (
"golang.org/x/text/language"
"golang.org/x/text/message"
)
// Language parse LanguageCode of current user and returns language.Tag.
func (u *User) Language() language.Tag {
if u == nil {
return language.Und
}
tag, err := language.Parse(u.LanguageCode)
if err != nil {
return language.Und
}
return tag
}
// NewPrinter create simple message.Printer with User.Language() by default.
func (u *User) NewPrinter() *message.Printer {
return message.NewPrinter(u.Language())
}
// FullName returns the full name of user or FirstName if LastName is not
// available.
func (u *User) FullName() string {
if u == nil {
return ""
}
if u.HasLastName() {
return u.FirstName + " " + u.LastName
}
return u.FirstName
}
// HaveLastName checks what the current user has a LastName.
func (u *User) HasLastName() bool {
return u != nil && u.LastName != ""
}
// HaveUsername checks what the current user has a username.
func (u *User) HasUsername() bool {
return u != nil && u.Username != ""
}

16
vendor/gitlab.com/toby3d/telegram/utils_video.go generated vendored Normal file
View File

@@ -0,0 +1,16 @@
package telegram
func (v *Video) HasThumb() bool {
return v != nil && v.Thumb != nil
}
func (v *Video) File() *File {
if v == nil {
return nil
}
return &File{
FileID: v.FileID,
FileSize: v.FileSize,
}
}

16
vendor/gitlab.com/toby3d/telegram/utils_video_note.go generated vendored Normal file
View File

@@ -0,0 +1,16 @@
package telegram
func (vn *VideoNote) HasThumb() bool {
return vn != nil && vn.Thumb != nil
}
func (vn *VideoNote) File() *File {
if vn == nil {
return nil
}
return &File{
FileID: vn.FileID,
FileSize: vn.FileSize,
}
}