Skip to content

Latest commit

 

History

History
95 lines (82 loc) · 5.1 KB

File metadata and controls

95 lines (82 loc) · 5.1 KB

Changelog

All notable changes to this project are documented here. The format is based on Keep a Changelog, and the project aims to follow Semantic Versioning. Commit messages follow Conventional Commits.

Fixed

  • Targeted commands — a command addressed to another bot (/cmd@other_bot, as clients send in groups) no longer matches. Command/OnCommand now match an untargeted command, or one whose @username is this bot's own.

Changed

  • Logging port — the library now logs through github.com/gotd/log instead of zap directly. Options.Logger and Bot.Logger() (and pool.Options.Logger) are now log.Logger. Breaking: wrap a *zap.Logger with github.com/gotd/log/logzap.New (or a *slog.Logger with logslog.New). The library no longer depends on zap.

Added

  • storage.Open/Close — a one-call opener that creates (or reuses) a bbolt-backed Storage and owns the database, so persisting a session is storage.Open("bot.bbolt") plus a deferred Close. Every example now persists its session by default.
  • Rich messages (Bot API 10.1) — SendRichMessage/SendRichHTML/ SendRichMarkdown send structured page-block content built with github.com/gotd/td/telegram/message/rich. The examples/rich bot showcases the page-block and rich-text constructors valid in a bot-sent message. (Instant-View-page-only constructors are rejected by the server with RICH_VALIDATE_CTOR_NOT_ALLOWED: page blocks Title, Subtitle, Header, Subheader, Kicker, AuthorDate, Cover, RelatedArticles; and inline styles Mention, Hashtag, Cashtag, BotCommand, BankCard, AutoURL/AutoEmail/AutoPhone.)
  • Background sendsBot.Background() / Context.Background() expose a run-lifetime context for proactive sends to any chat from timers, queues or goroutines, instead of the per-update handler context. Plus Bot.Logger().
  • Serializable peer referencesBot.PeerRef captures a chat's id and access hash into a JSON-serializable PeerRef; Peer(ref) addresses it directly (no stored peer data, no re-resolution), so background/scheduled sends survive a restart. The new examples/background bot persists subscriber PeerRefs to a JSON file and re-greets them after a restart.

0.1.0 - 2026-06-14

botapi was rebuilt from a codegen-first OpenAPI/ogen project into a hand-written, MTProto-backed Bot API library built on gotd/td. It exposes the familiar Bot API surface but speaks MTProto directly — no api.telegram.org, no getUpdates/webhooks.

Added

  • ClientBot with New/Run/Raw, a persistent MTProto connection and gap-aware update stream. Optional bbolt Storage for session/peers/state.
  • Types — hand-written Bot API types and sealed-interface unions (ChatID, InputFile, ReplyMarkup, InputMedia, ChatMember, MessageOrigin, InlineQueryResult, InputMessageContent, BotCommandScope, PassportElementError, …) with compile-time exhaustiveness checks.
  • SendingSendMessage (HTML/MarkdownV2/Markdown), photo/document/video/ audio/voice/animation/video-note/sticker, media groups, location/venue/ contact/poll/dice, chat actions; edits (text/caption/markup/media, live location), forward/copy/delete, StopPoll.
  • Receiving — a handler framework (On*, predicates, middleware, Group, Context) over the native update stream; messages, edits, channel posts, callback/inline queries, shipping/pre-checkout queries; incoming media, polls, contacts and forward origins mapped to the typed Message.
  • FilesGetFile, DownloadFile/DownloadFileToPath, local file_unique_id derivation.
  • QueriesAnswerCallbackQuery, AnswerInlineQuery, AnswerShippingQuery, AnswerPreCheckoutQuery.
  • Chat management — members (ban/unban/restrict/promote, get member(s)/ admins/count, custom title), admin (pin/unpin, title/description/photo/ permissions, sticker set, leave), invite links, GetChat, GetUserProfilePhotos.
  • CommandsSet/Get/DeleteMyCommands with scopes; OnCommand auto-publishes the command menu.
  • StickersUploadStickerFile, sticker-set create/add/delete/reorder, GetStickerSet, SetStickerSetThumb.
  • Payments & gamesSendInvoice, SetPassportDataErrors, SendGame, SetGameScore, GetGameHighScores.
  • Resilience — Bot-API-shaped errors with a comprehensive tgerr mapping and AsFloodWait/AsChatMigrated/Code helpers; opt-in flood-wait retry and a proactive rate limiter.
  • Multi-botpool.Pool runs and multiplexes many bots by token with idle GC.
  • Tooling & docscmd/botdoc (fetch/inspect the published API), a method-drift conformance test, hot-path benchmarks, package docs, a usage guide and runnable examples (echo, buttons, inline, media, advanced).