Skip to content

Telebot V3.2

Latest
Compare
Choose a tag to compare
@demget demget released this 20 Nov 13:53
· 25 commits to v3 since this release

Changelog

  • Bot API 6.3, 6.4, 6.5
  • Group's forum topics support
  • Other minor fixes and improvements

Bot API 6.3, 6.4: Topics

// 1. Create a forum topic with specified settings
topic, err := b.CreateTopic(chat, &tele.Topic{Name: "Discussions"})
if err != nil {
  return err
}

// 2. Use topic methods
b.CloseTopic(chat, topic)
b.ReopenTopic(chat, topic)
b.DeleteTopic(chat, topic)
b.HideGeneralTopic(chat)
b.UnhideGeneralTopic(chat)
...

// 3. Handle topics-related events
b.Handle(tele.OnTopicCreated, func(c tele.Context) error {
  topic := c.Topic()
  topic.Name
  topic.ThreadID
})

Bot API 6.5: ReplyRecipient

// 1. Use a ReplyRecipient constructor for both
// `request_user` and `request_chat` params
var (
  replyUser = &tele.ReplyRecipient{
    ID:      1, // unique
    Bot:     tele.Flag(false),
    Premium: tele.Flag(true),
  }
  replyChat = &tele.ReplyRecipient{
    ID:       1,     // unique
    Channel:  false, // required
    Username: tele.Flag(true),
  }
)

markup := &tele.ReplyMarkup{}
markup.Reply(
  markup.Row(markup.User(replyUser)),
  markup.Row(markup.Chat(replyChat)),
)

b.Send(to, "Share with me...", markup)

// 2. Handle the shared user or chat
b.Handle(tele.OnUserShared, func(c tele.Context) error {
  user := c.Message().UserShared
  log.Println("Shared user ID:", user.UserID)
})

Use a Flag helper that returns a pointer to the given bool:

// Flag returns a pointer to the given bool.
// Useful for passing the three-state flags to a Bot API.
// For example, see ReplyRecipient type.
func Flag(b bool) *bool {
  return &b
}

Fixes and Improvements

  • Bot.SetWebhook error is loggable by default (#559)
  • telebot/layout fixes (7065335, 4c17ca7)
  • Fixed the middleware applying for groups (#588)
  • More errors (#570, 699e5db)
  • Added missed is_member field to the ChatMember (#615)
  • Added missed custom_emoji_id field to the Sticker (#579)
  • Fixed Results.MarshalJSON addressing inside for-loop (#589)

Discussion

Discuss on Telegram