StampyAI / stampy

A Discord bot for the Robert Miles AI server
37 stars 9 forks source link

questions.py: marking questions as del/dup, restoring review request cache, reducing overhead with TypedDict #241

Closed MatthewBaggins closed 1 year ago

MatthewBaggins commented 1 year ago
  1. @editors can now easily change status of one or more questions to "Marked for deletion" or "Duplicate" by posting GDoc links to those questions
s, del <gdoc-link(s)> # changes to "Marked for deletion"
s, dup <gdoc-link(s)> # changes to "Duplicate"
  1. When a @reviewer accepts a request for feedback on edited questions by replying to a message with "lgtm", "approved", or "accepted", Stampy changes their statuses to "Live on site". For that, he uses a cache that maps a Discord message ID to coda IDs of questions the GDocs of which are posted linked in that message. The problem is that this cache is lost whenever Stampy reboots (e.g. after any PR merge), so accepting a review request from before the last reboot doesn't work. This PR fixes that. Now, when Stampy sees an approval of a review request, that is missing from his cache, he goes over the last 2000 messages in that channels history, finds review requests, parses them and stores the message-id-to-question-ids in the cache.

  2. Previously I used dataclasses for managing different kinds of commands. While it's handy, dataclasses introduce a lot of functionality that we don't really need, so I replaced them with TypedDicts, which are mostly typechecker sugar.