@@ -24,6 +24,21 @@ export class CharterMonitoringService {
24
24
*/
25
25
async processCharterChange ( event : CharterChangeEvent ) : Promise < void > {
26
26
try {
27
+ // Only process if the watchdog name is specifically set to "Cerberus"
28
+ const charterText = event . newCharter . toLowerCase ( ) ;
29
+
30
+ // Look for "Watchdog Name:" followed by "**Cerberus**" on next line (handles markdown)
31
+ let watchdogNameMatch = charterText . match ( / w a t c h d o g n a m e : \s * \n \s * \* \* ( [ ^ * ] + ) \* \* / ) ;
32
+ if ( ! watchdogNameMatch ) {
33
+ // Alternative: look for "Watchdog Name: Cerberus" on same line
34
+ watchdogNameMatch = charterText . match ( / w a t c h d o g n a m e : \s * ( [ ^ \n \r ] + ) / ) ;
35
+ }
36
+
37
+ if ( ! watchdogNameMatch || watchdogNameMatch [ 1 ] . trim ( ) !== 'cerberus' ) {
38
+ console . log ( `🔍 Cerberus not enabled for group: ${ event . groupName } - watchdog name is not "Cerberus"` ) ;
39
+ return ;
40
+ }
41
+
27
42
console . log ( `🔍 Cerberus monitoring charter change in group: ${ event . groupName } ` ) ;
28
43
29
44
if ( event . changeType === 'created' ) {
@@ -269,13 +284,51 @@ Just add a new charter with an Automated Watchdog Policy mentioning "Cerberus"!
269
284
*/
270
285
private charterMentionsCerberus ( charterContent : string ) : boolean {
271
286
if ( ! charterContent ) return false ;
272
- return charterContent . toLowerCase ( ) . includes ( 'cerberus' ) ;
287
+
288
+ // Check if the watchdog name is specifically set to "Cerberus"
289
+ const charterText = charterContent . toLowerCase ( ) ;
290
+
291
+ // Look for "Watchdog Name:" followed by "**Cerberus**" on next line (handles markdown)
292
+ let watchdogNameMatch = charterText . match ( / w a t c h d o g n a m e : \s * \n \s * \* \* ( [ ^ * ] + ) \* \* / ) ;
293
+ if ( ! watchdogNameMatch ) {
294
+ // Alternative: look for "Watchdog Name: Cerberus" on same line
295
+ watchdogNameMatch = charterText . match ( / w a t c h d o g n a m e : \s * ( [ ^ \n \r ] + ) / ) ;
296
+ }
297
+
298
+ if ( watchdogNameMatch ) {
299
+ const watchdogName = watchdogNameMatch [ 1 ] . trim ( ) ;
300
+ return watchdogName === 'cerberus' ;
301
+ }
302
+
303
+ // Fallback: check if "Watchdog Name: Cerberus" appears anywhere
304
+ return charterText . includes ( 'watchdog name: cerberus' ) ;
273
305
}
274
306
275
307
/**
276
308
* Send a fun periodic check-in message to groups with active charters
277
309
*/
278
310
async sendPeriodicCheckIn ( groupId : string , groupName : string ) : Promise < void > {
311
+ // Get the group to check if Cerberus is enabled
312
+ const group = await this . groupService . getGroupById ( groupId ) ;
313
+ if ( ! group || ! group . charter ) {
314
+ console . log ( `🔍 No charter found for group: ${ groupName } - skipping periodic check-in` ) ;
315
+ return ;
316
+ }
317
+
318
+ const charterText = group . charter . toLowerCase ( ) ;
319
+
320
+ // Look for "Watchdog Name:" followed by "**Cerberus**" on next line (handles markdown)
321
+ let watchdogNameMatch = charterText . match ( / w a t c h d o g n a m e : \s * \n \s * \* \* ( [ ^ * ] + ) \* \* / ) ;
322
+ if ( ! watchdogNameMatch ) {
323
+ // Alternative: look for "Watchdog Name: Cerberus" on same line
324
+ watchdogNameMatch = charterText . match ( / w a t c h d o g n a m e : \s * ( [ ^ \n \r ] + ) / ) ;
325
+ }
326
+
327
+ if ( ! watchdogNameMatch || watchdogNameMatch [ 1 ] . trim ( ) !== 'cerberus' ) {
328
+ console . log ( `🔍 Cerberus not enabled for group: ${ groupName } - watchdog name is not "Cerberus"` ) ;
329
+ return ;
330
+ }
331
+
279
332
const messageText = `🐕 **Cerberus Check-In!** 🐕
280
333
281
334
Just dropping by to say hello! I'm still here, watching over your charter in ${ groupName } .
0 commit comments