commit
26b0a55fe2
163
configs.go
163
configs.go
|
@ -265,6 +265,7 @@ func (CloseConfig) params() (Params, error) {
|
||||||
// BaseChat is base type for all chat config types.
|
// BaseChat is base type for all chat config types.
|
||||||
type BaseChat struct {
|
type BaseChat struct {
|
||||||
ChatID int64 // required
|
ChatID int64 // required
|
||||||
|
MessageThreadID int
|
||||||
ChannelUsername string
|
ChannelUsername string
|
||||||
ProtectContent bool
|
ProtectContent bool
|
||||||
ReplyToMessageID int
|
ReplyToMessageID int
|
||||||
|
@ -277,6 +278,7 @@ func (chat *BaseChat) params() (Params, error) {
|
||||||
params := make(Params)
|
params := make(Params)
|
||||||
|
|
||||||
params.AddFirstValid("chat_id", chat.ChatID, chat.ChannelUsername)
|
params.AddFirstValid("chat_id", chat.ChatID, chat.ChannelUsername)
|
||||||
|
params.AddNonZero("message_thread_id", chat.MessageThreadID)
|
||||||
params.AddNonZero("reply_to_message_id", chat.ReplyToMessageID)
|
params.AddNonZero("reply_to_message_id", chat.ReplyToMessageID)
|
||||||
params.AddBool("disable_notification", chat.DisableNotification)
|
params.AddBool("disable_notification", chat.DisableNotification)
|
||||||
params.AddBool("allow_sending_without_reply", chat.AllowSendingWithoutReply)
|
params.AddBool("allow_sending_without_reply", chat.AllowSendingWithoutReply)
|
||||||
|
@ -1385,6 +1387,7 @@ type PromoteChatMemberConfig struct {
|
||||||
CanRestrictMembers bool
|
CanRestrictMembers bool
|
||||||
CanPinMessages bool
|
CanPinMessages bool
|
||||||
CanPromoteMembers bool
|
CanPromoteMembers bool
|
||||||
|
CanManageTopics bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (config PromoteChatMemberConfig) method() string {
|
func (config PromoteChatMemberConfig) method() string {
|
||||||
|
@ -1408,6 +1411,7 @@ func (config PromoteChatMemberConfig) params() (Params, error) {
|
||||||
params.AddBool("can_restrict_members", config.CanRestrictMembers)
|
params.AddBool("can_restrict_members", config.CanRestrictMembers)
|
||||||
params.AddBool("can_pin_messages", config.CanPinMessages)
|
params.AddBool("can_pin_messages", config.CanPinMessages)
|
||||||
params.AddBool("can_promote_members", config.CanPromoteMembers)
|
params.AddBool("can_promote_members", config.CanPromoteMembers)
|
||||||
|
params.AddBool("can_manage_topics", config.CanManageTopics)
|
||||||
|
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
@ -2298,16 +2302,158 @@ func (config DeleteChatStickerSetConfig) params() (Params, error) {
|
||||||
return params, nil
|
return params, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetForumTopicIconStickersConfig allows you to get custom emoji stickers,
|
||||||
|
// which can be used as a forum topic icon by any user.
|
||||||
|
type GetForumTopicIconStickersConfig struct{}
|
||||||
|
|
||||||
|
func (config GetForumTopicIconStickersConfig) method() string {
|
||||||
|
return "getForumTopicIconStickers"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (config GetForumTopicIconStickersConfig) params() (Params, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateForumTopicConfig allows you to create a topic
|
||||||
|
// in a forum supergroup chat.
|
||||||
|
type CreateForumTopicConfig struct {
|
||||||
|
ChatID int64
|
||||||
|
Name string
|
||||||
|
IconColor int
|
||||||
|
IconCustomEmojiID string
|
||||||
|
SuperGroupUsername string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (config CreateForumTopicConfig) method() string {
|
||||||
|
return "createForumTopic"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (config CreateForumTopicConfig) params() (Params, error) {
|
||||||
|
params := make(Params)
|
||||||
|
|
||||||
|
params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
|
||||||
|
params.AddNonEmpty("name", config.Name)
|
||||||
|
params.AddNonZero("icon_color", config.IconColor)
|
||||||
|
params.AddNonEmpty("icon_custom_emoji_id", config.IconCustomEmojiID)
|
||||||
|
|
||||||
|
return params, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// EditForumTopicConfig allows you to edit
|
||||||
|
// name and icon of a topic in a forum supergroup chat.
|
||||||
|
type EditForumTopicConfig struct {
|
||||||
|
ChatID int64
|
||||||
|
MessageThreadID int
|
||||||
|
Name string
|
||||||
|
IconCustomEmojiID string
|
||||||
|
SuperGroupUsername string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (config EditForumTopicConfig) method() string {
|
||||||
|
return "editForumTopic"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (config EditForumTopicConfig) params() (Params, error) {
|
||||||
|
params := make(Params)
|
||||||
|
|
||||||
|
params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
|
||||||
|
params.AddNonZero("message_thread_id", config.MessageThreadID)
|
||||||
|
params.AddNonEmpty("icon_color", config.Name)
|
||||||
|
params.AddNonEmpty("icon_custom_emoji_id", config.IconCustomEmojiID)
|
||||||
|
|
||||||
|
return params, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CloseForumTopicConfig allows you to close
|
||||||
|
// an open topic in a forum supergroup chat.
|
||||||
|
type CloseForumTopicConfig struct {
|
||||||
|
ChatID int64
|
||||||
|
MessageThreadID int
|
||||||
|
SuperGroupUsername string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (config CloseForumTopicConfig) method() string {
|
||||||
|
return "closeForumTopic"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (config CloseForumTopicConfig) params() (Params, error) {
|
||||||
|
params := make(Params)
|
||||||
|
|
||||||
|
params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
|
||||||
|
params.AddNonZero("message_thread_id", config.MessageThreadID)
|
||||||
|
|
||||||
|
return params, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReopenForumTopicConfig allows you to reopen
|
||||||
|
// an closed topic in a forum supergroup chat.
|
||||||
|
type ReopenForumTopicConfig struct {
|
||||||
|
ChatID int64
|
||||||
|
MessageThreadID int
|
||||||
|
SuperGroupUsername string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (config ReopenForumTopicConfig) method() string {
|
||||||
|
return "reopenForumTopic"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (config ReopenForumTopicConfig) params() (Params, error) {
|
||||||
|
params := make(Params)
|
||||||
|
|
||||||
|
params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
|
||||||
|
params.AddNonZero("message_thread_id", config.MessageThreadID)
|
||||||
|
|
||||||
|
return params, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteForumTopicConfig allows you to delete a forum topic
|
||||||
|
// along with all its messages in a forum supergroup chat.
|
||||||
|
type DeleteForumTopicConfig struct {
|
||||||
|
ChatID int64
|
||||||
|
MessageThreadID int
|
||||||
|
SuperGroupUsername string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (config DeleteForumTopicConfig) method() string {
|
||||||
|
return "deleteForumTopic"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (config DeleteForumTopicConfig) params() (Params, error) {
|
||||||
|
params := make(Params)
|
||||||
|
|
||||||
|
params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
|
||||||
|
params.AddNonZero("message_thread_id", config.MessageThreadID)
|
||||||
|
|
||||||
|
return params, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnpinAllForumTopicMessagesConfig allows you to clear the list
|
||||||
|
// of pinned messages in a forum topic.
|
||||||
|
type UnpinAllForumTopicMessagesConfig struct {
|
||||||
|
ChatID int64
|
||||||
|
MessageThreadID int
|
||||||
|
SuperGroupUsername string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (config UnpinAllForumTopicMessagesConfig) method() string {
|
||||||
|
return "unpinAllForumTopicMessages"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (config UnpinAllForumTopicMessagesConfig) params() (Params, error) {
|
||||||
|
params := make(Params)
|
||||||
|
|
||||||
|
params.AddFirstValid("chat_id", config.ChatID, config.SuperGroupUsername)
|
||||||
|
params.AddNonZero("message_thread_id", config.MessageThreadID)
|
||||||
|
|
||||||
|
return params, nil
|
||||||
|
}
|
||||||
|
|
||||||
// MediaGroupConfig allows you to send a group of media.
|
// MediaGroupConfig allows you to send a group of media.
|
||||||
//
|
//
|
||||||
// Media consist of InputMedia items (InputMediaPhoto, InputMediaVideo).
|
// Media consist of InputMedia items (InputMediaPhoto, InputMediaVideo).
|
||||||
type MediaGroupConfig struct {
|
type MediaGroupConfig struct {
|
||||||
ChatID int64
|
BaseChat
|
||||||
ChannelUsername string
|
|
||||||
|
|
||||||
Media []interface{}
|
Media []interface{}
|
||||||
DisableNotification bool
|
|
||||||
ReplyToMessageID int
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (config MediaGroupConfig) method() string {
|
func (config MediaGroupConfig) method() string {
|
||||||
|
@ -2315,13 +2461,16 @@ func (config MediaGroupConfig) method() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (config MediaGroupConfig) params() (Params, error) {
|
func (config MediaGroupConfig) params() (Params, error) {
|
||||||
params := make(Params)
|
params, err := config.BaseChat.params()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
params.AddFirstValid("chat_id", config.ChatID, config.ChannelUsername)
|
params.AddFirstValid("chat_id", config.ChatID, config.ChannelUsername)
|
||||||
params.AddBool("disable_notification", config.DisableNotification)
|
params.AddBool("disable_notification", config.DisableNotification)
|
||||||
params.AddNonZero("reply_to_message_id", config.ReplyToMessageID)
|
params.AddNonZero("reply_to_message_id", config.ReplyToMessageID)
|
||||||
|
|
||||||
err := params.AddInterface("media", prepareInputMediaForParams(config.Media))
|
err = params.AddInterface("media", prepareInputMediaForParams(config.Media))
|
||||||
|
|
||||||
return params, err
|
return params, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,7 +178,9 @@ func NewVoice(chatID int64, file RequestFileData) VoiceConfig {
|
||||||
// two to ten InputMediaPhoto or InputMediaVideo.
|
// two to ten InputMediaPhoto or InputMediaVideo.
|
||||||
func NewMediaGroup(chatID int64, files []interface{}) MediaGroupConfig {
|
func NewMediaGroup(chatID int64, files []interface{}) MediaGroupConfig {
|
||||||
return MediaGroupConfig{
|
return MediaGroupConfig{
|
||||||
|
BaseChat: BaseChat{
|
||||||
ChatID: chatID,
|
ChatID: chatID,
|
||||||
|
},
|
||||||
Media: files,
|
Media: files,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
86
types.go
86
types.go
|
@ -265,8 +265,22 @@ type Chat struct {
|
||||||
//
|
//
|
||||||
// optional
|
// optional
|
||||||
LastName string `json:"last_name,omitempty"`
|
LastName string `json:"last_name,omitempty"`
|
||||||
|
// IsForum is true if the supergroup chat is a forum (has topics enabled)
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
IsForum bool `json:"is_forum,omitempty"`
|
||||||
// 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;
|
||||||
|
// for private chats, supergroups and channels. Returned only in getChat.
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
ActiveUsernames []string `json:"active_usernames,omitempty"`
|
||||||
|
// Custom emoji identifier of emoji status of the other party
|
||||||
|
// in a private chat. Returned only in getChat.
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
EmojiStatusCustomEmojiID string `json:"emoji_status_custom_emoji_id,omitempty"`
|
||||||
// Bio is the bio of the other party in a private chat. Returned only in
|
// Bio is the bio of the other party in a private chat. Returned only in
|
||||||
// getChat
|
// getChat
|
||||||
//
|
//
|
||||||
|
@ -383,6 +397,11 @@ func (c Chat) ChatConfig() ChatConfig {
|
||||||
type Message struct {
|
type Message struct {
|
||||||
// MessageID is a unique message identifier inside this chat
|
// MessageID is a unique message identifier inside this chat
|
||||||
MessageID int `json:"message_id"`
|
MessageID int `json:"message_id"`
|
||||||
|
// Unique identifier of a message thread to which the message belongs;
|
||||||
|
// for supergroups only
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
MessageThreadID int `json:"message_thread_id,omitempty"`
|
||||||
// From is a sender, empty for messages sent to channels;
|
// From is a sender, empty for messages sent to channels;
|
||||||
//
|
//
|
||||||
// optional
|
// optional
|
||||||
|
@ -426,6 +445,10 @@ type Message struct {
|
||||||
//
|
//
|
||||||
// optional
|
// optional
|
||||||
ForwardDate int `json:"forward_date,omitempty"`
|
ForwardDate int `json:"forward_date,omitempty"`
|
||||||
|
// IsTopicMessage true if the message is sent to a forum topic
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
IsTopicMessage bool `json:"is_topic_message,omitempty"`
|
||||||
// IsAutomaticForward is true if the message is a channel post that was
|
// IsAutomaticForward is true if the message is a channel post that was
|
||||||
// automatically forwarded to the connected discussion group.
|
// automatically forwarded to the connected discussion group.
|
||||||
//
|
//
|
||||||
|
@ -630,6 +653,18 @@ type Message struct {
|
||||||
//
|
//
|
||||||
// optional
|
// optional
|
||||||
ProximityAlertTriggered *ProximityAlertTriggered `json:"proximity_alert_triggered,omitempty"`
|
ProximityAlertTriggered *ProximityAlertTriggered `json:"proximity_alert_triggered,omitempty"`
|
||||||
|
// ForumTopicCreated is a service message: forum topic created
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
ForumTopicCreated *ForumTopicCreated `json:"forum_topic_created,omitempty"`
|
||||||
|
// ForumTopicClosed is a service message: forum topic closed
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
ForumTopicClosed *ForumTopicClosed `json:"forum_topic_closed,omitempty"`
|
||||||
|
// ForumTopicReopened is a service message: forum topic reopened
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
ForumTopicReopened *ForumTopicReopened `json:"forum_topic_reopened,omitempty"`
|
||||||
// VideoChatScheduled is a service message: video chat scheduled.
|
// VideoChatScheduled is a service message: video chat scheduled.
|
||||||
//
|
//
|
||||||
// optional
|
// optional
|
||||||
|
@ -1208,6 +1243,30 @@ type MessageAutoDeleteTimerChanged struct {
|
||||||
MessageAutoDeleteTime int `json:"message_auto_delete_time"`
|
MessageAutoDeleteTime int `json:"message_auto_delete_time"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ForumTopicCreated represents a service message about a new forum topic
|
||||||
|
// created in the chat.
|
||||||
|
type ForumTopicCreated struct {
|
||||||
|
// Name is the name of topic
|
||||||
|
Name string `json:"name"`
|
||||||
|
// IconColor is the color of the topic icon in RGB format
|
||||||
|
IconColor int `json:"icon_color"`
|
||||||
|
// IconCustomEmojiID is the unique identifier of the custom emoji
|
||||||
|
// shown as the topic icon
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
IconCustomEmojiID string `json:"icon_custom_emoji_id,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ForumTopicClosed represents a service message about a forum topic
|
||||||
|
// closed in the chat. Currently holds no information.
|
||||||
|
type ForumTopicClosed struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
// ForumTopicReopened represents a service message about a forum topic
|
||||||
|
// reopened in the chat. Currently holds no information.
|
||||||
|
type ForumTopicReopened struct {
|
||||||
|
}
|
||||||
|
|
||||||
// VideoChatScheduled represents a service message about a voice chat scheduled
|
// VideoChatScheduled represents a service message about a voice chat scheduled
|
||||||
// in the chat.
|
// in the chat.
|
||||||
type VideoChatScheduled struct {
|
type VideoChatScheduled struct {
|
||||||
|
@ -1618,6 +1677,7 @@ type ChatAdministratorRights struct {
|
||||||
CanPostMessages bool `json:"can_post_messages"`
|
CanPostMessages bool `json:"can_post_messages"`
|
||||||
CanEditMessages bool `json:"can_edit_messages"`
|
CanEditMessages bool `json:"can_edit_messages"`
|
||||||
CanPinMessages bool `json:"can_pin_messages"`
|
CanPinMessages bool `json:"can_pin_messages"`
|
||||||
|
CanManageTopics bool `json:"can_manage_topics"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChatMember contains information about one member of a chat.
|
// ChatMember contains information about one member of a chat.
|
||||||
|
@ -1710,6 +1770,12 @@ type ChatMember struct {
|
||||||
//
|
//
|
||||||
// optional
|
// optional
|
||||||
CanPinMessages bool `json:"can_pin_messages,omitempty"`
|
CanPinMessages bool `json:"can_pin_messages,omitempty"`
|
||||||
|
// CanManageTopics administrators and restricted only.
|
||||||
|
// True, if the user is allowed to create, rename,
|
||||||
|
// close, and reopen forum topics; supergroups only
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
CanManageTopics bool `json:"can_manage_topics,omitempty"`
|
||||||
// IsMember is true, if the user is a member of the chat at the moment of
|
// IsMember is true, if the user is a member of the chat at the moment of
|
||||||
// the request
|
// the request
|
||||||
IsMember bool `json:"is_member"`
|
IsMember bool `json:"is_member"`
|
||||||
|
@ -1833,6 +1899,11 @@ type ChatPermissions struct {
|
||||||
//
|
//
|
||||||
// optional
|
// optional
|
||||||
CanPinMessages bool `json:"can_pin_messages,omitempty"`
|
CanPinMessages bool `json:"can_pin_messages,omitempty"`
|
||||||
|
// CanManageTopics is true, if the user is allowed to create forum topics.
|
||||||
|
// If omitted defaults to the value of can_pin_messages
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
CanManageTopics bool `json:"can_manage_topics,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChatLocation represents a location to which a chat is connected.
|
// ChatLocation represents a location to which a chat is connected.
|
||||||
|
@ -1845,6 +1916,21 @@ type ChatLocation struct {
|
||||||
Address string `json:"address"`
|
Address string `json:"address"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ForumTopic represents a forum topic.
|
||||||
|
type ForumTopic struct {
|
||||||
|
// MessageThreadID is the unique identifier of the forum topic
|
||||||
|
MessageThreadID int `json:"message_thread_id"`
|
||||||
|
// Name is the name of the topic
|
||||||
|
Name string `json:"name"`
|
||||||
|
// IconColor is the color of the topic icon in RGB format
|
||||||
|
IconColor int `json:"icon_color"`
|
||||||
|
// IconCustomEmojiID is the unique identifier of the custom emoji
|
||||||
|
// shown as the topic icon
|
||||||
|
//
|
||||||
|
// optional
|
||||||
|
IconCustomEmojiID string `json:"icon_custom_emoji_id,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
// BotCommand represents a bot command.
|
// BotCommand represents a bot command.
|
||||||
type BotCommand struct {
|
type BotCommand struct {
|
||||||
// Command text of the command, 1-32 characters.
|
// Command text of the command, 1-32 characters.
|
||||||
|
|
Loading…
Reference in New Issue