util: fix param type for embedRights

pull/316/head
PiggyMoe 4 years ago
parent b9ba8c4535
commit 2b4e7eeb65
No known key found for this signature in database
GPG Key ID: 4F2DDB9491768DD5

@ -111,7 +111,7 @@ func (b *Bot) Unban(chat *Chat, user *User) error {
func (b *Bot) Restrict(chat *Chat, member *ChatMember) error {
prv, until := member.Rights, member.RestrictedUntil
params := map[string]string{
params := map[string]interface{}{
"chat_id": chat.Recipient(),
"user_id": member.User.Recipient(),
"until_date": strconv.FormatInt(until, 10),
@ -136,7 +136,7 @@ func (b *Bot) Restrict(chat *Chat, member *ChatMember) error {
func (b *Bot) Promote(chat *Chat, member *ChatMember) error {
prv := member.Rights
params := map[string]string{
params := map[string]interface{}{
"chat_id": chat.Recipient(),
"user_id": member.User.Recipient(),
}

@ -1265,7 +1265,7 @@ func (b *Bot) SetGroupStickerSet(chat *Chat, setName string) error {
// SetGroupPermissions sets default chat permissions for all members.
func (b *Bot) SetGroupPermissions(chat *Chat, perms Rights) error {
params := map[string]string{
params := map[string]interface{}{
"chat_id": chat.Recipient(),
}
embedRights(params, perms)

@ -185,7 +185,7 @@ func processButtons(keys [][]InlineButton) {
}
}
func embedRights(p map[string]string, rights Rights) {
func embedRights(p map[string]interface{}, rights Rights) {
data, _ := json.Marshal(rights)
_ = json.Unmarshal(data, &p)
}

@ -26,3 +26,24 @@ func TestExtractMessage(t *testing.T) {
_, err = extractMessage(data)
assert.NoError(t, err)
}
func TestEmbedRights(t *testing.T) {
rights := NoRestrictions()
params := map[string]interface{}{
"chat_id": "1",
"user_id": "2",
}
embedRights(params, rights)
expected := map[string]interface{}{
"chat_id": "1",
"user_id": "2",
"can_be_edited": true,
"can_send_messages": true,
"can_send_media_messages": true,
"can_send_polls": true,
"can_send_other_messages": true,
"can_add_web_page_previews": true,
}
assert.Equal(t, expected, params)
}

Loading…
Cancel
Save