types.go (view raw)
1package tgbotapi
2
3import (
4 "encoding/json"
5)
6
7// APIResponse is a response from the Telegram API with the result stored raw.
8type APIResponse struct {
9 Ok bool `json:"ok"`
10 Result json.RawMessage `json:"result"`
11 ErrorCode int `json:"error_code"`
12 Description string `json:"description"`
13}
14
15// Update is an update response, from GetUpdates.
16type Update struct {
17 UpdateID int `json:"update_id"`
18 Message Message `json:"message"`
19}
20
21// User is a user, contained in Message and returned by GetSelf.
22type User struct {
23 ID int `json:"id"`
24 FirstName string `json:"first_name"`
25 LastName string `json:"last_name"`
26 UserName string `json:"username"`
27}
28
29// GroupChat is a group chat, and not currently in use.
30type GroupChat struct {
31 ID int `json:"id"`
32 Title string `json:"title"`
33}
34
35// UserOrGroupChat is returned in Message, because it's not clear which it is.
36type UserOrGroupChat struct {
37 ID int `json:"id"`
38 FirstName string `json:"first_name"`
39 LastName string `json:"last_name"`
40 UserName string `json:"username"`
41 Title string `json:"title"`
42}
43
44// Message is returned by almost every request, and contains data about almost anything.
45type Message struct {
46 MessageID int `json:"message_id"`
47 From User `json:"from"`
48 Date int `json:"date"`
49 Chat UserOrGroupChat `json:"chat"`
50 ForwardFrom User `json:"forward_from"`
51 ForwardDate int `json:"forward_date"`
52 ReplyToMessage *Message `json:"reply_to_message"`
53 Text string `json:"text"`
54 Audio Audio `json:"audio"`
55 Document Document `json:"document"`
56 Photo []PhotoSize `json:"photo"`
57 Sticker Sticker `json:"sticker"`
58 Video Video `json:"video"`
59 Contact Contact `json:"contact"`
60 Location Location `json:"location"`
61 NewChatParticipant User `json:"new_chat_participant"`
62 LeftChatParticipant User `json:"left_chat_participant"`
63 NewChatTitle string `json:"new_chat_title"`
64 NewChatPhoto string `json:"new_chat_photo"`
65 DeleteChatPhoto bool `json:"delete_chat_photo"`
66 GroupChatCreated bool `json:"group_chat_created"`
67}
68
69// PhotoSize contains information about photos, including ID and Width and Height.
70type PhotoSize struct {
71 FileID string `json:"file_id"`
72 Width int `json:"width"`
73 Height int `json:"height"`
74 FileSize int `json:"file_size"`
75}
76
77// Audio contains information about audio, including ID and Duration.
78type Audio struct {
79 FileID string `json:"file_id"`
80 Duration int `json:"duration"`
81 MimeType string `json:"mime_type"`
82 FileSize int `json:"file_size"`
83}
84
85// Document contains information about a document, including ID and a Thumbnail.
86type Document struct {
87 FileID string `json:"file_id"`
88 Thumbnail PhotoSize `json:"thumb"`
89 FileName string `json:"file_name"`
90 MimeType string `json:"mime_type"`
91 FileSize int `json:"file_size"`
92}
93
94// Sticker contains information about a sticker, including ID and Thumbnail.
95type Sticker struct {
96 FileID string `json:"file_id"`
97 Width int `json:"width"`
98 Height int `json:"height"`
99 Thumbnail PhotoSize `json:"thumb"`
100 FileSize int `json:"file_size"`
101}
102
103// Video contains information about a video, including ID and duration and Thumbnail.
104type Video struct {
105 FileID string `json:"file_id"`
106 Width int `json:"width"`
107 Height int `json:"height"`
108 Duration int `json:"duration"`
109 Thumbnail PhotoSize `json:"thumb"`
110 MimeType string `json:"mime_type"`
111 FileSize int `json:"file_size"`
112 Caption string `json:"caption"`
113}
114
115// Contact contains information about a contact, such as PhoneNumber and UserId.
116type Contact struct {
117 PhoneNumber string `json:"phone_number"`
118 FirstName string `json:"first_name"`
119 LastName string `json:"last_name"`
120 UserID string `json:"user_id"`
121}
122
123// Location contains information about a place, such as Longitude and Latitude.
124type Location struct {
125 Longitude float32 `json:"longitude"`
126 Latitude float32 `json:"latitude"`
127}
128
129// UserProfilePhotos contains information a set of user profile photos.
130type UserProfilePhotos struct {
131 TotalCount int `json:"total_count"`
132 Photos []PhotoSize `json:"photos"`
133}
134
135// ReplyKeyboardMarkup allows the Bot to set a custom keyboard.
136type ReplyKeyboardMarkup struct {
137 Keyboard [][]string `json:"keyboard"`
138 ResizeKeyboard bool `json:"resize_keyboard"`
139 OneTimeKeyboard bool `json:"one_time_keyboard"`
140 Selective bool `json:"selective"`
141}
142
143// ReplyKeyboardHide allows the Bot to hide a custom keyboard.
144type ReplyKeyboardHide struct {
145 HideKeyboard bool `json:"hide_keyboard"`
146 Selective bool `json:"selective"`
147}
148
149// ForceReply allows the Bot to have users directly reply to it without additional interaction.
150type ForceReply struct {
151 ForceReply bool `json:"force_reply"`
152 Selective bool `json:"selective"`
153}