Skip to content

Commit

Permalink
More functionality and enhancements
Browse files Browse the repository at this point in the history
- [wip] Sponsored/Recommended messages formatting

- [enh] `telega-msg-add-reaction` add support for custom emoji reactions

- [add] Support for `updateSpeechRecognitionTrial`.  Also, show speech recognition button only if there are speech recognition attempt trials available

- [add] Support for `C-h .` on the `textEntityTypeTextUrl` text entities
  Fixes https://t.me/emacs_ru/545102

- [rm] `telega-msg-heading-whole-line' is obsolete, because chatbufs uses `visual-fill-column-mode' by default, so heading face always ends at `fill-column`

- [enh] i18n: Add support for floating point plurals.  Making float parameter to :count in i18n possible

- [add] Support for `clickChatSponsoredMessage` method.

- [enh] Clickable user titles in special messages, such as `messageChatAddMembers'.  Makes `RET` work to show user details

- [enh] `telega-describe-stickerset' use `telega-ins-describe-item'

- [fix] `telega-image-mode--chat-position-fetch' handle case when buffer is dead already

Version -> 0.8.231
  • Loading branch information
zevlg committed Jan 12, 2024
1 parent d284619 commit 2a8c099
Show file tree
Hide file tree
Showing 18 changed files with 421 additions and 153 deletions.
25 changes: 25 additions & 0 deletions etc/langs/en.plist
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,11 @@ Example: 23 y.o. designer from San Francisco")
("lng_sure_delete_contact"
:value "Are you sure you want to delete {contact} from your contact list?")
("lng_maps_point"
:value "Location")
("lng_info_location_label"
:value "Location")
("lng_manage_linked_channel"
:value "Linked channel")
("lng_channel_discuss"
Expand Down Expand Up @@ -823,8 +828,12 @@ Example: 23 y.o. designer from San Francisco")
:value "Leave video chat")
("lng_group_call_leave_sure"
:value "Do you want to leave this video chat?")
("lng_group_call_join"
:value "Join")
("lng_group_call_join_as_header"
:value "Join Video Chat as...")
("lng_group_call_leave"
:value "Leave")
("lng_group_call_members"
:one_value "{count} participant"
Expand Down Expand Up @@ -1091,6 +1100,8 @@ Telegram offers a free and unlimited service to hundreds of millions of users, w
:value "Live stream")
("lng_view_button_request_join"
:value "Request to Join")
("lng_view_button_external_link"
:value "Open link")
("lng_unblock_button"
:value "Unblock")
Expand Down Expand Up @@ -1339,6 +1350,12 @@ You can send them an invite link as message instead.")
:value "Favorite stickers")
("lng_recent_stickers"
:value "Recently used")
("lng_stickers_featured_add"
:value "Add")
("lng_stickers_remove_pack"
:value "Remove \"{sticker_pack}\"?")
("lng_stickers_remove_pack_button"
:value "Remove Stickers")
;; Prompt helpers
("lng_message_ph"
Expand Down Expand Up @@ -1488,4 +1505,12 @@ You can send them an invite link as message instead.")
:value "{user} set the same wallpaper for this chat")
("lng_action_set_wallpaper_both_me"
:value "You set a new wallpaper for {user} and you.")
;; messageGiftedPremium
("lng_action_gift_received"
:value "{user} sent you a gift for {cost}")
("lng_action_gift_received_me"
:value "You sent to {user} a gift for {cost}")
)
34 changes: 25 additions & 9 deletions telega-chat.el
Original file line number Diff line number Diff line change
Expand Up @@ -1836,7 +1836,8 @@ View only if message matches TEMEX or not yet viewed."
'(:@type "messageSourceForumTopicHistory"))
((telega-chatbuf--thread-msg)
'(:@type "messageSourceMessageThreadHistory"))
(t '(:@type "messageSourceChatHistory"))))))
(t
'(:@type "messageSourceChatHistory"))))))

(defun telega-chatbuf--manage-point (&optional point only-prompt-p)
"Manage current chatbuf's point.
Expand Down Expand Up @@ -2130,10 +2131,10 @@ Use this to surrond header with some prefix and suffix."
(propertize "No title" 'face 'telega-shadow))
" ")
(if (plist-get group-call :is_joined)
(telega-ins--box-button "Leave"
(telega-ins--box-button (telega-i18n "lng_group_call_leave")
:value group-call
:action #'telega-group-call-leave)
(telega-ins--box-button "Join"
(telega-ins--box-button (telega-i18n "lng_group_call_join")
:value group-call
:action #'telega-group-call-join))
(telega-ins "\n")
Expand All @@ -2146,7 +2147,7 @@ Use this to surrond header with some prefix and suffix."
(plist-get group-call :scheduled_start_date))
;; Start Now
(telega-ins " ")
(telega-ins--box-button "Start Now"
(telega-ins--box-button (telega-i18n "lng_group_call_start_now")
:value group-call
:action #'telega--startScheduledGroupCall)
(telega-ins "\n"))
Expand Down Expand Up @@ -2255,8 +2256,18 @@ Use this to surrond header with some prefix and suffix."
(plist-get telega-chatbuf--chat :telega-sponsored-messages)))
(telega-ins--as-string
(seq-doseq (sponsored-msg (plist-get sponsored-messages :messages))
(telega-ins--chat-sponsored-message
telega-chatbuf--chat sponsored-msg)))))
(telega-ins--text-button (telega-symbol 'button-close)
'face 'telega-link
:value sponsored-msg
:action #'telega-sponsored-msg--hide)
(telega-ins " ")
(telega-ins--with-face 'telega-shadow
(telega-ins (telega-i18n (if (plist-get sponsored-msg :is_recommended)
"lng_recommended"
"lng_sponsored")))
(telega-ins "\n"))
(telega-ins--line-wrap-prefix (concat " " (telega-symbol 'vertical-bar))
(telega-button--insert 'telega-sponsored-msg sponsored-msg))))))

(defun telega-chatbuf-footer-prompt-delim (&optional with-actions-p
with-loading-p)
Expand Down Expand Up @@ -2717,14 +2728,19 @@ Recover previous active action after BODY execution."
;; message as viewed as well
(when-let ((sponsored-messages
(plist-get telega-chatbuf--chat :telega-sponsored-messages))
(has-messages-p
(not (seq-empty-p (plist-get sponsored-messages :messages))))
(not-preview-p
(not telega-chat-preview-mode))
(sponsored-views
(or (plist-get telega-chatbuf--chat :telega-sponsored-views) 0)))
(when (and (telega-chatbuf--last-msg-loaded-p)
(pos-visible-in-window-p
(ewoc-location (ewoc--footer telega-chatbuf--ewoc))))
(when (zerop sponsored-views)
(seq-doseq (sponsored-msg (plist-get sponsored-messages :messages))
(telega--viewSponsoredMessage telega-chatbuf--chat sponsored-msg)))
(telega--view-sponsored-messages
telega-chatbuf--chat
(plist-get sponsored-messages :messages)))

(plist-put telega-chatbuf--chat :telega-sponsored-views
(1+ sponsored-views))
Expand Down Expand Up @@ -4728,7 +4744,7 @@ If `\\[universal-argument]' is given, then attach live location."
(interactive (list (with-telega-chatbuf-action "ChoosingLocation"
(if current-prefix-arg
(telega-read-live-location "Live Location")
(telega-read-location "Location")))
(telega-read-location (telega-i18n "lng_maps_point"))))
(when current-prefix-arg
(let* ((choices `(("1 min" . 60)
("15 min" . ,(* 15 60))
Expand Down
5 changes: 4 additions & 1 deletion telega-core.el
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,9 @@ Document message with the #telega_favorite_messages hashtag.")
Favorite message is a plist with at least `:chat_id', `:id' properties.
`:timestamp' and `:comment' properties are also supported.")

(defvar telega--speech-recognition-trial nil
"The parameters of speech recognition without Telegram Premium.")

;; Searching
(defvar telega-search-history nil
"List of recent search queries.")
Expand Down Expand Up @@ -1729,7 +1732,7 @@ Return t."
(,facesym ,face)
(,result (progn ,@body)))
(when ,facesym
(add-face-text-property ,startsym (point) ,facesym 'append))
(add-face-text-property ,startsym (point) ,facesym))
,result)))

(defmacro telega-ins--column (column fill-col &rest body)
Expand Down
14 changes: 6 additions & 8 deletions telega-customize.el
Original file line number Diff line number Diff line change
Expand Up @@ -1110,6 +1110,11 @@ See `telega-ins--message' for NO-HEADER argument."
:type 'function
:group 'telega-inserter)

(defcustom telega-inserter-for-sponsored-msg-button 'telega-ins--sponsored-message
"Inserter for sponsored message button in a chat buffer."
:type 'function
:group 'telega-inserter)

(defcustom telega-inserter-for-msg-notification 'telega-ins--msg-notification
"*Inserter used to form body for notification bubble."
:type 'function
Expand Down Expand Up @@ -1614,8 +1619,7 @@ See `mode-line-buffer-identification'."
:group 'telega-chat)

(defcustom telega-chat-footer-format
'((:eval (telega-chatbuf-header-concat
(telega-chatbuf-footer-sponsored-messages) "\n"))
'((:eval (telega-chatbuf-footer-sponsored-messages))
(:eval (telega-chatbuf-header-concat
(telega-chatbuf-footer-prompt-delim t t) "\n"))
(:eval (telega-chatbuf-header-concat
Expand Down Expand Up @@ -1795,12 +1799,6 @@ Use this for Client Side Messages Filtering."
:type 'boolean
:group 'telega-msg)

(defcustom telega-msg-heading-whole-line nil
"*Non-nil to spread `telega-msg-heading' face to full line width.
Also applies to `telega-msg-inline-reply' face."
:type 'boolean
:group 'telega-msg)

(defcustom telega-msg-heading-with-date-and-status nil
"Non-nil to put message sent date and outgoing status into heading."
:package-version '(telega . "0.8.210")
Expand Down
2 changes: 2 additions & 0 deletions telega-i18n.el
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ Loaded from \"etc/langs/en.plist\" in `telega-i18n-init'.")
"Apply plural rule corresponding N value.
Return one of: `:zero_value', `:one_value', `:two_value',
`:few_value', `:many_value' or `:other_value'."
(when (floatp n)
(setq n (floor n)))
(or (and telega-i18n--plural-func
(funcall telega-i18n--plural-func n))
:other_value))
Expand Down
Loading

0 comments on commit 2a8c099

Please sign in to comment.