micl2e2 / tg-focus

A comprehensive Telegram message filter/forwarder that helps you focus💡.
GNU General Public License v3.0
95 stars 3 forks source link

More ergonomic support for case insensitive keywords #15

Open dangoodman opened 6 months ago

dangoodman commented 6 months ago

It would be great to have a switch to enable a case-insensitive matching of the keywords.

For now, one can use regexes, e.g., "[Tt][Aa][Bb][Ll][Ee]". While it works, it hurts readability a lot if all of the keywords are defined this way.

A new filters.toml key, say "case-insensitive": true/false, could help with that.

Another option is to support regex flags, e.g., "/table/i".

micl2e2 commented 6 months ago

Thanks for your rational suggestion!

Since the underlying regex engine used by tg-focus comes from libc's regex.h, there is no support like JS RegExp's flags or Perl RE's modifiers. But REG_ICASE(https://www.man7.org/linux/man-pages/man3/regcomp.3.html) should do the trick. It would be great if someone could send a patch to support such scenarios.