Skip to content

Commit

Permalink
Support for TDLib 1.8.45 features
Browse files Browse the repository at this point in the history
- [add] Support for video covers

- [enh] Do not put eliding on separate line for expandable quotes

Support for reactions for special messages

- [new] `telega-chat-custom-order-for' to apply custom order to chats matching chat temex.

Version -> 0.8.450
  • Loading branch information
zevlg committed Mar 1, 2025
1 parent 8327a14 commit 4f06ab5
Show file tree
Hide file tree
Showing 15 changed files with 122 additions and 37 deletions.
47 changes: 35 additions & 12 deletions docs/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions docs/telega-ellit.org
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,8 @@ Use ~telega-story-match-p~ to match a story.
- {{{user-option(telega-chat-show-deleted-messages-for, 2)}}}
- {{{user-option(telega-root-view-grouping-alist, 2)}}}
- {{{user-option(telega-chat-delete-skip-confirmation-for, 2)}}}
- {{{user-option(telega-chat-delete-skip-confirmation-for, 2)}}}
- {{{user-option(telega-chat-custom-order-for, 2)}}}

* Chat Folders

Expand Down
13 changes: 12 additions & 1 deletion docs/telega-manual.org
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#+options: timestamp:nil \n:t num:nil ellit-cid:t
#+title: Telega Manual (v0.8.441)
#+title: Telega Manual (v0.8.450)
#+author: Zajcev Evgeny
#+startup: showall

Expand Down Expand Up @@ -1620,6 +1620,17 @@ Use ~telega-story-match-p~ to match a story.
Specifies Chat Temex for chats which can be deleted without
typing confirmation.

Default value: ~nil~
- User Option: ~telega-chat-delete-skip-confirmation-for~

Specifies Chat Temex for chats which can be deleted without
typing confirmation.

Default value: ~nil~
- User Option: ~telega-chat-custom-order-for~

Chat temex returning custom order for the chat.

Default value: ~nil~

* Chat Folders
Expand Down
4 changes: 2 additions & 2 deletions etc/langs/en.plist
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,8 @@ Example: 23 y.o. designer from San Francisco")
:other_value "{member_count} members, {count} online")
;; queries to user
("telega_action_cant_undone"
:value "This action cannot be undone")
("lng_context_mark_read_all_sure_2"
:value "**This action cannot be undone.**")
("telega_query_delete_chat"
:value "Delete «{title}» chat? ")
("telega_query_delete_chat_history"
Expand Down
10 changes: 9 additions & 1 deletion telega-core.el
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ Use FILENAME as is if resulting file does not exist."
"Default reaction for the messages.
Updated on `updateDefaultReactionType' event.")

(defvar telega-default-paid-reaction-type nil
"Default paid reaction type for the messages.
Updated on `updateDefaultPaidReactionType' event.")

(defconst telega-translate-languages-alist
'(("Afrikaans" . "af") ("Albanian" . "sq") ("Amharic" . "am")
("Arabic" . "ar") ("Armenian" . "hy") ("Azerbaijani" . "az")
Expand Down Expand Up @@ -768,6 +772,9 @@ Done when telega server is ready to receive queries."

(setq telega--close-birthday-users nil)
(setq telega--owned-stars 0)

(setq telega-default-reaction-type nil)
(setq telega-default-paid-reaction-type nil)
)

(defun telega-test-env (&optional quiet-p)
Expand Down Expand Up @@ -1683,7 +1690,8 @@ For use by interactive commands."
Order from `telega-tdlib--chat-list' position is used.
If CHAT has custom order, then return its custom order."
(or (unless ignore-custom
(telega-chat-uaprop chat :order))
(or (telega-chat-uaprop chat :order)
(telega-chat-match-p chat telega-chat-custom-order-for)))
(plist-get (telega-chat-position chat) :order)
"0"))

Expand Down
7 changes: 7 additions & 0 deletions telega-customize.el
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,13 @@ is a function accepting title string and returning string."
:value-type function)
:group 'telega-root)

(defcustom telega-chat-custom-order-for nil
"Chat temex returning custom order for the chat."
:package-version "0.8.450"
:type 'telega-chat-temex
:options '((and (folder "SOMEFOLDER") (return "10")))
:group 'telega-root)

(defcustom telega-chat-button-width '(0.35 15 48)
"*Width for the chat buttons in root buffer.
If integer, then use this number of chars.
Expand Down
4 changes: 2 additions & 2 deletions telega-emoji.el
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,8 @@ Do not fetch custom emojis for ignored messages."

(defun telega-emoji-status--animate (emoji-status)
"Animate EMOJI-STATUS."
(let* ((custom-emoji-id (plist-get emoji-status :custom_emoji_id))
(sticker (telega-custom-emoji-get custom-emoji-id)))
(when-let* ((custom-emoji-id (plist-get emoji-status :custom_emoji_id))
(sticker (telega-custom-emoji-get custom-emoji-id)))
(when (and telega-sticker-animated-play
(not (telega-sticker-static-p sticker)))
(telega-sticker--animate sticker))))
Expand Down
1 change: 1 addition & 0 deletions telega-i18n.el
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
("telega_at" . "lng_schedule_at")
("telega_comment" . "lng_photos_comment")
("telega_status" . "lng_proxy_box_status")
("telega_action_cant_undone" . "lng_context_mark_read_all_sure_2")
)
"i18n names aliases alist.")

Expand Down
32 changes: 24 additions & 8 deletions telega-ins.el
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,8 @@ SHOW-DETAILS - non-nil to show photo details."
(telega-ins "\n"))

(let ((msg-content (plist-get msg :content)))
(cond ((plist-get msg-content :is_secret)
(cond ((and (plist-get msg-content :is_secret)
(plist-get photo :minithumbnail))
(let ((ttl-in (plist-get msg :self_destruct_in)))
(unless (telega-zerop ttl-in)
(telega-ins--with-face 'telega-shadow
Expand All @@ -721,7 +722,8 @@ SHOW-DETAILS - non-nil to show photo details."
(if (plist-get msg :self_destruct_type) 'flames 'lock))))))

((and (plist-get msg-content :has_spoiler)
(not (plist-get msg :telega-media-spoiler-removed)))
(not (plist-get msg :telega-media-spoiler-removed))
(plist-get photo :minithumbnail))
(telega-ins--image-slices
(telega-spoiler-create-svg
(plist-get photo :minithumbnail)
Expand Down Expand Up @@ -852,7 +854,8 @@ and thumbnail are shown."
;; Video's thumbnail, if any
(unless (eq how 'metainfo)
(telega-ins-from-newline
(cond ((plist-get content :is_secret)
(cond ((and (plist-get content :is_secret)
(plist-get video :minithumbnail))
;; Secret video
(let ((ttl-in (plist-get msg :self_destruct_in)))
(unless (telega-zerop ttl-in)
Expand All @@ -868,13 +871,15 @@ and thumbnail are shown."
(setq ret t)))

((and (plist-get content :has_spoiler)
(not (plist-get msg :telega-media-spoiler-removed)))
(not (plist-get msg :telega-media-spoiler-removed))
(plist-get video :minithumbnail))
(telega-ins--image-slices
(telega-spoiler-create-svg
(plist-get video :minithumbnail)
(plist-get video :width)
(plist-get video :height)
telega-thumbnail-size-limits))
telega-thumbnail-size-limits
'video))
(telega-ins "\n")
(telega-ins--box-button (telega-i18n "lng_context_disable_spoiler")
:action #'telega-msg-media-spoiler-toggle)
Expand Down Expand Up @@ -1250,10 +1255,15 @@ and thumbnail are shown."
(telega-ins "\n"))
(linkPreviewTypeVideo
(when-let ((video (plist-get lp-type :video)))
(telega-ins--video msg video 'thumbnail)
(if-let ((cover (plist-get lp-type :cover)))
(telega-ins--photo cover nil telega-video-size-limits)
(telega-ins--video msg video 'thumbnail))
(telega-ins "\n")
(telega-ins--with-face 'telega-shadow
(telega-ins--video msg video 'metainfo))
(telega-ins--video msg video 'metainfo)
(let ((start-timestamp (plist-get lp-type :start_timestamp)))
(unless (telega-zerop start-timestamp)
(telega-ins-fmt " start: %ds" start-timestamp))))
(telega-ins "\n")))
(linkPreviewTypeVideoNote
(when-let ((video-note (plist-get lp-type :video_note)))
Expand Down Expand Up @@ -2538,7 +2548,12 @@ Special messages are determined with `telega-msg-special-p'."
('messageAudio
(telega-ins--audio msg))
('messageVideo
(telega-ins--video msg))
(if-let ((cover (plist-get content :cover)))
(progn
(telega-ins--video msg nil 'metainfo)
(telega-ins-from-newline
(telega-ins--photo cover nil telega-video-size-limits)))
(telega-ins--video msg)))
('messageVoiceNote
(telega-ins--voice-note msg))
('messageVideoNote
Expand Down Expand Up @@ -3290,6 +3305,7 @@ ADDON-HEADER-INSERTER is passed directly to `telega-ins--message-header'."
;; Align message at the center using `horizontal-bar' symbol
(let ((start-pos (point)))
(telega-ins--content msg)
(telega-ins--msg-reaction-list msg)
(let* ((end-column (telega-current-column))
(align-nchars (/ (- telega-chat-fill-column
end-column)
Expand Down
1 change: 0 additions & 1 deletion telega-media.el
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,6 @@ Return nil if preview image is unavailable."
(plist-get audio :album_cover_thumbnail)
(plist-get audio :album_cover_minithumbnail)))

;; TODO: draw tringle inside preview image
(defun telega-video--create-image (video &optional file)
"Create image to preview VIDEO content."
(if (not telega-use-svg-base-uri)
Expand Down
11 changes: 9 additions & 2 deletions telega-msg.el
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,15 @@ Return nil for deleted messages."
(cl-assert (telega-file--downloaded-p file))
(telega-open-file (telega--tl-get file :local :path) msg))

(telega-video-player-run
(telega--tl-get file :local :path) msg done-callback)))
(let* ((start-timestamp
(or (telega--tl-get msg :content :start_timestamp)
(telega--tl-get msg :content :link_preview
:type :start_timestamp)))
(telega-ffplay-media-timestamp
(unless (telega-zerop start-timestamp)
start-timestamp)))
(telega-video-player-run
(telega--tl-get file :local :path) msg done-callback))))

(defun telega-msg--play-video-incrementally (msg video _file)
"For massage MSG start playing VIDEO file, while still downloading it."
Expand Down
4 changes: 4 additions & 0 deletions telega-tdlib-events.el
Original file line number Diff line number Diff line change
Expand Up @@ -1462,6 +1462,10 @@ Please downgrade TDLib and recompile `telega-server'"
(setq telega-default-reaction-type
(plist-get event :reaction_type)))

(defun telega--on-updateDefaultPaidReactionType (event)
(setq telega-default-paid-reaction-type
(plist-get event :type)))

(defun telega--on-updateChatAvailableReactions (event)
(let ((chat (telega-chat-get (plist-get event :chat_id) 'offline)))
(cl-assert chat)
Expand Down
9 changes: 4 additions & 5 deletions telega-tdlib.el
Original file line number Diff line number Diff line change
Expand Up @@ -3249,16 +3249,15 @@ Saved Messages topic is specified by SM-TOPIC-ID."
(or callback #'ignore)))

(cl-defun telega--addPendingPaidMessageReaction (msg &key (star-count 1)
(anonymous-p 'default))
tl-paid-reaction-type)
(telega-server--send
(list :@type "addPendingPaidMessageReaction"
:chat_id (plist-get msg :chat_id)
:message_id (plist-get msg :id)
:star_count star-count
:use_default_is_anonymous (if (eq anonymous-p 'default) t :false)
:is_anonymous (if (and anonymous-p (not (eq anonymous-p 'default)))
t
:false)
:type (or tl-paid-reaction-type
telega-default-paid-reaction-type
'(list :@type "paidReactionTypeRegular"))
)))

(defun telega--commitPendingPaidMessageReactions (msg)
Expand Down
Loading

0 comments on commit 4f06ab5

Please sign in to comment.