Merge pull request #408 from DiscoreMe/develop

api: support 5.2
pull/425/head
demget 3 years ago committed by Demian
parent e02f9ceb37
commit bd0bb74d13

@ -376,6 +376,11 @@ func (b *Bot) ProcessUpdate(upd Update) {
b.handle(OnAutoDeleteTimer, c)
return
}
if m.VoiceChatSchedule != nil {
b.handle(OnVoiceChatScheduled, c)
return
}
}
if upd.EditedMessage != nil {

@ -35,6 +35,9 @@ type Query struct {
// Offset of the results to be returned, can be controlled by the bot.
Offset string `json:"offset"`
// ChatType of the type of the chat, from which the inline query was sent.
ChatType string `json:"chat_type"`
}
// QueryResponse builds a response to an inline Query.

@ -221,6 +221,8 @@ type Message struct {
// Inline keyboard attached to the message.
ReplyMarkup InlineKeyboardMarkup `json:"reply_markup"`
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"`

@ -74,13 +74,16 @@ type Invoice struct {
PhotoSize int `json:"photo_size"`
// Unique deep-linking parameter that can be used to
// generate this invoice when used as a start parameter.
// generate this invoice when used as a start parameter (0).
Start string `json:"start_parameter"`
// Shows the total price in the smallest units of the currency.
// For example, for a price of US$ 1.45 pass amount = 145.
Total int `json:"total_amount"`
MaxTipAmount int `json:"max_tip_amount"`
SuggestedTipAmounts []int `json:"suggested_tip_amounts"`
NeedName bool `json:"need_name"`
NeedPhoneNumber bool `json:"need_phone_number"`
NeedEmail bool `json:"need_email"`

@ -5,6 +5,7 @@ import (
"fmt"
"path/filepath"
"strconv"
"strings"
)
// Recipient is any possible endpoint you can send
@ -317,6 +318,7 @@ func (i *Invoice) Send(b *Bot, to Recipient, opt *SendOptions) (*Message, error)
"payload": i.Payload,
"provider_token": i.Token,
"currency": i.Currency,
"max_tip_amount": strconv.Itoa(i.MaxTipAmount),
"need_name": strconv.FormatBool(i.NeedName),
"need_phone_number": strconv.FormatBool(i.NeedPhoneNumber),
"need_email": strconv.FormatBool(i.NeedEmail),
@ -343,6 +345,9 @@ func (i *Invoice) Send(b *Bot, to Recipient, opt *SendOptions) (*Message, error)
data, _ := json.Marshal(i.Prices)
params["prices"] = string(data)
}
if len(i.SuggestedTipAmounts) > 0 {
params["suggested_tip_amounts"] = "[" + strings.Join(intsToStrs(i.SuggestedTipAmounts), ",") + "]"
}
b.embedSendOptions(params, opt)
data, err := b.Raw("sendInvoice", params)

@ -156,6 +156,11 @@ const (
//
// Handler: func(*Message)
OnAutoDeleteTimer = "\amessage_auto_delete_timer_changed"
// Will fire on OnVoiceChatScheduled
//
// Handler: func(*Message)
OnVoiceChatScheduled = "\avoice_chat_scheduled"
)
// ChatAction is a client-side status indicating bot activity.

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

@ -1,5 +1,7 @@
package telebot
import "time"
// VoiceChatStarted represents a service message about a voice chat
// started in the chat.
type VoiceChatStarted struct{}
@ -7,7 +9,7 @@ type VoiceChatStarted struct{}
// VoiceChatEnded represents a service message about a voice chat
// ended in the chat.
type VoiceChatEnded struct {
Duration int `json:"duration"`
Duration int `json:"duration"` // in seconds
}
// VoiceChatParticipants represents a service message about new
@ -15,3 +17,13 @@ type VoiceChatEnded struct {
type VoiceChatParticipants struct {
Users []User `json:"users"`
}
// VoiceChatScheduled represents a service message about a voice chat scheduled in the chat.
type VoiceChatScheduled struct {
Unixtime int64 `json:"start_date"`
}
// StartsAt returns the point when the voice chat is supposed to be started by a chat administrator.
func (v *VoiceChatScheduled) StartsAt() time.Time {
return time.Unix(v.Unixtime, 0)
}
Loading…
Cancel
Save