zevlg / telega.el

GNU Emacs telegram client (unofficial)
https://zevlg.github.io/telega.el/
GNU General Public License v3.0
1.09k stars 85 forks source link

[feature] Upload video with comment from filename #392

Closed brothermechanic closed 1 year ago

brothermechanic commented 1 year ago

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

 ⟬📹 /media/disk/video/2022.06.22 Dark summer day.mp4⟭  2022.06.22 Dark summer day

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.

brothermechanic commented 1 year ago

How to telega-chatbuf-attach-media with auto caption from filename?

zevlg commented 1 year ago

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.

brothermechanic commented 1 year ago

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?

zevlg commented 1 year ago

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)))
brothermechanic commented 1 year ago

Wow! You my hero! Thank you very much!

brothermechanic commented 1 year ago

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)
      ))

Screenshot_20230126_095127

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)

zevlg commented 1 year ago

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

brothermechanic commented 1 year ago

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?

brothermechanic commented 1 year ago

@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"))))