Archive of the USPol Labeler's automatic labeling script. Out-of-date. Must run alongside Ozone. DO NOT OPEN ISSUES OR PULLS -- THEY WILL BE IGNORED/CLOSED
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

[WIP] feat: accept Redis URI and connect to Redis

+57 -1
+1
deno.json
··· 7 7 "@atproto/api": "npm:@atproto/api@0.13.14", 8 8 "@atproto/identity": "npm:@atproto/identity@^0.4.2", 9 9 "@atproto/sync": "npm:@atproto/sync@^0.1.4", 10 + "@iuioiua/r2d2": "jsr:@iuioiua/r2d2@^2.1.1", 10 11 "@std/assert": "jsr:@std/assert@1", 11 12 "@std/dotenv": "jsr:@std/dotenv@^0.225.2", 12 13 "@cliffy/command": "jsr:@cliffy/command@1.0.0-rc.7"
+26
deno.lock
··· 5 5 "jsr:@cliffy/flags@1.0.0-rc.7": "1.0.0-rc.7", 6 6 "jsr:@cliffy/internal@1.0.0-rc.7": "1.0.0-rc.7", 7 7 "jsr:@cliffy/table@1.0.0-rc.7": "1.0.0-rc.7", 8 + "jsr:@iuioiua/r2d2@*": "2.1.1", 9 + "jsr:@iuioiua/r2d2@^2.1.1": "2.1.1", 8 10 "jsr:@std/assert@1": "1.0.7", 11 + "jsr:@std/bytes@~0.220.1": "0.220.1", 12 + "jsr:@std/collections@~0.220.1": "0.220.1", 9 13 "jsr:@std/dotenv@~0.225.2": "0.225.2", 10 14 "jsr:@std/fmt@~1.0.2": "1.0.3", 11 15 "jsr:@std/internal@^1.0.5": "1.0.5", 16 + "jsr:@std/io@~0.220.1": "0.220.1", 12 17 "jsr:@std/text@~1.0.7": "1.0.8", 13 18 "npm:@atproto/api@0.13.14": "0.13.14", 14 19 "npm:@atproto/identity@~0.4.2": "0.4.2", ··· 38 43 "integrity": "9fdd9776eda28a0b397981c400eeb1aa36da2371b43eefe12e6ff555290e3180", 39 44 "dependencies": [ 40 45 "jsr:@std/fmt" 46 + ] 47 + }, 48 + "@iuioiua/r2d2@2.1.1": { 49 + "integrity": "ef7ca7c892f5345b553efaf426b95021e7eb7374e885f521e00de5a6e5b98df9", 50 + "dependencies": [ 51 + "jsr:@std/bytes", 52 + "jsr:@std/collections", 53 + "jsr:@std/io" 41 54 ] 42 55 }, 43 56 "@std/assert@1.0.7": { ··· 46 59 "jsr:@std/internal" 47 60 ] 48 61 }, 62 + "@std/bytes@0.220.1": { 63 + "integrity": "e522cdc7c152cfc8a09bd618618cbc710dcf57003ab6fab3a6c37ff4c88aa3db" 64 + }, 65 + "@std/collections@0.220.1": { 66 + "integrity": "5820a8d7f69ef93af6807249dfa4be5b97ebf8654c587826612744cf7ae57ef2" 67 + }, 49 68 "@std/dotenv@0.225.2": { 50 69 "integrity": "e2025dce4de6c7bca21dece8baddd4262b09d5187217e231b033e088e0c4dd23" 51 70 }, ··· 54 73 }, 55 74 "@std/internal@1.0.5": { 56 75 "integrity": "54a546004f769c1ac9e025abd15a76b6671ddc9687e2313b67376125650dc7ba" 76 + }, 77 + "@std/io@0.220.1": { 78 + "integrity": "c14c3237cfc73dd8086ac82673212939f8c49f0803d6da68eea32249caffdd67", 79 + "dependencies": [ 80 + "jsr:@std/bytes" 81 + ] 57 82 }, 58 83 "@std/text@1.0.8": { 59 84 "integrity": "40ba34caa095f393e78796e5eda37b8b4e2cc6cfd6f51f34658ad7487b1451e4" ··· 797 822 "workspace": { 798 823 "dependencies": [ 799 824 "jsr:@cliffy/command@1.0.0-rc.7", 825 + "jsr:@iuioiua/r2d2@^2.1.1", 800 826 "jsr:@std/assert@1", 801 827 "jsr:@std/dotenv@~0.225.2", 802 828 "npm:@atproto/api@0.13.14",
+29
main.ts
··· 11 11 import { pollFeed } from "./src/poll_feed.ts"; 12 12 import { pollBlueskyList } from "./src/poll_list.ts"; 13 13 import { firehoseEventToRecordView } from "./src/convert.ts"; 14 + import { RedisClient } from "jsr:@iuioiua/r2d2"; 14 15 const { BskyAgent } = api; // RIP need module export 15 16 16 17 // load .env file ··· 22 23 const IDENTIFIER = Deno.env.get("BLUESKY_IDENTIFIER") || env["BLUESKY_IDENTIFIER"]; 23 24 const PASSWORD = Deno.env.get("BLUESKY_PASSWORD") || env["BLUESKY_PASSWORD"]; 24 25 const OZONE_DID = Deno.env.get("BLUESKY_OZONE_DID") || env["BLUESKY_OZONE_DID"]; 26 + const REDIS_URI = Deno.env.get("STAR_SPANGLED_REDIS_URI") || env["STAR_SPANGLED_REDIS_URI"]; 25 27 export const ESCALATION_THRESHOLD = parseInt(Deno.env.get("STAR_SPANGLED_ESCALATION_THRESHOLD") || env["STAR_SPANGLED_ESCALATION_THRESHOLD"]) || 50; 26 28 export const ESCALATE_AND_LABEL_THRESHOLD = parseInt(Deno.env.get("STAR_SPANGLED_ESCALATE_AND_LABEL_THRESHOLD") || env["STAR_SPANGLED_ESCALATE_AND_LABEL_THRESHOLD"]) || 1000; 27 29 export const LABEL_THRESHOLD = parseInt(Deno.env.get("STAR_SPANGLED_LABEL_THRESHOLD") || env["STAR_SPANGLED_LABEL_THRESHOLD"]) || 100; ··· 40 42 .env("BLUESKY_IDENTIFIER=<handle:string>", "The ATProto handle to sign in with.") 41 43 .env("BLUESKY_PASSWORD=<password:string>", "The Bluesky app password to sign in with.") 42 44 .env("BLUESKY_OZONE_DID=<did:string>", "The DID of the Ozone instance to connect to. ") 45 + .env("STAR_SPANGLED_REDIS_URI=<uri:string>", "The URI of the Redis instance to use. Functionality that uses Redis will be unavailable if this is not set, or if Redis fails to connect.") 43 46 .env("STAR_SPANGLED_ESCALATION_THRESHOLD=<threshold:number>", "The keyword score threshold at which a post gets escalated for manual review.", {prefix: "STAR_SPANGLED_"}) 44 47 .env("STAR_SPANGLED_LABEL_THRESHOLD=<threshold:number>", "The keyword score threshold at which a post gets automatically labeled (and not escalated).", {prefix: "STAR_SPANGLED_"}) 45 48 .env("STAR_SPANGLED_ESCALATE_AND_LABEL_THRESHOLD=<threshold:number>", "The keyword score threshold at which a post gets automatically labeled AND escalated.", {prefix: "STAR_SPANGLED_"}) ··· 107 110 108 111 // it's you! 109 112 const me = await agent.getProfile({ actor: IDENTIFIER }); 113 + 114 + // try to connect to Redis 115 + const _redisUri = URL.parse(REDIS_URI ?? "") 116 + // deno-lint-ignore no-var 117 + export var redis: RedisClient; 118 + if (REDIS_URI && _redisUri?.protocol == "redis:") { 119 + console.info("Connecting to Redis") 120 + try { 121 + const redisConnection = await Deno.connect( 122 + {hostname: _redisUri?.hostname ?? "localhost", port: _redisUri?.port ? parseInt(_redisUri?.port) : 6379} 123 + ); 124 + redis = new RedisClient(redisConnection); 125 + await redis.sendCommand(["HELLO", 3]); 126 + console.info("Connected to Redis") 127 + } catch(e) { 128 + console.error("Could not connect to Redis, disabling Redis functionality: ", e,) 129 + } 130 + }/* else if (REDIS_URI && _redisUri?.protocol == "redis-socket") { 131 + const redisConnection = await Deno.connect( 132 + {path: _redisUri?.pathname ?? "/run/redis.sock", transport: "unix"} 133 + ); 134 + redis = new RedisClient(redisConnection); 135 + await redis.sendCommand(["HELLO", 3]); 136 + }*/ else { 137 + console.warn("Redis functionality, including restart recovery and double-auto-review prevention, has been turned off. Set STAR_SPANGLED_REDIS_URI to use Redis functionality.") 138 + } 110 139 111 140 // deno-lint-ignore no-var 112 141 export var keywordList = await getKeywordsFromFile();
+1 -1
overrides.tsv.example
··· 1 1 # Subject (DID) Bonus points (or "skip") 2 - did:plc:5bzztbxvhii56ryi3az7lvzh skip # yours truly 2 + #did:plc:5bzztbxvhii56ryi3az7lvzh skip # yours truly 3 3 did:plc:p7gxyfr5vii5ntpwo7f6dhe2 100 # AOC 4 4 # note to self: run :CsvViewEnable comment=# 5 5 # vim: softtabstop=0:noexpandtab