dronefly-garden / dronefly

Red Discord Bot V3 cogs for naturalists.
Other
16 stars 3 forks source link

last: Rewrite as interactions stored in config #47

Open synrg opened 4 years ago

synrg commented 4 years ago

Instead of plowing through channel histories to search for links & commands, record bot interactions in a config-backed history which can then be retrieved by the user in a less wordy fashion:

synrg commented 4 years ago

https://github.com/synrg/dronefly/issues/37 is a good place to start for the on_message hook part of this problem (i.e. simply reacting to messages & previewing).

synrg commented 4 years ago

Not sure if config-backed is even needed most of the time. Just remembering what happened since the bot joined is probably good enough for most of the "related info traversal" needs.

The only time not being aware of channel history becomes annoying is when the bot has to restart in the middle of a bot interaction. While that might happen frequently with the development bot, to be kind to my users, production bot restarts should really be kept to a minimum. It would certainly help reduce complexity if I pared this back to only be a shallow history of recently remembered interactions kept in-memory per channel.

So consider just a simple in-memory limited length collections.deque for each "thing" to remember: 'query for a taxon', 'query for an observation', 'navigation up or down taxonomy tree from taxon-or-observation'. In particular, 'query for a taxon', and 'taxon navigation' should be remembered as separate things so that 'show the family of the last taxon query' isn't misunderstood to be 'show the family of last taxon navigated to' (which might not even be possible if, e.g. they navigated to the superfamily).

synrg commented 3 years ago

In #141 we are working towards having recent interactions with taxon and tab displays (via reaction buttons) cause those displays to be cached for a time. We could dispense with even having to parse them if we started out by placing the embeds in the cache as soon as they are created. Then last has even less work to do if the most recent message of the requested type is already cached. Revisit this issue once that issue is complete.