Add ability to mute keywords from chat (#413)

* Added ability to mute keywords from chat

* Muted words logic in widget, added Json Converter

Created a json converter to to serialize the observable list of muted keywords, this required a static method for the default value. Also moved the logic for the muted keyword widget to the widget itself

* Removed JSON Converter and ObservableList

* remove unused imports

---------

Co-authored-by: Tommy Chow <tommyxchow@gmail.com>
This commit is contained in:
Corentin Detry 2024-11-13 03:42:33 +01:00 • committed by GitHub
parent 5276ddb8d4
commit a7619027af
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 225 additions and 0 deletions

View file

@ -311,6 +311,21 @@ abstract class ChatStoreBase with Store {
continue;
}
// Filter messages containing any muted words.
if (parsedIRCMessage.message != null) {
final List<String> mutedWords = settings.mutedWords;
// check if the message contains any of the muted words
for (final word in mutedWords) {
if (parsedIRCMessage.message!
.toLowerCase()
.split(settings.matchWholeWord ? ' ' : '')
.contains(word.toLowerCase())) {
return;
}
}
}
switch (parsedIRCMessage.command) {
case Command.privateMessage:
case Command.notice: