From 2b4e7eeb65b146745244a0ce04eff6b05d76abc4 Mon Sep 17 00:00:00 2001 From: PiggyMoe Date: Wed, 24 Jun 2020 09:07:53 +0800 Subject: [PATCH 1/2] util: fix param type for embedRights --- admin.go | 4 ++-- bot.go | 2 +- util.go | 2 +- util_test.go | 21 +++++++++++++++++++++ 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/admin.go b/admin.go index 1236b8d..d0be6ab 100644 --- a/admin.go +++ b/admin.go @@ -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(), } diff --git a/bot.go b/bot.go index 13c6c41..4933dba 100644 --- a/bot.go +++ b/bot.go @@ -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) diff --git a/util.go b/util.go index ba81e1a..5b50302 100644 --- a/util.go +++ b/util.go @@ -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) } diff --git a/util_test.go b/util_test.go index 0837dec..78f6991 100644 --- a/util_test.go +++ b/util_test.go @@ -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) +} From a3f6efa6f2856157139e4248b08740fc7ef6758e Mon Sep 17 00:00:00 2001 From: Ian Patrick Badtrousers Date: Fri, 3 Jul 2020 17:10:51 +0200 Subject: [PATCH 2/2] html5 games 400 hotfix --- sendable.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sendable.go b/sendable.go index 0f18abe..fc6bad0 100644 --- a/sendable.go +++ b/sendable.go @@ -389,7 +389,7 @@ func (d *Dice) Send(b *Bot, to Recipient, opt *SendOptions) (*Message, error) { func (g *Game) Send(b *Bot, to Recipient, opt *SendOptions) (*Message, error) { params := map[string]string{ "chat_id": to.Recipient(), - "game_short_name": g.Title, + "game_short_name": g.Name, } b.embedSendOptions(params, opt)