Closed brothermechanic closed 1 year ago
How to telega-chatbuf-attach-media with auto caption from filename?
telega-chatbuf-attach-media
is the interactive command, use it to attach media to a chatbuf, any text in the chatbuf's prompt following the attachment will be a media's caption.
To send media to a chat programmatically interactive commands are not suitable most of the time, because they might require interaction with the user, that's why they are called "interactive".
To send any message to a chat programmatically use telega--sendMessage
function.
telega-chatbuf-attach-media
is the interactive command, use it to attach media to a chatbuf, any text in the chatbuf's prompt following the attachment will be a media's caption.To send media to a chat programmatically interactive commands are not suitable most of the time, because they might require interaction with the user, that's why they are called "interactive". To send any message to a chat programmatically use
telega--sendMessage
function.
Thank you for reply! Can you send an example for me?
Thank you for reply! Can you send an example for me?
Command to do what you want could look like:
(defun my-telega-chatbuf-video (filename)
"Attach FILENAME as video with caption constructed out of FILENAME."
(interactive (list (telega-read-file-name "Video: ")))
(telega-chatbuf-attach-video filename)
(telega-chatbuf-input-insert (file-name-nondirectory filename)))
Wow! You my hero! Thank you very much!
Thank you for reply! Can you send an example for me?
Command to do what you want could look like:
(defun my-telega-chatbuf-video (filename) "Attach FILENAME as video with caption constructed out of FILENAME." (interactive (list (telega-read-file-name "Video: "))) (telega-chatbuf-attach-video filename) (telega-chatbuf-input-insert (file-name-nondirectory filename)))
Hi @zevlg Can you give me another advice? I want to upload this way whole directory and now learning lisp how to do that I have a trouble. This is my code:
(setq filelist (directory-files-recursively "~/dir/" "\.mp4$"))
(defun my-post-directory ()
(interactive)
(while filelist
(my-telega-chatbuf-video (car filelist))
(setq filelist (cdr filelist))
(end-of-line)
(newline-and-indent)
))
It post all videos right, but grouped in single message.
Can you give me an advice how to post all files in separated messages? (one by one)
Can you give me an advice how to post all files in separated messages? (one by one)
Just send them as separate messages, i.e. send chat input after you've added some file into the chatbuf's input. See telega-chatbuf-input-send
But take into account all things you do is "interactive" thing, i.e. intended to be used by user in interactive manner, not by some script in background mode
Can you give me an advice how to post all files in separated messages? (one by one)
Just send them as separate messages, i.e. send chat input after you've added some file into the chatbuf's input. See
telega-chatbuf-input-send
But take into account all things you do is "interactive" thing, i.e. intended to be used by user in interactive manner, not by some script in background mode
@zevlg can't get it working :(
(defun my-telega-chatbuf-video (filename)
"Attach FILENAME as video with caption constructed out of FILENAME."
(interactive (list (telega-read-file-name "Video: ")))
(telega-chatbuf-attach-video filename)
(telega-chatbuf-input-insert (file-name-nondirectory filename))
(interactive (telega-chatbuf-input-send)))
(setq filelist (directory-files-recursively "~/dir/" "\.mp4$"))
(defun my-post-directory ()
(interactive)
(while filelist
(my-telega-chatbuf-video (car filelist))
(setq filelist (cdr filelist))
))
How to do right syntax?
@zevlg hi
i did it!
This is helping line (funcall (lookup-key (current-local-map) (kbd "RET"))))
(defun my-telega-chatbuf-video (filename)
"Attach FILENAME as video with caption constructed out of FILENAME."
(interactive (list (telega-read-file-name "Video: ")))
(telega-chatbuf-attach-video filename)
(telega-chatbuf-input-insert (file-name-nondirectory filename))
(interactive (telega-chatbuf-input-send))
(funcall (lookup-key (current-local-map) (kbd "RET"))))
Hello Thank you for developing useful ui for telega!
Current Behavior
Now i upload my videoarchive to my channel and wonder about batch uploading. But main feature will be upload video with comment from filename, because without comment it's not possible to search video by name.
Steps to Reproduce
Now i upload video manually this way
Please, look. What symbol is '⟬⟭' ? this is not simple '()' This pipeline works, but not useful for batch upload many files.
Possible Solution
May be this feature aready is, tell me please. Or May be it's simple to create el script for it.