Repository navigation
v0.2.0-alpha.1
Pre-release
Pre-release
·
1 commit
to main
since this release
Added
- Albums, live photos and replies from other chats are decoded.
Message
gainedMediaGroupID,LivePhoto,ExternalReplyandHasMediaSpoiler, with
the types behind them:LivePhoto,ExternalReplyInfo,MessageOriginand
theOrigin*constants. Telegram sends every item of an album as its own
update, andMediaGroupIDis what ties them together. A live photo fills
Photoas well asLivePhoto, so a bot that sorts attachments checks
LivePhotofirst, as it does withAnimationbeforeDocument. A reply to a
message in another chat or another topic arrives inExternalReply, not in
ReplyToMessage.ExternalReplyInfomodels the attachments and the origin;
the rest of the object is inMessage.Raw. The Bot API version stays at 10.3:
live photos are from 10.0. - Three more button kinds.
InlineKeyboardButtongainedWebApp
(WebAppInfo),LoginURL(LoginURL) andCopyText(CopyTextButton). A
bot that kept its own keyboard type only forweb_app, and edited the buttons
in after a photo upload, can send the photo with its buttons in one call.
Telegram acceptsweb_apponly in a private chat; the field comment says so.
The struct comment now lists the actions a button can carry. This package
still does not check that exactly one is set. SendAnimationandInputMediaAnimation.SendAnimationtakes the same
files asSendVideo: afile_idor a URL, a path on a--localserver, or an
upload, which is multipart on its own.AnimationOptionshas the caption
options, width, height, duration,ShowCaptionAboveMediaandHasSpoiler.
InputMediaAnimationis the same animation forEditMessageMedia, so a photo
can turn into a loop in place. maply uploaded an MP4 as a document with its own
HTTP client to get an animation; this replaces that, with tg's retries and
token redaction. Telegram does not accept an animation in an album, so
SendMediaGrouprefuses one before sending anything.sendAnimationis in
probeSafe: with no file the server answers "There is no animation in the
request" before it does anything, soNeeds.Methodscan name it.EditMessageMediaMessagereturns the editedMessage. Thefile_idof a
file an edit uploaded is only in that answer, andEditMessageMediathrew it
away. The new method takes the same arguments and returns(Message, error).
UnlikeEditMessageMedia, it returns "message is not modified" as the error
(IsMessageNotModified) instead of swallowing it, because there is no message
to return and a zeroMessagewith a nil error would look like an edit that
worked. An edit of an inline message is still not possible: it needs the
inline_message_idwork and returnstrue, not a message.- Caption options on the media types.
InputMediaPhoto,InputMediaVideo
andInputMediaAnimationtakeShowCaptionAboveMediaandHasSpoiler, in an
edit and in an album. The caption was already HTML, so a caption and its
placement go in the same call as the media. EditMessageCaption. Replaces the caption of a message the bot sent and
returns the editedMessage: an HTML caption,EditCaptionOptionswith the
keyboard andShowCaptionAboveMedia. An empty caption removes it, and is sent
as an empty string. LikeEditMessageMediaMessageit returns "message is not
modified" as the error, which a bot editing on a timer ignores with
IsMessageNotModified.editMessageCaptionwas already inprobeSafe, and
the server answers an empty body with "Message identifier is not specified".- Reactions and batch delete.
SetMessageReactionsets the bot's own
reaction and replaces the previous one; an empty list removes it.
DeleteMessagesdeletes 1 to 100 messages in one call and refuses any other
count before sending.DeleteMessageReaction(Bot API 10.0) takes a
ReactionActor, a user or a chat, and removes that actor's reaction. It is a
moderation method for groups and supergroups and needs the right to delete
messages: it cannot take back the bot's own reaction, so the bot does that
withSetMessageReactionand no reactions. Telegram accepts only the emoji in
the Bot API reference list for a bot's reaction, and the check mark is not in
it, so a "done" mark has to be another emoji.setMessageReactionwas already
inprobeSafe;deleteMessagesanddeleteMessageReactionjoin it, so
Needs.Methodscan name all three. The server source answers an empty body
with "Message identifiers are not specified" and "chat_id is empty" before it
calls TDLib. - Menu button and profile texts.
SetChatMenuButtontakes aMenuButton
(MenuCommands,MenuWebAppwithTextandWebApp, orMenuDefault) and a
private chat; chat 0 sets the default for every private chat. A web_app button
without its text or URL and an unknown kind are refused before sending.
SetMyDescriptionandSetMyShortDescriptiontake the text and a language
code, empty for the default. An empty text is sent as an empty string, because
that is how Telegram is told to drop the text of a language. maply and framy
both set these at start; maply did it throughCall. None of the three is in
probeSafe, and a test now says so: with an empty bodysetMyDescriptionand
setMyShortDescriptionclear the text, andsetChatMenuButtonresets the
button. - Downloads reach the
Observer.DownloadToFilereports oneEventwhen
it finishes, successful or not.MethodisdownloadFilefor a transfer over
HTTP andreadLocalFilefor a read from the disk of a--localserver. The
second has no request, so itsStatusis 0 and a success is told byErr
being nil.Durationcovers the whole transfer, and the newEvent.Bytesis
what was written to the destination, 0 for every other event.Retryablesays
whether another try could pass (the network, a 429, a 5xx), but a download is
still one attempt andAttemptis 1. A file over the limit is not retryable,
andBytescounts what was written before it was rejected.Erris the error
DownloadToFilereturns, so it holds no token. A bot that counts every event
byMethodgets two new values, and one that treatsStatus == 0as "no
answer" has to checkErrfirst forreadLocalFile.