all repos — telegram-bot-api @ 13a8bd025c70a5f1d0700f41c13ea339e073d3d0

Golang bindings for the Telegram Bot API

configs.go (view raw)

  1package tgbotapi
  2
  3import (
  4	"io"
  5	"net/url"
  6)
  7
  8// Telegram constants
  9const (
 10	// APIEndpoint is the endpoint for all API methods, with formatting for Sprintf
 11	APIEndpoint = "https://api.telegram.org/bot%s/%s"
 12	// FileEndpoint is the endpoint for downloading a file from Telegram
 13	FileEndpoint = "https://api.telegram.org/file/bot%s/%s"
 14)
 15
 16// Constant values for ChatActions
 17const (
 18	ChatTyping         = "typing"
 19	ChatUploadPhoto    = "upload_photo"
 20	ChatRecordVideo    = "record_video"
 21	ChatUploadVideo    = "upload_video"
 22	ChatRecordAudio    = "record_audio"
 23	ChatUploadAudio    = "upload_audio"
 24	ChatUploadDocument = "upload_document"
 25	ChatFindLocation   = "find_location"
 26)
 27
 28// API errors
 29const (
 30	// APIForbidden happens when a token is bad
 31	APIForbidden = "forbidden"
 32)
 33
 34// Constant values for ParseMode in MessageConfig
 35const (
 36	ModeMarkdown = "Markdown"
 37)
 38
 39// Base struct for all chat event(Message, Photo and so on)
 40type Chattable struct {
 41	ChatID          int
 42	ChannelUsername string
 43}
 44
 45// MessageConfig contains information about a SendMessage request.
 46type MessageConfig struct {
 47	Chattable
 48	Text                  string
 49	ParseMode             string
 50	DisableWebPagePreview bool
 51	ReplyToMessageID      int
 52	ReplyMarkup           interface{}
 53}
 54
 55// ForwardConfig contains information about a ForwardMessage request.
 56type ForwardConfig struct {
 57	Chattable
 58	FromChatID          int
 59	FromChannelUsername string
 60	MessageID           int
 61}
 62
 63// PhotoConfig contains information about a SendPhoto request.
 64type PhotoConfig struct {
 65	Chattable
 66	Caption          string
 67	ReplyToMessageID int
 68	ReplyMarkup      interface{}
 69	UseExistingPhoto bool
 70	FilePath         string
 71	File             interface{}
 72	FileID           string
 73}
 74
 75// AudioConfig contains information about a SendAudio request.
 76type AudioConfig struct {
 77	Chattable
 78	Duration         int
 79	Performer        string
 80	Title            string
 81	ReplyToMessageID int
 82	ReplyMarkup      interface{}
 83	UseExistingAudio bool
 84	FilePath         string
 85	File             interface{}
 86	FileID           string
 87}
 88
 89// DocumentConfig contains information about a SendDocument request.
 90type DocumentConfig struct {
 91	Chattable
 92	ReplyToMessageID    int
 93	ReplyMarkup         interface{}
 94	UseExistingDocument bool
 95	FilePath            string
 96	File                interface{}
 97	FileID              string
 98}
 99
100// StickerConfig contains information about a SendSticker request.
101type StickerConfig struct {
102	Chattable
103	ReplyToMessageID   int
104	ReplyMarkup        interface{}
105	UseExistingSticker bool
106	FilePath           string
107	File               interface{}
108	FileID             string
109}
110
111// VideoConfig contains information about a SendVideo request.
112type VideoConfig struct {
113	Chattable
114	Duration         int
115	Caption          string
116	ReplyToMessageID int
117	ReplyMarkup      interface{}
118	UseExistingVideo bool
119	FilePath         string
120	File             interface{}
121	FileID           string
122}
123
124// VoiceConfig contains information about a SendVoice request.
125type VoiceConfig struct {
126	Chattable
127	Duration         int
128	ReplyToMessageID int
129	ReplyMarkup      interface{}
130	UseExistingVoice bool
131	FilePath         string
132	File             interface{}
133	FileID           string
134}
135
136// LocationConfig contains information about a SendLocation request.
137type LocationConfig struct {
138	Chattable
139	Latitude         float64
140	Longitude        float64
141	ReplyToMessageID int
142	ReplyMarkup      interface{}
143}
144
145// ChatActionConfig contains information about a SendChatAction request.
146type ChatActionConfig struct {
147	Chattable
148	Action string
149}
150
151// UserProfilePhotosConfig contains information about a GetUserProfilePhotos request.
152type UserProfilePhotosConfig struct {
153	UserID int
154	Offset int
155	Limit  int
156}
157
158// FileConfig has information about a file hosted on Telegram
159type FileConfig struct {
160	FileID string
161}
162
163// UpdateConfig contains information about a GetUpdates request.
164type UpdateConfig struct {
165	Offset  int
166	Limit   int
167	Timeout int
168}
169
170// WebhookConfig contains information about a SetWebhook request.
171type WebhookConfig struct {
172	Clear       bool
173	URL         *url.URL
174	Certificate interface{}
175}
176
177// FileBytes contains information about a set of bytes to upload as a File.
178type FileBytes struct {
179	Name  string
180	Bytes []byte
181}
182
183// FileReader contains information about a reader to upload as a File.
184// If Size is -1, it will read the entire Reader into memory to calculate a Size.
185type FileReader struct {
186	Name   string
187	Reader io.Reader
188	Size   int64
189}