A work-in-progress chat bot for Streamplace with chat overlay functionality
2
fork

Configure Feed

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

Singleton export atprotoClient

+7 -14
+5 -11
main.ts
··· 1 1 import { App, staticFiles } from "fresh"; 2 2 import { type State } from "./utils.ts"; 3 3 import { isHandle } from "@atcute/lexicons/syntax"; 4 - import { resolveHandle } from "./utils/atcuteUtils.ts"; 4 + import { AtprotoClient, resolveHandle } from "./utils/atcuteUtils.ts"; 5 5 import { 6 6 filterByStreamplace, 7 7 getBacklinks, ··· 15 15 export const botInstances: Map<Did, StreamplaceBot> = new Map(); 16 16 17 17 // Initialize for self 18 + export const atprotoClient = new AtprotoClient(BOT_CREDENTIALS, BOT_SERVICE); 18 19 const botDid = isHandle(BOT_CREDENTIALS.identifier) 19 20 ? await resolveHandle(BOT_CREDENTIALS.identifier) 20 21 : BOT_CREDENTIALS.identifier; 21 - const streamplaceBot = new StreamplaceBot( 22 - botDid, 23 - BOT_CREDENTIALS, 24 - BOT_SERVICE, 25 - ); 22 + const streamplaceBot = new StreamplaceBot(botDid); 26 23 streamplaceBot.init(); 27 24 botInstances.set(botDid, streamplaceBot); 28 25 ··· 36 33 ); 37 34 const filteredBacklinks = await filterByStreamplace(backlinks); 38 35 for (const backlinkDid of filteredBacklinks) { 39 - const streamplaceBot = new StreamplaceBot( 40 - backlinkDid, 41 - BOT_CREDENTIALS, 42 - BOT_SERVICE, 43 - ); 36 + //if(backlinkDid !== "did:plc:dvh3s2edmdijbcv3k45ze22l") continue; 37 + const streamplaceBot = new StreamplaceBot(backlinkDid); 44 38 streamplaceBot.init(); 45 39 botInstances.set(backlinkDid, streamplaceBot); 46 40 }
+2 -3
utils/streamplaceBot.ts
··· 8 8 OnlineTimtinkersBotCommand, 9 9 PlaceStreamChatMessage, 10 10 } from "./lexicons/index.ts"; 11 + import { atprotoClient } from "../main.ts"; 11 12 12 13 export interface CommandHandler { 13 14 ( ··· 49 50 */ 50 51 constructor( 51 52 streamerDid: Did, 52 - clientCredentials: AuthLoginOptions, 53 - clientService: string, 54 53 commandPrefix = "!", 55 54 ) { 56 55 this.streamerDid = streamerDid; 57 56 this.commandPrefix = commandPrefix; 58 57 this.commands = new Map(); 59 58 this.enabled = true; 60 - this.client = new AtprotoClient(clientCredentials, clientService); 59 + this.client = atprotoClient; 61 60 } 62 61 63 62 // Initialize the bot - must be called before use