Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get message ID when replying to a message? #18

Open
bmansurov opened this issue Jun 6, 2023 · 2 comments
Open

How to get message ID when replying to a message? #18

bmansurov opened this issue Jun 6, 2023 · 2 comments

Comments

@bmansurov
Copy link

I have a method that listens to on-message and I want to get the *current-message* ID so that I can pass it to reply as reply-message-id, but *current-message* is not an exported symbol. Is that something we can export? Or maybe pass an instance of the message class to on-message? Or any other suggestions?

@svetlyak40wt
Copy link
Member

Do you want to call reply but later?

I'm looked into the code and sems exporting of *current-message* will not be sufficient.

Describe your use-case and I'll think how it is better to adopt the API.

@bmansurov
Copy link
Author

bmansurov commented Jun 6, 2023

Thanks for your quick response! With reply if I want to pass the reply-to-message-id parameter, I can't because I don't have the message ID. And I need a message ID to send a message via cl-telegram-bot/message:send-message too. My use case is simple, I want to quote the user's original text when replying to it.

For example, in the below snippet I want to have the value of some-imaginary-id which is the ID of the message that has the text text.

(defmethod cl-telegram-bot:on-message ((cl-telegram-bot/bot:bot bot) text)
  (reply text :reply-to-message-id some-imaginary-id))

Ideally, it would be great if the message is passed along like this:

(defgeneric on-message (bot message)
  (:documentation "This method gets called with the message.
                   By default it does nothing."))

Rather than

(defgeneric on-message (bot text)
  (:documentation "This method gets called with raw text from the message.
                   By default it does nothing."))

This would allow us to access all the slots of the message object, not just its id.

@bmansurov bmansurov changed the title How get message ID when replying to a message? How to get message ID when replying to a message? Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants