This repository has been archived on 2023-07-05. You can view files and clone it, but cannot push or open issues or pull requests.
clessy/tg/api.go

155 lines
5.4 KiB
Go
Raw Normal View History

2016-02-08 16:52:13 +00:00
package tg
// APIUser represents the "User" JSON structure
2016-02-08 16:52:13 +00:00
type APIUser struct {
2016-09-01 12:05:32 +00:00
UserID int64 `json:"id"`
2016-02-08 16:52:13 +00:00
FirstName string `json:"first_name"`
LastName string `json:"last_name,omitempty"`
Username string `json:"username,omitempty"`
}
// ChatType defines the type of chat
2016-02-08 16:52:13 +00:00
type ChatType string
const (
// ChatTypePrivate is a private chat (between user and bot)
ChatTypePrivate ChatType = "private"
// ChatTypeGroup is a group chat (<100 members)
ChatTypeGroup ChatType = "group"
// ChatTypeSupergroup is a supergroup chat (>=100 members)
2016-02-08 16:52:13 +00:00
ChatTypeSupergroup ChatType = "supergroup"
// ChatTypeChannel is a channel (Read-only)
ChatTypeChannel ChatType = "channel"
2016-02-08 16:52:13 +00:00
)
// APIChat represents the "Chat" JSON structure
2016-02-08 16:52:13 +00:00
type APIChat struct {
2016-09-01 12:05:32 +00:00
ChatID int64 `json:"id"`
2016-02-08 16:52:13 +00:00
Type ChatType `json:"type"`
2016-02-08 16:57:27 +00:00
Title *string `json:"title,omitempty"`
Username *string `json:"username,omitempty"`
FirstName *string `json:"first_name,omitempty"`
LastName *string `json:"last_name,omitempty"`
2016-02-08 16:52:13 +00:00
}
// APIMessage represents the "Message" JSON structure
2016-02-08 16:52:13 +00:00
type APIMessage struct {
2016-09-01 12:05:32 +00:00
MessageID int64 `json:"message_id"`
2016-02-08 16:52:13 +00:00
User APIUser `json:"from"`
2016-09-01 12:05:32 +00:00
Time int64 `json:"date"`
2016-02-08 16:57:27 +00:00
Chat *APIChat `json:"chat"`
FwdUser *APIUpdate `json:"forward_from,omitempty"`
FwdTime *int `json:"forward_date,omitempty"`
ReplyTo *APIMessage `json:"reply_to_message,omitempty"`
Text *string `json:"text,omitempty"`
Audio *APIAudio `json:"audio,omitempty"`
Document *APIDocument `json:"document,omitempty"`
2016-02-08 16:52:13 +00:00
Photo []APIPhotoSize `json:"photo,omitempty"`
2016-02-08 16:57:27 +00:00
Sticker *APISticker `json:"sticker,omitempty"`
Video *APIVideo `json:"video,omitempty"`
Voice *APIVoice `json:"voice,omitempty"`
Caption *string `json:"caption,omitempty"`
Contact *APIContact `json:"contact,omitempty"`
Location *APILocation `json:"location,omitempty"`
NewUser *APIUser `json:"new_chat_partecipant,omitempty"`
2016-02-08 16:57:27 +00:00
LeftUser *APIUser `json:"left_chat_partecipant,omitempty"`
PhotoDeleted *bool `json:"delete_chat_photo,omitempty"`
GroupCreated *bool `json:"group_chat_created,omitempty"`
SupergroupCreated *bool `json:"supergroup_chat_created,omitempty"`
ChannelCreated *bool `json:"channel_chat_created,omitempty"`
2016-09-01 12:05:32 +00:00
GroupToSuper *int64 `json:"migrate_to_chat_id,omitempty"`
GroupFromSuper *int64 `json:"migrate_from_chat_id,omitempty"`
2016-02-08 16:52:13 +00:00
}
// APIPhotoSize represents the "PhotoSize" JSON structure
2016-02-08 16:52:13 +00:00
type APIPhotoSize struct {
FileID string `json:"file_id"`
Width int `json:"width"`
Height int `json:"height"`
2016-02-08 16:57:27 +00:00
FileSize *int `json:"file_size,omitempty"`
2016-02-08 16:52:13 +00:00
}
// APIAudio represents the "Audio" JSON structure
2016-02-08 16:52:13 +00:00
type APIAudio struct {
2016-02-08 16:57:27 +00:00
FileID string `json:"file_id"`
Duration int `json:"duration"`
Performer *string `json:"performer,omitempty"`
Title *string `json:"title,omitempty"`
MimeType *string `json:"mime_type,omitempty"`
FileSize *int `json:"file_size,omitempty"`
2016-02-08 16:52:13 +00:00
}
// APIDocument represents the "Document" JSON structure
2016-02-08 16:52:13 +00:00
type APIDocument struct {
2016-02-08 16:57:27 +00:00
FileID string `json:"file_id"`
Thumbnail *APIPhotoSize `json:"thumb,omitempty"`
Filename string `json:"file_name"`
MimeType *string `json:"mime_type,omitempty"`
FileSize *int `json:"file_size,omitempty"`
2016-02-08 16:52:13 +00:00
}
// APISticker represents the "Sticker" JSON structure
2016-02-08 16:52:13 +00:00
type APISticker struct {
2016-02-08 16:57:27 +00:00
FileID string `json:"file_id"`
Width int `json:"width"`
Height int `json:"height"`
Thumbnail *APIPhotoSize `json:"thumb,omitempty"`
FileSize *int `json:"file_size,omitempty"`
2016-02-08 16:52:13 +00:00
}
// APIVideo represents the "Video" JSON structure
2016-02-08 16:52:13 +00:00
type APIVideo struct {
2016-02-08 16:57:27 +00:00
FileID string `json:"file_id"`
Width int `json:"width"`
Height int `json:"height"`
Duration int `json:"duration"`
Thumbnail *APIPhotoSize `json:"thumb,omitempty"`
MimeType *string `json:"mime_type,omitempty"`
FileSize *int `json:"file_size,omitempty"`
2016-02-08 16:52:13 +00:00
}
// APIVoice represents the "Voice" JSON structure
2016-02-08 16:52:13 +00:00
type APIVoice struct {
2016-02-08 16:57:27 +00:00
FileID string `json:"file_id"`
Duration int `json:"duration"`
MimeType *string `json:"mime_type,omitempty"`
FileSize *int `json:"file_size,omitempty"`
2016-02-08 16:52:13 +00:00
}
// APIContact represents the "Contact" JSON structure
2016-02-08 16:52:13 +00:00
type APIContact struct {
2016-02-08 16:57:27 +00:00
PhoneNumber string `json:"phone_number"`
FirstName string `json:"first_name"`
LastName *string `json:"last_name,omitempty"`
2016-09-01 12:05:32 +00:00
UserID *int64 `json:"user_id,omitempty"`
2016-02-08 16:52:13 +00:00
}
// APILocation represents the "Location" JSON structure
2016-02-08 16:52:13 +00:00
type APILocation struct {
Longitude float64 `json:"longitude"`
Latitude float64 `json:"latitude"`
}
// APIUpdate represents the "Update" JSON structure
2016-02-08 16:52:13 +00:00
type APIUpdate struct {
2016-09-01 12:05:32 +00:00
UpdateID int64 `json:"update_id"`
2016-02-08 16:52:13 +00:00
Message APIMessage `json:"message"`
}
2016-02-08 17:05:46 +00:00
// APIFile represents the "File" JSON structure
type APIFile struct {
FileID string `json:"file_id"`
Size *int `json:"file_size,omitempty"`
Path *string `json:"file_path,omitempty"`
}
// APIResponse represents a response from the Telegram API
2016-02-08 17:05:46 +00:00
type APIResponse struct {
Ok bool `json:"ok"`
ErrCode *int `json:"error_code,omitempty"`
Description *string `json:"description,omitempty"`
}