A tool for parsing traffic on the jetstream and applying a moderation workstream based on regexp based rules

Merge pull request #23 from skywatch-bsky/enhance-lang

Enhance languages

authored by

Scarnecchia and committed by
GitHub
3d352e4c 9d252306

+24 -11
+4 -2
src/checkPosts.ts
··· 51 51 (postCheck) => postCheck.label === label, 52 52 ); 53 53 54 - if (!langs.includes(lang)) { 55 - return; 54 + if (checkPost?.language || checkPost?.language !== undefined) { 55 + if (!checkPost?.language.includes(lang)) { 56 + return; 57 + } 56 58 } 57 59 58 60 if (checkPost?.ignoredDIDs) {
+12 -8
src/checkProfiles.ts
··· 16 16 ) => { 17 17 const lang = await getLanguage(description); 18 18 19 - if (!langs.includes(lang)) { 20 - return; 21 - } 22 - 23 19 const labels: string[] = Array.from( 24 20 PROFILE_CHECKS, 25 21 (profileCheck) => profileCheck.label, ··· 30 26 const checkProfiles = PROFILE_CHECKS.find( 31 27 (profileCheck) => profileCheck.label === label, 32 28 ); 29 + 30 + if (checkProfiles?.language || checkProfiles?.language !== undefined) { 31 + if (!checkProfiles?.language.includes(lang)) { 32 + return; 33 + } 34 + } 33 35 34 36 // Check if DID is whitelisted 35 37 if (checkProfiles?.ignoredDIDs) { ··· 94 96 ) => { 95 97 const lang = await getLanguage(description); 96 98 97 - if (!langs.includes(lang)) { 98 - return; 99 - } 100 - 101 99 // Get a list of labels 102 100 const labels: string[] = Array.from( 103 101 PROFILE_CHECKS, ··· 109 107 const checkProfiles = PROFILE_CHECKS.find( 110 108 (profileCheck) => profileCheck.label === label, 111 109 ); 110 + 111 + if (checkProfiles?.language || checkProfiles?.language !== undefined) { 112 + if (!checkProfiles?.language.includes(lang)) { 113 + return; 114 + } 115 + } 112 116 113 117 // Check if DID is whitelisted 114 118 if (checkProfiles?.ignoredDIDs) {
+4
src/constants.ts.example
··· 10 10 11 11 export const PROFILE_CHECKS: Checks[] = [ 12 12 { 13 + language: ["eng"], 13 14 label: "skub", 14 15 comment: "Pro-skub language found in profile", 15 16 description: true, ··· 43 44 44 45 export const HANDLE_CHECKS: Checks[] = [ 45 46 { 47 + language: ["eng"], 46 48 label: "skub", 47 49 comment: "Pro-skub language found in handle", 48 50 reportAcct: false, ··· 57 59 58 60 export const POST_CHECKS: Checks[] = [ 59 61 { 62 + language: ["eng"], 60 63 label: "pro-skub-link", 61 64 comment: "Pro Skub link found in post", 62 65 reportAcct: false, 63 66 commentAcct: true, 67 + reportPost: false, 64 68 toLabel: true, 65 69 check: new RegExp( 66 70 "skubbe\\.com|skub\\.(me|pro|tech)",
+3 -1
src/developing_checks.md
··· 8 8 ```typescript 9 9 export const HANDLE_CHECKS: Checks[] = [ 10 10 { 11 + language: "[eng]", // Language of the check. If the check language does not match the content language, the check will be skipped. Assign null or remove field to apply to all languages. 11 12 label: "example", 12 13 comment: "Example found in handle", 13 14 description: true, // Optional, only used in handle checks 14 15 displayName: true, // Optional, only used in handle checks 15 - reportAcct: false, // it true, the check will only report the content against the account, not label. 16 + reportAcct: false, // if true, the check will only report the content against the account, not label. 17 + reportPost: false, // if true, the check will only report the content against the post, not label. Only used in post checks. 16 18 commentOnly: false, // if true, will generate an account level comment from flagged posts, rather than a report. Intended for use when reportAcct is false, and on posts only where the flag may generate a high volume of reports. 17 19 toLabel: true, // Should the handle in question be labeled if check evaluates to true. 18 20 check: new RegExp("example", "i"), // Regular expression to match against the content
+1
src/types.ts
··· 1 1 export interface Checks { 2 + language?: string[]; 2 3 label: string; 3 4 comment: string; 4 5 description?: boolean;