Skip to content

Commit

Permalink
add quote characters (#532)
Browse files Browse the repository at this point in the history
  • Loading branch information
H-Shay authored Oct 2, 2024
1 parent c782d05 commit f12ebcf
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/protections/NsfwProtection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,14 @@ export class NsfwProtection extends Protection {
public async handleEvent(mjolnir: Mjolnir, roomId: string, event: any): Promise<any> {
if (event['type'] === 'm.room.message') {
let content = JSON.stringify(event['content']);
// clean up brackets and "" to simplify regex
content = content.replace(/"|{|}/g, '')
if (!content.toLowerCase().includes("mxc")) {
return;
}
// try and grab a human-readable alias for more helpful management room output
const maybeAlias = await mjolnir.client.getPublishedAlias(roomId)
const room = maybeAlias ? maybeAlias : roomId

const mxcs = content.match(/(mxc?:\/\/[^\s]+)/gim);
const mxcs = content.match(/(mxc?:\/\/[^\s'"]+)/gim);
if (!mxcs) {
//something's gone wrong with the regex
await mjolnir.managementRoomOutput.logMessage(LogLevel.ERROR, "NSFWProtection", `Unable to find any mxcs in ${event["event_id"]} in ${room}`);
Expand Down

0 comments on commit f12ebcf

Please sign in to comment.