forked from tucnak/telebot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
chat.go
110 lines (91 loc) · 3.22 KB
/
chat.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
package telebot
import "strconv"
// User object represents a Telegram user, bot.
type User struct {
ID int `json:"id"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
Username string `json:"username"`
LanguageCode string `json:"language_code"`
IsBot bool `json:"is_bot"`
// Returns only in getMe
CanJoinGroups bool `json:"can_join_groups"`
CanReadMessages bool `json:"can_read_all_group_messages"`
SupportsInline bool `json:"supports_inline_queries"`
}
// Recipient returns user ID (see Recipient interface).
func (u *User) Recipient() string {
return strconv.Itoa(u.ID)
}
// Chat object represents a Telegram user, bot, group or a channel.
type Chat struct {
ID int64 `json:"id"`
// See ChatType and consts.
Type ChatType `json:"type"`
// Won't be there for ChatPrivate.
Title string `json:"title"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
Username string `json:"username"`
// Still shows whether the user is a member
// of the chat at the moment of the request.
Still bool `json:"is_member,omitempty"`
// Returns only in getChat
Photo *ChatPhoto `json:"photo,omitempty"`
Description string `json:"description,omitempty"`
InviteLink string `json:"invite_link,omitempty"`
PinnedMessage *Message `json:"pinned_message,omitempty"`
Permissions *Rights `json:"permissions,omitempty"`
SlowMode int `json:"slow_mode_delay,omitempty"`
StickerSet string `json:"sticker_set_name,omitempty"`
CanSetStickerSet bool `json:"can_set_sticker_set,omitempty"`
}
// ChatPhoto object represents a chat photo.
type ChatPhoto struct {
// File identifiers of small (160x160) chat photo
SmallFileID string `json:"small_file_id"`
SmallFileUniqueID string `json:"small_file_unique_id"`
// File identifiers of big (640x640) chat photo
BigFileID string `json:"big_file_id"`
BigFileUniqueID string `json:"big_file_unique_id"`
}
// Recipient returns chat ID (see Recipient interface).
func (c *Chat) Recipient() string {
return strconv.FormatInt(c.ID, 10)
}
// ChatMember object represents information about a single chat member.
type ChatMember struct {
Rights
User *User `json:"user"`
Role MemberStatus `json:"status"`
Title string `json:"custom_title"`
// Date when restrictions will be lifted for the user, unix time.
//
// If user is restricted for more than 366 days or less than
// 30 seconds from the current time, they are considered to be
// restricted forever.
//
// Use tb.Forever().
//
RestrictedUntil int64 `json:"until_date,omitempty"`
}
// ChatID represents a chat or an user integer ID, which can be used
// as recipient in bot methods. It is very useful in cases where
// you have special group IDs, for example in your config, and don't
// want to wrap it into *tb.Chat every time you send messages.
//
// Example:
//
// group := tb.ChatID(-100756389456)
// b.Send(group, "Hello!")
//
// type Config struct {
// AdminGroup tb.ChatID `json:"admin_group"`
// }
// b.Send(conf.AdminGroup, "Hello!")
//
type ChatID int64
// Recipient returns chat ID (see Recipient interface).
func (i ChatID) Recipient() string {
return strconv.FormatInt(int64(i), 10)
}