telebot: some fixes

This commit is contained in:
Nikita 2021-05-24 13:04:06 +03:00
parent 6684383594
commit 2d4921e1ea
4 changed files with 10 additions and 10 deletions

View File

@ -221,7 +221,7 @@ type Message struct {
// Inline keyboard attached to the message.
ReplyMarkup InlineKeyboardMarkup `json:"reply_markup"`
VoiceChatSchedule *VoiceChatSchedule `json:"voice_chat_scheduled,omitempty"`
VoiceChatSchedule *VoiceChatScheduled `json:"voice_chat_scheduled,omitempty"`
// For a service message, a voice chat started in the chat.
VoiceChatStarted *VoiceChatStarted `json:"voice_chat_started,omitempty"`

View File

@ -5,6 +5,7 @@ import (
"fmt"
"path/filepath"
"strconv"
"strings"
)
// Recipient is any possible endpoint you can send
@ -345,7 +346,7 @@ func (i *Invoice) Send(b *Bot, to Recipient, opt *SendOptions) (*Message, error)
params["prices"] = string(data)
}
if len(i.SuggestedTipAmounts) > 0 {
params["suggested_tip_amounts"] = sliceIntToString(i.SuggestedTipAmounts)
params["suggested_tip_amounts"] = "[" + strings.Join(intsToStrs(i.SuggestedTipAmounts), ",") + "]"
}
b.embedSendOptions(params, opt)

View File

@ -252,10 +252,9 @@ func isUserInList(user *User, list []User) bool {
return false
}
func sliceIntToString(ns []int) (s string) {
func intsToStrs(ns []int) (s []string) {
for _, n := range ns {
s += strconv.Itoa(n) + ","
s = append(s, strconv.Itoa(n))
}
s = s[:len(s)-1]
return
}

View File

@ -18,12 +18,12 @@ type VoiceChatParticipantsInvited struct {
Users []User `json:"users"`
}
// VoiceChatSchedule represents a service message about a voice chat scheduled in the chat.
type VoiceChatSchedule struct {
StartUnixTime int64 `json:"start_date"`
// VoiceChatScheduled represents a service message about a voice chat scheduled in the chat.
type VoiceChatScheduled struct {
Unixtime int64 `json:"start_date"`
}
// ExpireDate returns the point when the voice chat is supposed to be started by a chat administrator.
func (v *VoiceChatSchedule) ExpireDate() time.Time {
return time.Unix(v.StartUnixTime, 0)
func (v *VoiceChatScheduled) ExpireDate() time.Time {
return time.Unix(v.Unixtime, 0)
}