mjolnir icon indicating copy to clipboard operation
mjolnir copied to clipboard

Internal: Have a class/function that splits text into multiple events at max size

Open ShadowJonathan opened this issue 3 years ago • 1 comments

This is needed for !mjolnir rules, at the very least, to make it possible to display large amounts of listed items.

My thought process is to encapsule these kinds of display events into a seperate structure anyway, to make things like "X rooms: <li><li><li>"/"no rooms" more idiomatic;

(pseudocode)

class Listing:
  header: (str, str) # html + text
  items: [](str, str)

class MultipleListings:
  listings: []Listing

Passing a single Listing would (if needed) chunk up items so that it fits in a series of events, and MultipleListings would have multiple lists with each a header, trying to fit these in a single event if possible.

This'd make the code to pass large lists of items like this more generic, and would allow mjolnir to work even if these lists (like !mjolnir rules) would get too big.

ShadowJonathan avatar May 14 '22 15:05 ShadowJonathan

Additionally, for the function actually chunking the text into events, the binary search algorithm can probably be applied to find the "right" size per event quickly and efficiently.

ShadowJonathan avatar May 14 '22 15:05 ShadowJonathan