Skip to content

Commit 1615493

Browse files
authored
Merge pull request #57 from yanzay/restrict-permissions
User new ChatPermissions for RestrictChatMember.
2 parents e9d198e + 0606e72 commit 1615493

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

client.go

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,26 +1025,16 @@ func (c *Client) UnbanChatMember(chatID string, userID int) error {
10251025
return c.doRequest("unbanChatMember", req, &unbanned)
10261026
}
10271027

1028-
// Restrictions for user in supergroup
1029-
type Restrictions struct {
1030-
CanSendMessages bool
1031-
CanSendMediaMessages bool
1032-
CanSendOtherMessages bool
1033-
CanAddWebPagePreviews bool
1034-
}
1035-
10361028
/*
10371029
RestrictChatMember restrict a user in a supergroup. Available options:
10381030
- OptUntilDate(date time.Time)
10391031
*/
1040-
func (c *Client) RestrictChatMember(chatID string, userID int, r *Restrictions, opts ...sendOption) error {
1032+
func (c *Client) RestrictChatMember(chatID string, userID int, perm *ChatPermissions, opts ...sendOption) error {
10411033
req := url.Values{}
10421034
req.Set("chat_id", chatID)
10431035
req.Set("user_id", fmt.Sprint(userID))
1044-
req.Set("can_send_messages", fmt.Sprint(r.CanSendMessages))
1045-
req.Set("can_send_media_messages", fmt.Sprint(r.CanSendMediaMessages))
1046-
req.Set("can_send_other_messages", fmt.Sprint(r.CanSendOtherMessages))
1047-
req.Set("can_add_web_page_previews", fmt.Sprint(r.CanAddWebPagePreviews))
1036+
marshalledPermissions, _ := json.Marshal(perm)
1037+
req.Set("permissions", string(marshalledPermissions))
10481038
for _, opt := range opts {
10491039
opt(req)
10501040
}

0 commit comments

Comments
 (0)