forked from gotd/botapi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchat_join.go
More file actions
42 lines (34 loc) · 1.13 KB
/
Copy pathchat_join.go
File metadata and controls
42 lines (34 loc) · 1.13 KB
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
package botapi
import (
"context"
"github.com/gotd/td/tg"
)
// hideJoinRequest approves or declines a pending join request for a chat.
func (b *Bot) hideJoinRequest(ctx context.Context, chat ChatID, userID int64, approved bool) error {
peer, err := b.resolveInputPeer(ctx, chat)
if err != nil {
return err
}
user, err := b.resolveInputUser(ctx, userID)
if err != nil {
return err
}
if _, err := b.raw.MessagesHideChatJoinRequest(ctx, &tg.MessagesHideChatJoinRequestRequest{
Approved: approved,
Peer: peer,
UserID: user,
}); err != nil {
return asAPIError(err)
}
return nil
}
// ApproveChatJoinRequest approves a chat join request. The bot must be an
// administrator with the can_invite_users right.
func (b *Bot) ApproveChatJoinRequest(ctx context.Context, chat ChatID, userID int64) error {
return b.hideJoinRequest(ctx, chat, userID, true)
}
// DeclineChatJoinRequest declines a chat join request. The bot must be an
// administrator with the can_invite_users right.
func (b *Bot) DeclineChatJoinRequest(ctx context.Context, chat ChatID, userID int64) error {
return b.hideJoinRequest(ctx, chat, userID, false)
}