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

Make send-message work for existing chats with the bot. #7

Open
wmealing opened this issue Mar 8, 2022 · 2 comments
Open

Make send-message work for existing chats with the bot. #7

wmealing opened this issue Mar 8, 2022 · 2 comments

Comments

@wmealing
Copy link
Contributor

wmealing commented Mar 8, 2022

I made a request on how to use send-message on the 40-ants gitter-chat, and a few steps were mentioned that would allow send-message to work correctly.

The steps that are mentioned are:

  1. Make sure send-message is exported from the cl-telegram-bot/message package instead of cl-telegram-bot/bot (I see some other functions also need such refactoring.

  2. Remove export of the make-chat function because now it waits some internal plist with response from telegram server.

  3. Add another function make-private-chat which can be used to recreate chat object from remembered (in a database) chat_id, nickname and other params.

I plan to address each of these in this issue. I hope to not make more work for you.

Thank you for this project.

@wmealing
Copy link
Contributor Author

wmealing commented Mar 8, 2022

I have completed the first two steps, I have a question about step 3.

I think that this function would look very similar to 'make-chat' at that point. I can possibly go ahead with doing this, but I feel that it would duplicate most of the code in that function.

From this point my 'send-message-to-user' function looks something like

(let (chat (cl-telegram-bot/chat:make-chat (list :|id| chat-id ╎
:|username| username
:|type| "private"))))

(cl-telegram-bot/message:send-message (get-bot) chat message-text)

Where i pull chat-id / username from a local datastore. I was tempted to do something like a simple lisp database, but creating this probably means storing data in the 'process' function, and retrieving it in the make-private-chat function.

The only downside to this I see is that function will not persist between bot restarts, and expand memory over time.

I'll submit the PR for the first two, looking forward to your response for how to deal with the third requirement. Thanks in advance.

@svetlyak40wt
Copy link
Member

Thank you!

Probably the best way to make some kind of generalized store protocol to save a mapping nickname -> chat-id . Default implementation of the store will keep data in the memory and user should have an ability to specify another store object which might save data to the file or a database.

That is how I'd solve this problem.

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