nmlorg / metabot

Modularized, multi-account bot.
https://metabot.readthedocs.io/
5 stars 0 forks source link

Keep events list messages updated #97

Closed nmlorg closed 5 months ago

nmlorg commented 5 months ago

The output of /events is just discarded (for now), but daily announcements are recorded and edited if the included events are changed — but the "X days" markers (and the choice of listing the current month/year) are allowed to go stale. When a new announcement is made every day, this isn't a big deal, but groups that are configured to only do one/a couple announcements per week, or that have no upcoming events, get stuck with inaccurate countdowns.

In addition to having the "NOW" versus "TODAY" markers update in real time, it might also make sense to have the bot list "X hours" instead of just "TODAY"; and "Xh left" instead of just "NOW":

Jun 25 7 a.m.: ¹ʷ¹ᵈ Wed, Jul 3, 8–10ᵃᵐ

Jun 26 7 a.m.: ¹ʷ Wed, Jul 3, 8–10ᵃᵐ

Jun 27 7 a.m.: ⁶ ᵈᵃʸˢ Wed, Jul 3, 8–10ᵃᵐ

Jun 30 7 a.m.: ³ ᵈᵃʸˢ Wed, Jul 3, 8–10ᵃᵐ

Jul 1 7 a.m.: ² ᵈᵃʸˢ Wed 3, 8–10ᵃᵐ

Jul 2 7 a.m.: ᵗᵒᵐᵒʳʳᵒʷ Wed 3, 8–10ᵃᵐ

Jul 2 9 a.m.: ²³ ʰᵒᵘʳˢ Wed 3, 8–10ᵃᵐ

Jul 3 7 a.m.: ¹ ʰᵒᵘʳ Wed 3, 8–10ᵃᵐ

Jul 3 9 a.m.: ¹ʰ ˡᵉᶠᵗ Wed 3, 8–10ᵃᵐ

nmlorg commented 5 months ago

The next step is to record the current text and suffix in records so the reminder_edit branch can essentially do:

if edits:
    send edit notice
    suffix = 'Updated {now}'
else:
    suffix = lastsuffix

if text != lasttext:
    reminder_edit('{text}\n\n{suffix}')

Right now, records is a pickle mapping (botusername, groupid) to (eventtime, events as of eventtime, reminder message). I'm leaning towards changing this from a tuple to a dict. I could do something like:

class Record:
    events = message = time = None

which would be fairly futureproof (I could make this format change right now without making any logic changes, then add more fields to Record later).

However, I could also take the opportunity to migrate daily.pickle into multibot.conf, so instead of managing file I/O inside reminders.py I'd just create a new multibot.conf['reminders'] table and botconf.py would magically turn that into a new reminders.yaml file.

However however, right now I store lists of dicts in records, and dicttools.TrackingList doesn't allow that. So I need to decide between adding support for that to TrackingList, or creating a way to just store a normal dict inside an ImplicitTrackingDict, or giving up on migrating into multibot.conf — in which case I'd need to choose between sticking with daily.pickle (or maybe at least renaming it reminders.pickle) or maybe moving to reminders.json (or still switching to YAML but just not having the file end in .yaml :/).

nmlorg commented 5 months ago

(Another option would be to stop storing lists of dicts in records, but I'm not sure that's plausible.)

nmlorg commented 5 months ago

The superscript 'i' (U+2071) and 'n' (U+207f) are in a different block from most of the letters, and it really, really doesn't look good when you mix the two blocks in some fonts — including the one used on my laptop.

I tried a few possible variations:

¹⁰ ᵐⁱⁿᵘᵗᵉˢ U+2071 ¹⁰ ᵐᶤⁿᵘᵗᵉˢ U+1da4 ¹⁰ ᵐᶨⁿᵘᵗᵉˢ U+1da8 ¹⁰ ᵐʲⁿᵘᵗᵉˢ U+02b2 ¹⁰ ᵐᶦⁿᵘᵗᵉˢ U+1da6

that all look better than U+2071 on my laptop, but U+2071 actually looks fine on Android Telegram and all of the variations are noticeably off :/

  It doesn't look like there's a superscript colon, so I can't just stick to "0:10" as a format.

  I'm using "Xm" for months right now. (Technically that means X meters; and the abbreviation for X minutes would be X min, which would have the exact same problem as just spelling it out.) I thought it might be important to keep the expression consistent:

3m 2m3w 2m2w 2m1w 2m

but I could theoretically do something like:

3 months 2m3w 2m2w 2m1w 2 months

  I could just not use superscript for minutes, given that it's a bit emphasized.

  I could also give up on displaying a minutes countdown altogether.