Skip to content

feature request: bot message limit warning message #52

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

Closed
seshubonam opened this issue Jun 6, 2024 · 6 comments
Closed

feature request: bot message limit warning message #52

seshubonam opened this issue Jun 6, 2024 · 6 comments

Comments

@seshubonam
Copy link

Hi, we have used this matrix bot in a chat application. Where, users can use publicly available ai bot for upto 10 messages and post this, it will send a message to user about "10 message limit reached, resume in 1 hour or add your own API key"

We tried to implement this but ran into issues where the bot stopped responding after message limit is reached.

More context of our implementation: User can add own API key by using a !key command. but in our implementation, after the 10 message warning the bot stops to respond.

Any ideas how we could implement this?

thanks !

@hibobmaster
Copy link
Owner

after the 10 message warning the bot stops to respond

Can you tell me how you guy implement message limit.

@f1delius
Copy link

f1delius commented Jun 6, 2024

We implemented it using simple dict as it resets every 3 hours,it triggers the condition just doesn't send the message.

https://github.com/pixxels-team/matrix_chatgpt_bot/blob/93456a21c2a6e3f67b38f8b13f08c9444a297cfe/src/bot.py#L187-L198

@seshubonam
Copy link
Author

the required flow is:.

after 10 messages are sent by the ai/bot
it should send a message that 10 message limit has exceeded ,

at present it doesnt send the message

and it works after set time limit (3 hours in our case) is over.

@hibobmaster
Copy link
Owner

hibobmaster commented Jun 6, 2024

it triggers the condition just doesn't send the message.

I recommend creating a breakpoint here and then step into to see what happen in details.
https://github.com/pixxels-team/matrix_chatgpt_bot/blob/93456a21c2a6e3f67b38f8b13f08c9444a297cfe/src/bot.py#L189

Besides, i guess this function will only execute once.
https://github.com/pixxels-team/matrix_chatgpt_bot/blob/93456a21c2a6e3f67b38f8b13f08c9444a297cfe/src/main.py#L91-L95
https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.loop.call_later

To make thing easier, you can use apschuduler library: https://apscheduler.readthedocs.io/en/3.x/
Create a background scheduler when matrix bot iniitialize.

@seshubonam
Copy link
Author

will try this. thanks

@seshubonam
Copy link
Author

took all week to solve this. but your suggestion helped 🔥 thanks.
the dev also found a solution but he finally implemented yours.

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

3 participants