Skip to content

Commit

Permalink
Merge branch 'v2' into v3
Browse files Browse the repository at this point in the history
  • Loading branch information
demget committed Jul 25, 2020
2 parents 5f6792d + bd4747d commit 5a480bd
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 5 deletions.
4 changes: 2 additions & 2 deletions admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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(),
}
Expand Down
2 changes: 1 addition & 1 deletion bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -1203,7 +1203,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)
Expand Down
2 changes: 1 addition & 1 deletion sendable.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,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)

Expand Down
2 changes: 1 addition & 1 deletion util.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,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)
}
Expand Down
21 changes: 21 additions & 0 deletions util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 5a480bd

Please sign in to comment.