synzen / MonitoRSS

MonitoRSS RSS bot (formerly known as Discord.RSS) with customizable feeds. https://monitorss.xyz
https://monitorss.xyz
MIT License
1.08k stars 240 forks source link

[Question] How did you solve the problem of what messages you already sent? #206

Closed reesericci closed 3 years ago

reesericci commented 3 years ago

I'm trying to build a similar app but using a REST api to interact and wondering how you solved the problem of what messages did the bot already send so it won't send duplicates. Did you log each post to a file?

synzen commented 3 years ago

Apologies for the late reply.

It is a little involved, but the general steps are

  1. It fetches the feeds https://github.com/synzen/MonitoRSS/blob/master/src/util/FeedFetcher.js
  2. It resolves the article's ID via https://github.com/synzen/MonitoRSS/blob/d01d6077f28528fda2ded9ad7980839f38fe380b/src/util/FeedFetcher.js#L232 and attaches it to the article
  3. It compares the resolved ID of every article against every other ID in the feed's collection https://github.com/synzen/MonitoRSS/blob/d01d6077f28528fda2ded9ad7980839f38fe380b/src/structs/LinkLogic.js#L302, as well as other custom comparison properties and date checks