Merge branch 'v2' into v3

pull/341/head
Demian 4 years ago
commit 5a480bd291

@ -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(),
}

@ -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)

@ -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)

@ -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)
}

@ -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