Skip to content

Instantly share code, notes, and snippets.

@alexgleason
Created March 25, 2023 14:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexgleason/5c2d084434fa0875397f44da198f4352 to your computer and use it in GitHub Desktop.
Save alexgleason/5c2d084434fa0875397f44da198f4352 to your computer and use it in GitHub Desktop.
strfry American Policy (example)
import type { Policy } from 'https://gitlab.com/soapbox-pub/strfry-policies/-/blob/develop/mod.ts';
/** Only American English is allowed. */
const americanPolicy: Policy<void> = (msg) => {
const { content } = msg.event;
const words = [
'armour',
'behaviour',
'colour',
'favourite',
'flavour',
'honour',
'humour',
'rumour',
];
const isBritish = words.some((word) => content.toLowerCase().includes(word));
if (isBritish) {
return {
id: msg.event.id,
action: 'reject',
msg: 'Sorry, only American English is allowed on this server!',
};
} else {
return {
id: msg.event.id,
action: 'accept',
msg: '',
};
}
};
export default americanPolicy;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment