commit
f8ef3a5696
6
bot.go
6
bot.go
|
@ -553,13 +553,13 @@ func WriteToHTTPResponse(w http.ResponseWriter, c Chattable) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetChat gets information about a chat.
|
// GetChat gets information about a chat.
|
||||||
func (bot *BotAPI) GetChat(config ChatInfoConfig) (Chat, error) {
|
func (bot *BotAPI) GetChat(config ChatInfoConfig) (ChatFullInfo, error) {
|
||||||
resp, err := bot.Request(config)
|
resp, err := bot.Request(config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return Chat{}, err
|
return ChatFullInfo{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var chat Chat
|
var chat ChatFullInfo
|
||||||
err = json.Unmarshal(resp.Result, &chat)
|
err = json.Unmarshal(resp.Result, &chat)
|
||||||
|
|
||||||
return chat, err
|
return chat, err
|
||||||
|
|
|
@ -933,7 +933,7 @@ func TestUnpinAllChatMessages(t *testing.T) {
|
||||||
func TestPolls(t *testing.T) {
|
func TestPolls(t *testing.T) {
|
||||||
bot, _ := getBot(t)
|
bot, _ := getBot(t)
|
||||||
|
|
||||||
poll := NewPoll(SupergroupChatID, "Are polls working?", "Yes", "No")
|
poll := NewPoll(SupergroupChatID, "Are polls working?", NewPollOption("Yes"), NewPollOption("No"))
|
||||||
|
|
||||||
msg, err := bot.Send(poll)
|
msg, err := bot.Send(poll)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
10
configs.go
10
configs.go
|
@ -829,6 +829,7 @@ type EditMessageLiveLocationConfig struct {
|
||||||
BaseEdit
|
BaseEdit
|
||||||
Latitude float64 // required
|
Latitude float64 // required
|
||||||
Longitude float64 // required
|
Longitude float64 // required
|
||||||
|
LivePeriod int //optional
|
||||||
HorizontalAccuracy float64 // optional
|
HorizontalAccuracy float64 // optional
|
||||||
Heading int // optional
|
Heading int // optional
|
||||||
ProximityAlertRadius int // optional
|
ProximityAlertRadius int // optional
|
||||||
|
@ -841,6 +842,7 @@ func (config EditMessageLiveLocationConfig) params() (Params, error) {
|
||||||
params.AddNonZeroFloat("longitude", config.Longitude)
|
params.AddNonZeroFloat("longitude", config.Longitude)
|
||||||
params.AddNonZeroFloat("horizontal_accuracy", config.HorizontalAccuracy)
|
params.AddNonZeroFloat("horizontal_accuracy", config.HorizontalAccuracy)
|
||||||
params.AddNonZero("heading", config.Heading)
|
params.AddNonZero("heading", config.Heading)
|
||||||
|
params.AddNonZero("live_period", config.LivePeriod)
|
||||||
params.AddNonZero("proximity_alert_radius", config.ProximityAlertRadius)
|
params.AddNonZero("proximity_alert_radius", config.ProximityAlertRadius)
|
||||||
|
|
||||||
return params, err
|
return params, err
|
||||||
|
@ -924,7 +926,9 @@ func (config ContactConfig) method() string {
|
||||||
type SendPollConfig struct {
|
type SendPollConfig struct {
|
||||||
BaseChat
|
BaseChat
|
||||||
Question string
|
Question string
|
||||||
Options []string
|
QuestionParseMode string // optional
|
||||||
|
QuestionEntities []MessageEntity // optional
|
||||||
|
Options []InputPollOption
|
||||||
IsAnonymous bool
|
IsAnonymous bool
|
||||||
Type string
|
Type string
|
||||||
AllowsMultipleAnswers bool
|
AllowsMultipleAnswers bool
|
||||||
|
@ -944,6 +948,10 @@ func (config SendPollConfig) params() (Params, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
params["question"] = config.Question
|
params["question"] = config.Question
|
||||||
|
params.AddNonEmpty("question_parse_mode", config.QuestionParseMode)
|
||||||
|
if err = params.AddInterface("question_entities", config.QuestionEntities); err != nil {
|
||||||
|
return params, err
|
||||||
|
}
|
||||||
if err = params.AddInterface("options", config.Options); err != nil {
|
if err = params.AddInterface("options", config.Options); err != nil {
|
||||||
return params, err
|
return params, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -933,7 +933,7 @@ func NewDeleteChatPhoto(chatID int64) DeleteChatPhotoConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPoll allows you to create a new poll.
|
// NewPoll allows you to create a new poll.
|
||||||
func NewPoll(chatID int64, question string, options ...string) SendPollConfig {
|
func NewPoll(chatID int64, question string, options ...InputPollOption) SendPollConfig {
|
||||||
return SendPollConfig{
|
return SendPollConfig{
|
||||||
BaseChat: BaseChat{
|
BaseChat: BaseChat{
|
||||||
ChatConfig: ChatConfig{ChatID: chatID},
|
ChatConfig: ChatConfig{ChatID: chatID},
|
||||||
|
@ -944,6 +944,13 @@ func NewPoll(chatID int64, question string, options ...string) SendPollConfig {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NewPollOption allows you to create poll option
|
||||||
|
func NewPollOption(text string) InputPollOption {
|
||||||
|
return InputPollOption{
|
||||||
|
Text: text,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// NewStopPoll allows you to stop a poll.
|
// NewStopPoll allows you to stop a poll.
|
||||||
func NewStopPoll(chatID int64, messageID int) StopPollConfig {
|
func NewStopPoll(chatID int64, messageID int) StopPollConfig {
|
||||||
return StopPollConfig{
|
return StopPollConfig{
|
||||||
|
|
124
types.go
124
types.go
|
@ -311,6 +311,11 @@ type Chat struct {
|
||||||
//
|
//
|
||||||
// optional
|
// optional
|
||||||
IsForum bool `json:"is_forum,omitempty"`
|
IsForum bool `json:"is_forum,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ChatFullInfo contains full information about a chat.
|
||||||
|
type ChatFullInfo struct {
|
||||||
|
Chat
|
||||||
// Photo is a chat photo
|
// Photo is a chat photo
|
||||||
Photo *ChatPhoto `json:"photo"`
|
Photo *ChatPhoto `json:"photo"`
|
||||||
// If non-empty, the list of all active chat usernames;
|
// If non-empty, the list of all active chat usernames;
|
||||||
|
@ -355,6 +360,8 @@ type Chat struct {
|
||||||
//
|
//
|
||||||
// optional
|
// optional
|
||||||
AccentColorID int `json:"accent_color_id,omitempty"`
|
AccentColorID int `json:"accent_color_id,omitempty"`
|
||||||
|
// The maximum number of reactions that can be set on a message in the chat
|
||||||
|
MaxReactionCount int `json:"max_reaction_count"`
|
||||||
// BackgroundCustomEmojiID is a custom emoji identifier of emoji chosen by
|
// BackgroundCustomEmojiID is a custom emoji identifier of emoji chosen by
|
||||||
// the chat for the reply header and link preview background.
|
// the chat for the reply header and link preview background.
|
||||||
// Returned only in getChat.
|
// Returned only in getChat.
|
||||||
|
@ -833,6 +840,10 @@ type Message struct {
|
||||||
//
|
//
|
||||||
// optional
|
// optional
|
||||||
BoostAdded *ChatBoostAdded `json:"boost_added,omitempty"`
|
BoostAdded *ChatBoostAdded `json:"boost_added,omitempty"`
|
||||||
|
// Service message: chat background set
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
ChatBackgroundSet *ChatBackground `json:"chat_background_set,omitempty"`
|
||||||
// ForumTopicCreated is a service message: forum topic created
|
// ForumTopicCreated is a service message: forum topic created
|
||||||
//
|
//
|
||||||
// optional
|
// optional
|
||||||
|
@ -1528,10 +1539,31 @@ type Dice struct {
|
||||||
type PollOption struct {
|
type PollOption struct {
|
||||||
// Text is the option text, 1-100 characters
|
// Text is the option text, 1-100 characters
|
||||||
Text string `json:"text"`
|
Text string `json:"text"`
|
||||||
|
// Special entities that appear in the option text.
|
||||||
|
// Currently, only custom emoji entities are allowed in poll option texts
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
TextEntities []MessageEntity `json:"text_entities,omitempty"`
|
||||||
// VoterCount is the number of users that voted for this option
|
// VoterCount is the number of users that voted for this option
|
||||||
VoterCount int `json:"voter_count"`
|
VoterCount int `json:"voter_count"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// InputPollOption contains information about one answer option in a poll to send.
|
||||||
|
type InputPollOption struct {
|
||||||
|
// Option text, 1-100 characters
|
||||||
|
Text string `json:"text"`
|
||||||
|
// Mode for parsing entities in the text. See formatting options for more details.
|
||||||
|
// Currently, only custom emoji entities are allowed
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
TextParseMode string `json:"text_parse_mode,omitempty"`
|
||||||
|
// A JSON-serialized list of special entities that appear in the poll option text.
|
||||||
|
// It can be specified instead of text_parse_mode
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
TextEntities []MessageEntity `json:"text_entities,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
// PollAnswer represents an answer of a user in a non-anonymous poll.
|
// PollAnswer represents an answer of a user in a non-anonymous poll.
|
||||||
type PollAnswer struct {
|
type PollAnswer struct {
|
||||||
// PollID is the unique poll identifier
|
// PollID is the unique poll identifier
|
||||||
|
@ -1557,6 +1589,11 @@ type Poll struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
// Question is the poll question, 1-255 characters
|
// Question is the poll question, 1-255 characters
|
||||||
Question string `json:"question"`
|
Question string `json:"question"`
|
||||||
|
// Special entities that appear in the question.
|
||||||
|
// Currently, only custom emoji entities are allowed in poll questions
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
QuestionEntities []MessageEntity `json:"question_entities,omitempty"`
|
||||||
// Options is the list of poll options
|
// Options is the list of poll options
|
||||||
Options []PollOption `json:"options"`
|
Options []PollOption `json:"options"`
|
||||||
// TotalVoterCount is the total numbers of users who voted in the poll
|
// TotalVoterCount is the total numbers of users who voted in the poll
|
||||||
|
@ -1610,6 +1647,7 @@ type Location struct {
|
||||||
HorizontalAccuracy float64 `json:"horizontal_accuracy,omitempty"`
|
HorizontalAccuracy float64 `json:"horizontal_accuracy,omitempty"`
|
||||||
// LivePeriod is time relative to the message sending date, during which the
|
// LivePeriod is time relative to the message sending date, during which the
|
||||||
// location can be updated, in seconds. For active live locations only.
|
// location can be updated, in seconds. For active live locations only.
|
||||||
|
// Use 0x7FFFFFFF (2147483647 - max positive Int) to edit indefinitely
|
||||||
//
|
//
|
||||||
// optional
|
// optional
|
||||||
LivePeriod int `json:"live_period,omitempty"`
|
LivePeriod int `json:"live_period,omitempty"`
|
||||||
|
@ -1684,6 +1722,86 @@ type ChatBoostAdded struct {
|
||||||
BoostCount int `json:"boost_count"`
|
BoostCount int `json:"boost_count"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BackgroundFill describes the way a background is filled based on the selected colors.
|
||||||
|
// Currently, it can be one of:
|
||||||
|
// - BackgroundFillSolid
|
||||||
|
// - BackgroundFillGradient
|
||||||
|
// - BackgroundFillFreeformGradient
|
||||||
|
type BackgroundFill struct {
|
||||||
|
// Type of the background fill, can be:
|
||||||
|
// - solid
|
||||||
|
// - gradient
|
||||||
|
// - freeform_gradient
|
||||||
|
Type string `json:"type"`
|
||||||
|
// BackgroundFillSolid only.
|
||||||
|
// The color of the background fill in the RGB24 format
|
||||||
|
Color int `json:"color"`
|
||||||
|
// BackgroundFillGradient only.
|
||||||
|
// Top color of the gradient in the RGB24 format
|
||||||
|
TopColor int `json:"top_color"`
|
||||||
|
// BackgroundFillGradient only.
|
||||||
|
// Bottom color of the gradient in the RGB24 format
|
||||||
|
BottomColor int `json:"bottom_color"`
|
||||||
|
// BackgroundFillGradient only.
|
||||||
|
// Clockwise rotation angle of the background fill in degrees; 0-359
|
||||||
|
RotationAngle int `json:"rotation_angle"`
|
||||||
|
// BackgroundFillFreeformGradient only.
|
||||||
|
// A list of the 3 or 4 base colors that are used to generate the freeform gradient in the RGB24 format
|
||||||
|
Colors []int `json:"colors"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// BackgroundType describes the type of a background. Currently, it can be one of:
|
||||||
|
// - BackgroundTypeFill
|
||||||
|
// - BackgroundTypeWallpaper
|
||||||
|
// - BackgroundTypePattern
|
||||||
|
// - BackgroundTypeChatTheme
|
||||||
|
type BackgroundType struct {
|
||||||
|
// Type of the background.
|
||||||
|
// Currently, it can be one of:
|
||||||
|
// - fill
|
||||||
|
// - wallpaper
|
||||||
|
// - pattern
|
||||||
|
// - chat_theme
|
||||||
|
Type string `json:"type"`
|
||||||
|
// BackgroundTypeFill and BackgroundTypePattern only.
|
||||||
|
// The background fill or fill that is combined with the pattern
|
||||||
|
Fill BackgroundFill `json:"fill"`
|
||||||
|
// BackgroundTypeFill and BackgroundTypeWallpaper only.
|
||||||
|
// Dimming of the background in dark themes, as a percentage; 0-100
|
||||||
|
DarkThemeDimming int `json:"dark_theme_dimming"`
|
||||||
|
// BackgroundTypeWallpaper and BackgroundTypePattern only.
|
||||||
|
// Document with the wallpaper / pattern
|
||||||
|
Document Document `json:"document"`
|
||||||
|
// BackgroundTypeWallpaper only.
|
||||||
|
// True, if the wallpaper is downscaled to fit in a 450x450 square and then box-blurred with radius 12
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
IsBlurred bool `json:"is_blurred,omitempty"`
|
||||||
|
// BackgroundTypeWallpaper and BackgroundTypePattern only.
|
||||||
|
// True, if the background moves slightly when the device is tilted
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
IsMoving bool `json:"is_moving,omitempty"`
|
||||||
|
// BackgroundTypePattern only.
|
||||||
|
// Intensity of the pattern when it is shown above the filled background; 0-100
|
||||||
|
Intensity int `json:"intensity"`
|
||||||
|
// BackgroundTypePattern only.
|
||||||
|
// True, if the background fill must be applied only to the pattern itself.
|
||||||
|
// All other pixels are black in this case. For dark themes only
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
IsInverted bool `json:"is_inverted,omitempty"`
|
||||||
|
// BackgroundTypeChatTheme only.
|
||||||
|
// Name of the chat theme, which is usually an emoji
|
||||||
|
ThemeName string `json:"theme_name"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ChatBackground represents a chat background.
|
||||||
|
type ChatBackground struct {
|
||||||
|
// Type of the background
|
||||||
|
Type BackgroundType `json:"type"`
|
||||||
|
}
|
||||||
|
|
||||||
// ForumTopicCreated represents a service message about a new forum topic
|
// ForumTopicCreated represents a service message about a new forum topic
|
||||||
// created in the chat.
|
// created in the chat.
|
||||||
type ForumTopicCreated struct {
|
type ForumTopicCreated struct {
|
||||||
|
@ -2702,6 +2820,12 @@ type ChatMemberUpdated struct {
|
||||||
//
|
//
|
||||||
// optional
|
// optional
|
||||||
InviteLink *ChatInviteLink `json:"invite_link,omitempty"`
|
InviteLink *ChatInviteLink `json:"invite_link,omitempty"`
|
||||||
|
// ViaJoinRequest is true, if the user joined the chat
|
||||||
|
// after sending a direct join request
|
||||||
|
// and being approved by an administrator
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
ViaJoinRequest bool `json:"via_join_request,omitempty"`
|
||||||
// ViaChatFolderInviteLink is True, if the user joined the chat
|
// ViaChatFolderInviteLink is True, if the user joined the chat
|
||||||
// via a chat folder invite link
|
// via a chat folder invite link
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in New Issue