Skip to content

Commit 0d6825e

Browse files
authored
Merge pull request #486 from go-telegram-bot-api/bot-api-5.4
Updates for Bot API 5.4
2 parents 309d612 + 04f547b commit 0d6825e

File tree

2 files changed

+90
-5
lines changed

2 files changed

+90
-5
lines changed

configs.go

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const (
2929
// Deprecated: use ChatUploadVoice instead.
3030
ChatUploadAudio = "upload_audio"
3131
ChatUploadDocument = "upload_document"
32+
ChatChooseSticker = "choose_sticker"
3233
ChatFindLocation = "find_location"
3334
ChatRecordVideoNote = "record_video_note"
3435
ChatUploadVideoNote = "upload_video_note"
@@ -1395,8 +1396,10 @@ func (config ChatInviteLinkConfig) params() (Params, error) {
13951396
// RevokeChatInviteLinkConfig.
13961397
type CreateChatInviteLinkConfig struct {
13971398
ChatConfig
1398-
ExpireDate int
1399-
MemberLimit int
1399+
Name string
1400+
ExpireDate int
1401+
MemberLimit int
1402+
CreatesJoinRequest bool
14001403
}
14011404

14021405
func (CreateChatInviteLinkConfig) method() string {
@@ -1406,9 +1409,11 @@ func (CreateChatInviteLinkConfig) method() string {
14061409
func (config CreateChatInviteLinkConfig) params() (Params, error) {
14071410
params := make(Params)
14081411

1412+
params.AddNonEmpty("name", config.Name)
14091413
params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
14101414
params.AddNonZero("expire_date", config.ExpireDate)
14111415
params.AddNonZero("member_limit", config.MemberLimit)
1416+
params.AddBool("creates_join_request", config.CreatesJoinRequest)
14121417

14131418
return params, nil
14141419
}
@@ -1418,9 +1423,11 @@ func (config CreateChatInviteLinkConfig) params() (Params, error) {
14181423
// must have the appropriate admin rights.
14191424
type EditChatInviteLinkConfig struct {
14201425
ChatConfig
1421-
InviteLink string
1422-
ExpireDate int
1423-
MemberLimit int
1426+
InviteLink string
1427+
Name string
1428+
ExpireDate int
1429+
MemberLimit int
1430+
CreatesJoinRequest bool
14241431
}
14251432

14261433
func (EditChatInviteLinkConfig) method() string {
@@ -1431,9 +1438,11 @@ func (config EditChatInviteLinkConfig) params() (Params, error) {
14311438
params := make(Params)
14321439

14331440
params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
1441+
params.AddNonEmpty("name", config.Name)
14341442
params["invite_link"] = config.InviteLink
14351443
params.AddNonZero("expire_date", config.ExpireDate)
14361444
params.AddNonZero("member_limit", config.MemberLimit)
1445+
params.AddBool("creates_join_request", config.CreatesJoinRequest)
14371446

14381447
return params, nil
14391448
}
@@ -1460,6 +1469,44 @@ func (config RevokeChatInviteLinkConfig) params() (Params, error) {
14601469
return params, nil
14611470
}
14621471

1472+
// ApproveChatJoinRequestConfig allows you to approve a chat join request.
1473+
type ApproveChatJoinRequestConfig struct {
1474+
ChatConfig
1475+
UserID int64
1476+
}
1477+
1478+
func (ApproveChatJoinRequestConfig) method() string {
1479+
return "approveChatJoinRequest"
1480+
}
1481+
1482+
func (config ApproveChatJoinRequestConfig) params() (Params, error) {
1483+
params := make(Params)
1484+
1485+
params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
1486+
params.AddNonZero("user_id", int(config.UserID))
1487+
1488+
return params, nil
1489+
}
1490+
1491+
// DeclineChatJoinRequest allows you to decline a chat join request.
1492+
type DeclineChatJoinRequest struct {
1493+
ChatConfig
1494+
UserID int64
1495+
}
1496+
1497+
func (DeclineChatJoinRequest) method() string {
1498+
return "declineChatJoinRequest"
1499+
}
1500+
1501+
func (config DeclineChatJoinRequest) params() (Params, error) {
1502+
params := make(Params)
1503+
1504+
params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
1505+
params.AddNonZero("user_id", int(config.UserID))
1506+
1507+
return params, nil
1508+
}
1509+
14631510
// LeaveChatConfig allows you to leave a chat.
14641511
type LeaveChatConfig struct {
14651512
ChatID int64

types.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,12 @@ type Update struct {
108108
//
109109
// optional
110110
ChatMember *ChatMemberUpdated `json:"chat_member"`
111+
// ChatJoinRequest is a request to join the chat has been sent. The bot must
112+
// have the can_invite_users administrator right in the chat to receive
113+
// these updates.
114+
//
115+
// optional
116+
ChatJoinRequest *ChatJoinRequest `json:"chat_join_request"`
111117
}
112118

113119
// UpdatesChannel is the channel for getting updates.
@@ -1421,10 +1427,19 @@ type ChatInviteLink struct {
14211427
InviteLink string `json:"invite_link"`
14221428
// Creator of the link.
14231429
Creator User `json:"creator"`
1430+
// CreatesJoinRequest is true if users joining the chat via the link need to
1431+
// be approved by chat administrators.
1432+
//
1433+
// optional
1434+
CreatesJoinRequest bool `json:"creates_join_request"`
14241435
// IsPrimary is true, if the link is primary.
14251436
IsPrimary bool `json:"is_primary"`
14261437
// IsRevoked is true, if the link is revoked.
14271438
IsRevoked bool `json:"is_revoked"`
1439+
// Name is the name of the invite link.
1440+
//
1441+
// optional
1442+
Name string `json:"name"`
14281443
// ExpireDate is the point in time (Unix timestamp) when the link will
14291444
// expire or has been expired.
14301445
//
@@ -1435,6 +1450,11 @@ type ChatInviteLink struct {
14351450
//
14361451
// optional
14371452
MemberLimit int `json:"member_limit"`
1453+
// PendingJoinRequestCount is the number of pending join requests created
1454+
// using this link.
1455+
//
1456+
// optional
1457+
PendingJoinRequestCount int `json:"pending_join_request_count"`
14381458
}
14391459

14401460
// ChatMember contains information about one member of a chat.
@@ -1588,6 +1608,24 @@ type ChatMemberUpdated struct {
15881608
InviteLink *ChatInviteLink `json:"invite_link"`
15891609
}
15901610

1611+
// ChatJoinRequest represents a join request sent to a chat.
1612+
type ChatJoinRequest struct {
1613+
// Chat to which the request was sent.
1614+
Chat Chat `json:"chat"`
1615+
// User that sent the join request.
1616+
From User `json:"user"`
1617+
// Date the request was sent in Unix time.
1618+
Date int `json:"date"`
1619+
// Bio of the user.
1620+
//
1621+
// optional
1622+
Bio string `json:"bio"`
1623+
// InviteLink is the link that was used by the user to send the join request.
1624+
//
1625+
// optional
1626+
InviteLink *ChatInviteLink `json:"invite_link"`
1627+
}
1628+
15911629
// ChatPermissions describes actions that a non-administrator user is
15921630
// allowed to take in a chat. All fields are optional.
15931631
type ChatPermissions struct {

0 commit comments

Comments
 (0)