telebot: refactor bot api 6.3

pull/606/head^2
Demian 12 months ago committed by Demian
parent 5d4079a489
commit d883371ded

@ -10,16 +10,16 @@ import (
type User struct {
ID int64 `json:"id"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
IsForum bool `json:"is_forum"`
Username string `json:"username"`
LanguageCode string `json:"language_code"`
IsBot bool `json:"is_bot"`
IsPremium bool `json:"is_premium"`
AddedToMenu bool `json:"added_to_attachment_menu"`
Usernames []string `json:"active_usernames"`
EmojiStatusCustomEmojiID string `json:"emoji_status_custom_emoji_id"`
FirstName string `json:"first_name"`
LastName string `json:"last_name"`
IsForum bool `json:"is_forum"`
Username string `json:"username"`
LanguageCode string `json:"language_code"`
IsBot bool `json:"is_bot"`
IsPremium bool `json:"is_premium"`
AddedToMenu bool `json:"added_to_attachment_menu"`
Usernames []string `json:"active_usernames"`
CustomEmojiStatusID string `json:"emoji_status_custom_emoji_id"`
// Returns only in getMe
CanJoinGroups bool `json:"can_join_groups"`

@ -62,8 +62,8 @@ type Message struct {
// (Optional) Time of last edit in Unix.
LastEdit int64 `json:"edit_date"`
// (Optional True, if the message is sent to a forum topic
TopicMessage bool `json:"is_topic_message"`
// (Optional) True, if the message is sent to a forum topic.
IsTopicMessage bool `json:"is_topic_message"`
// (Optional) Message can't be forwarded.
Protected bool `json:"has_protected_content,omitempty"`

@ -75,11 +75,11 @@ type SendOptions struct {
// AllowWithoutReply allows sending messages not a as reply if the replied-to message has already been deleted.
AllowWithoutReply bool
// Protected protects the contents of the sent message from forwarding and saving
// Protected protects the contents of sent message from forwarding and saving.
Protected bool
// MessageThreadID supports sending messages to a thread.
MessageThreadID int
// ThreadID supports sending messages to a thread.
ThreadID int
}
func (og *SendOptions) copy() *SendOptions {
@ -191,8 +191,8 @@ func (b *Bot) embedSendOptions(params map[string]string, opt *SendOptions) {
params["protect_content"] = "true"
}
if opt.MessageThreadID != 0 {
params["message_thread_id"] = strconv.Itoa(opt.MessageThreadID)
if opt.ThreadID != 0 {
params["message_thread_id"] = strconv.Itoa(opt.ThreadID)
}
}

@ -9,23 +9,15 @@ type Topic struct {
Name string `json:"name"`
IconColor int `json:"icon_color"`
IconCustomEmojiID string `json:"icon_custom_emoji_id"`
MessageThreadID int `json:"message_thread_id"`
ThreadID int `json:"message_thread_id"`
}
type TopicCreated struct {
Topic
}
type TopicClosed struct{}
type TopicDeleted struct {
Name string `json:"name"`
IconCustomEmojiID string `json:"icon_custom_emoji_id"`
}
type TopicReopened struct {
Topic
}
type (
TopicCreated struct{ Topic }
TopicClosed struct{}
TopicDeleted struct{ Topic }
TopicReopened struct{ Topic }
)
// CreateTopic creates a topic in a forum supergroup chat.
func (b *Bot) CreateTopic(chat *Chat, forum *Topic) error {
@ -49,7 +41,7 @@ func (b *Bot) CreateTopic(chat *Chat, forum *Topic) error {
func (b *Bot) EditTopic(chat *Chat, forum *Topic) error {
params := map[string]interface{}{
"chat_id": chat.Recipient(),
"message_thread_id": forum.MessageThreadID,
"message_thread_id": forum.ThreadID,
}
if forum.Name != "" {
@ -67,7 +59,7 @@ func (b *Bot) EditTopic(chat *Chat, forum *Topic) error {
func (b *Bot) CloseTopic(chat *Chat, forum *Topic) error {
params := map[string]interface{}{
"chat_id": chat.Recipient(),
"message_thread_id": forum.MessageThreadID,
"message_thread_id": forum.ThreadID,
}
_, err := b.Raw("closeForumTopic", params)
@ -78,7 +70,7 @@ func (b *Bot) CloseTopic(chat *Chat, forum *Topic) error {
func (b *Bot) ReopenTopic(chat *Chat, forum *Topic) error {
params := map[string]interface{}{
"chat_id": chat.Recipient(),
"message_thread_id": forum.MessageThreadID,
"message_thread_id": forum.ThreadID,
}
_, err := b.Raw("reopenForumTopic", params)
@ -89,7 +81,7 @@ func (b *Bot) ReopenTopic(chat *Chat, forum *Topic) error {
func (b *Bot) DeleteTopic(chat *Chat, forum *Topic) error {
params := map[string]interface{}{
"chat_id": chat.Recipient(),
"message_thread_id": forum.MessageThreadID,
"message_thread_id": forum.ThreadID,
}
_, err := b.Raw("deleteForumTopic", params)
@ -100,7 +92,7 @@ func (b *Bot) DeleteTopic(chat *Chat, forum *Topic) error {
func (b *Bot) UnpinAllTopicMessages(chat *Chat, forum *Topic) error {
params := map[string]interface{}{
"chat_id": chat.Recipient(),
"message_thread_id": forum.MessageThreadID,
"message_thread_id": forum.ThreadID,
}
_, err := b.Raw("unpinAllForumTopicMessages", params)

Loading…
Cancel
Save