2015-06-27 15:44:12 +00:00
|
|
|
package telebot
|
|
|
|
|
2015-10-16 22:36:07 +00:00
|
|
|
// Recipient is basically any possible endpoint you can send
|
|
|
|
// messages to. It's usually a distinct user or a chat.
|
|
|
|
type Recipient interface {
|
|
|
|
// Basically, ID of the endpoint.
|
|
|
|
Destination() int
|
|
|
|
}
|
|
|
|
|
2015-10-16 16:36:20 +00:00
|
|
|
// User object represents a Telegram user, bot
|
2015-07-06 16:58:54 +00:00
|
|
|
//
|
|
|
|
// object represents a group chat if Title is empty.
|
2015-06-27 15:44:12 +00:00
|
|
|
type User struct {
|
2015-07-06 16:27:10 +00:00
|
|
|
ID int `json:"id"`
|
2015-06-27 15:44:12 +00:00
|
|
|
FirstName string `json:"first_name"`
|
2015-10-16 16:36:20 +00:00
|
|
|
|
|
|
|
LastName string `json:"last_name"`
|
|
|
|
Username string `json:"username"`
|
|
|
|
}
|
|
|
|
|
2015-10-16 22:36:07 +00:00
|
|
|
// Destination is internal user ID.
|
|
|
|
func (u User) Destination() int {
|
|
|
|
return u.ID
|
|
|
|
}
|
|
|
|
|
2015-10-16 16:36:20 +00:00
|
|
|
// Chat object represents a Telegram user, bot or group chat.
|
|
|
|
// Title for channels and group chats
|
|
|
|
// Type of chat, can be either “private”, or “group”, or “channel”
|
|
|
|
type Chat struct {
|
|
|
|
ID int `json:"id"`
|
|
|
|
Type string `json:"type"`
|
|
|
|
|
|
|
|
Title string `json:"title"`
|
|
|
|
FirstName string `json:"first_name"`
|
2015-06-27 15:44:12 +00:00
|
|
|
LastName string `json:"last_name"`
|
|
|
|
Username string `json:"username"`
|
|
|
|
}
|
|
|
|
|
2015-10-16 22:36:07 +00:00
|
|
|
// Destination is internal chat ID.
|
|
|
|
func (c Chat) Destination() int {
|
|
|
|
return c.ID
|
|
|
|
}
|
|
|
|
|
2015-10-16 16:36:20 +00:00
|
|
|
// IsGroupChat returns true if chat object represents a group chat.
|
2015-10-16 22:36:07 +00:00
|
|
|
func (c Chat) IsGroupChat() bool {
|
|
|
|
return c.Type == "group"
|
2015-07-06 16:58:54 +00:00
|
|
|
}
|
|
|
|
|
2015-06-27 15:44:12 +00:00
|
|
|
// Update object represents an incoming update.
|
|
|
|
type Update struct {
|
2015-07-06 16:27:10 +00:00
|
|
|
ID int `json:"update_id"`
|
2015-06-27 15:44:12 +00:00
|
|
|
Payload Message `json:"message"`
|
|
|
|
}
|
2015-06-27 17:37:22 +00:00
|
|
|
|
|
|
|
// Thumbnail object represents a image/sticker of particular size.
|
|
|
|
type Thumbnail struct {
|
|
|
|
File
|
|
|
|
|
|
|
|
Width int `json:"width"`
|
|
|
|
Height int `json:"height"`
|
|
|
|
}
|
|
|
|
|
2015-07-02 18:39:39 +00:00
|
|
|
// Photo object represents a photo with caption.
|
|
|
|
type Photo struct {
|
|
|
|
Thumbnail
|
|
|
|
|
|
|
|
Caption string
|
|
|
|
}
|
|
|
|
|
2015-06-27 17:37:22 +00:00
|
|
|
// Audio object represents an audio file (voice note).
|
|
|
|
type Audio struct {
|
|
|
|
File
|
|
|
|
|
|
|
|
// Duration of the recording in seconds as defined by sender.
|
|
|
|
Duration int `json:"duration"`
|
|
|
|
|
|
|
|
// MIME type of the file as defined by sender.
|
|
|
|
Mime string `json:"mime_type"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// Document object represents a general file (as opposed to Photo or Audio).
|
|
|
|
// Telegram users can send files of any type of up to 1.5 GB in size.
|
|
|
|
type Document struct {
|
|
|
|
File
|
|
|
|
|
|
|
|
// Document thumbnail as defined by sender.
|
|
|
|
Preview Thumbnail `json:"thumb"`
|
|
|
|
|
|
|
|
// Original filename as defined by sender.
|
|
|
|
FileName string `json:"file_name"`
|
|
|
|
|
|
|
|
// MIME type of the file as defined by sender.
|
|
|
|
Mime string `json:"mime_type"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// Sticker object represents a WebP image, so-called sticker.
|
|
|
|
type Sticker struct {
|
|
|
|
File
|
|
|
|
|
|
|
|
Width int `json:"width"`
|
|
|
|
Height int `json:"height"`
|
|
|
|
|
|
|
|
// Sticker thumbnail in .webp or .jpg format.
|
|
|
|
Preview Thumbnail `json:"thumb"`
|
|
|
|
}
|
|
|
|
|
2015-07-03 18:54:40 +00:00
|
|
|
// Video object represents an MP4-encoded video.
|
2015-06-27 17:37:22 +00:00
|
|
|
type Video struct {
|
|
|
|
Audio
|
|
|
|
|
|
|
|
Width int `json:"width"`
|
|
|
|
Height int `json:"height"`
|
|
|
|
|
|
|
|
// Text description of the video as defined by sender (usually empty).
|
|
|
|
Caption string `json:"caption"`
|
|
|
|
|
|
|
|
// Video thumbnail.
|
|
|
|
Preview Thumbnail `json:"thumb"`
|
|
|
|
}
|
|
|
|
|
2015-07-03 18:54:40 +00:00
|
|
|
// Contact object represents a contact to Telegram user
|
2015-06-27 17:37:22 +00:00
|
|
|
type Contact struct {
|
|
|
|
PhoneNumber string `json:"phone_number"`
|
|
|
|
FirstName string `json:"first_name"`
|
|
|
|
LastName string `json:"last_name"`
|
|
|
|
|
|
|
|
// Contact's username in Telegram (might be empty).
|
|
|
|
Username string `json:"user_id"`
|
|
|
|
}
|
|
|
|
|
2015-07-03 18:54:40 +00:00
|
|
|
// Location object represents geographic position.
|
2015-06-27 17:37:22 +00:00
|
|
|
type Location struct {
|
|
|
|
Longitude float32 `json:"longitude"`
|
|
|
|
Latitude float32 `json:"latitude"`
|
|
|
|
}
|