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.

Auto-shoutout cooldown

+9 -4
+9 -4
utils/streamplaceBot.ts
··· 24 24 private moderatorsLoaded: boolean = false; 25 25 private shoutouts: Map<Did, OnlineTimtinkersBotShoutout.Main> = new Map(); 26 26 private shoutoutsByAtUri: Map<ResourceUri, Did> = new Map(); 27 - private hasBeenGreeted: Map<Did, boolean> = new Map(); 28 27 private shoutoutsLoaded: boolean = false; 28 + private hasBeenGreeted: Map<Did, Date> = new Map(); 29 + private greetingCooldown: number = 12 * 60 * 60 * 1000; // 12 hours 29 30 30 31 /** 31 32 * Create a new StreamplaceBot ··· 141 142 const chatter = await this.getUserProfile(event.did); 142 143 143 144 // Auto-greet first-time chatters with shoutout if they have one 144 - if (!this.hasBeenGreeted.get(event.did)) { 145 - this.hasBeenGreeted.set(event.did, true); 145 + const lastGreeting = this.hasBeenGreeted.get(event.did); 146 + if ( 147 + !lastGreeting || 148 + (Date.now() - lastGreeting.getTime()) >= this.greetingCooldown 149 + ) { 150 + this.hasBeenGreeted.set(event.did, new Date()); 146 151 147 152 if (this.shoutouts.get(event.did)) { 148 153 const shoutout = this.shoutouts.get(event.did); ··· 221 226 return this.commandHandler; 222 227 } 223 228 224 - getGreeted(): Map<Did, boolean> { 229 + getGreeted(): Map<Did, Date> { 225 230 return this.hasBeenGreeted; 226 231 } 227 232