I am writing a bot for Matrix using Ruby which allows users to subscribe to RSS feeds and when a new item shows up on the feed it gets sent to the room.
The problem I have come up against is how do I get the program to sit and wait for new commands from users while also fetching feeds every 2 minutes?
Some solutions I have found would be to check for new commands and then check to see if it's time to fetch the feeds again. This might work because waiting for new commands from Matrix is non blocking as you can request all the new messages since last time without having to sit and wait for something to come in. This feels a little hacky though and I'm not sure if it's the best way to go about things.
Another solution would be to create 2 separate programs. One which listens for commands from users and another one that is run by a cron job that sends new messages to the room when it finds a new item on rss. This would be possible because Matrix doesn't have a constant connection like IRC but uses a HTTP API to send and receive messages. The problem I see with this one is managing a database shared between 2 programs seems overly complex and could result in issues.
Another way would be multithreading but I am pretty unfamiliar with how this works and ruby doesn't seem to support it from what I have seen.
What would be the best way to handle this? Are any of the things I have come up with a good solution?