noodlebox / KawaiiDiscord

Add huge sets of external emotes to Discord
MIT License
6 stars 2 forks source link

Implement wildcard emotes #12

Closed noodlebox closed 7 years ago

noodlebox commented 8 years ago

Add support for wildcard (*) emotes in addition to rolls. Basically, bring back the original roll behavior changed by 4024f75, using * instead of #. Also, implement suffix and substring matching (at least) as well.

Also, now that "roll tables" would potentially become more complicated, determine whether building them ahead of time is worth doing. Roll resolution could be deferred to limit the impact of searching for an arbitrary wildcard match, showing the fallback emote until then (rollDefault), and giving the opportunity to animate the result as originally planned.

noodlebox commented 7 years ago

Deciding against arbitrary wildcard matching (:na*me:) as it just complicates the "score" calculation while not really having any use cases that make much sense.

noodlebox commented 7 years ago

It turns out that building a roll table is slow enough to matter when a single message can contain many instances of :*:. Factoring this out into an easy-to-memoize function drastically improves performance.