This commit is contained in:
Your Name 2024-09-18 22:50:16 -06:00
parent 63c11f78ea
commit 042e452540
2 changed files with 57 additions and 0 deletions

4
block.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
HEX=$(nak decode $1 | jq ".pubkey" | sed 's/"//i' | sed 's/"//i')
echo "Adding $1 to block list"
sed -i "30a '$HEX'," /opt/strfry-policies/strfry-policy.ts

53
src/policies/emoji.ts Normal file
View File

@ -0,0 +1,53 @@
import { Policy } from '../types.ts';
/**
* Reject events whose content matches the regex.
*
* @example
* ```ts
* // Ban events matching a regex.
* regexPolicy(msg, /(🟠|🔥|😳)ChtaGPT/i);
* ```
*/
const emoji: Policy<RegExp> = ({ event: { id, content } }) => {
var fire_count = (content.match(/🔥/g) || []).length;
var rainbow_count = (content.match(/🌈/g) || []).length;
var happy_count = (content.match(/😀/g) || []).length;
var hundred_count = (content.match(/💯/g) || []).length;
var party_count = (content.match(/🎉/g) || []).length;
var limit = 1;
if ( happy_count > 0 && happy_count > 0 && fire_count > 0 ) {
return {
id,
action: 'reject',
msg: 'ReplyGuy Dual Emoji Policy: Blocked!',
};
}
if ( happy_count > 0 && fire_count > 0 ) {
return {
id,
action: 'reject',
msg: 'ReplyGuy Dual Emoji Policy: Blocked!',
};
}
if (hundred_count > limit || happy_count > limit || fire_count > limit || rainbow_count > limit ) {
return {
id,
action: 'reject',
msg: 'ReplyGuy Emoji Policy: Blocked!',
};
}
return {
id,
action: 'accept',
msg: '',
};
};
export default emoji;