Skip to content

Commit

Permalink
Merge pull request benawad#2803 from n3oney/patch-2
Browse files Browse the repository at this point in the history
fix(dolma): fix emotes, codeblocks and refactor
  • Loading branch information
HoloPanio authored May 17, 2021
2 parents 4623f07 + 3edc6c5 commit 824c8cc
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions dolma/src/lib/filterString.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,26 @@ export function filterString(emotes: { name: string }[], message: string) {

vals.map((e) => {
let tkn = msgToken.getType(e);
if (tkn == "emote") {
emotes.find((emote) => `:${emote.name}:` == e.trim()) ? "" : tkn = "text";
}
if (tkn == "mention") {
e = e.substr(1);
}
let value = msgToken.getValue(tkn, e);
tokenSwitch:
switch (tkn) {
case "emote":
for(const emote of emotes) {
if(e.trim() === `:${emote.name}:`) {
e = emote.name;
break tokenSwitch;
}
}
tkn = "text";
break;
case "block":
e = e.slice(1, -1);
break;
case "mention":
e = e.substr(1);
break;
}

const value = msgToken.getValue(tkn, e);

return tokens.push(msgToken.newToken(tkn, value));
});
Expand Down

0 comments on commit 824c8cc

Please sign in to comment.