@@ -334,6 +334,70 @@ describe("irc inbound behavior", () => {
334334 expect ( ctx ?. OriginatingTo ) . toBe ( "channel:#ops" ) ;
335335 } ) ;
336336
337+ it . each ( [
338+ { label : "ordinary nick" , nick : "OpenClaw" , text : "OpenClaw: hello" , mentioned : true } ,
339+ { label : "ASCII case folding" , nick : "OpenClaw" , text : "openclaw: hello" , mentioned : true } ,
340+ { label : "leading bracket" , nick : "[Claw]" , text : "[Claw]: hello" , mentioned : true } ,
341+ { label : "trailing bracket" , nick : "Claw]" , text : "hello Claw]," , mentioned : true } ,
342+ { label : "leading caret" , nick : "^Claw" , text : "^Claw, hello" , mentioned : true } ,
343+ { label : "trailing hyphen" , nick : "Claw-" , text : "Claw-: hello" , mentioned : true } ,
344+ { label : "escaped backslash" , nick : "\\Claw" , text : "\\Claw: hello" , mentioned : true } ,
345+ { label : "embedded brackets" , nick : "Claw[Ops]" , text : "Claw[Ops]: hi" , mentioned : true } ,
346+ { label : "RFC1459 opening bracket" , nick : "[Claw" , text : "{claw: hello" , mentioned : true } ,
347+ { label : "RFC1459 opening brace" , nick : "{Claw" , text : "[claw: hello" , mentioned : true } ,
348+ { label : "RFC1459 closing bracket" , nick : "Claw]" , text : "claw}: hello" , mentioned : true } ,
349+ { label : "RFC1459 closing brace" , nick : "Claw}" , text : "claw]: hello" , mentioned : true } ,
350+ { label : "RFC1459 backslash" , nick : "\\Claw" , text : "|claw: hello" , mentioned : true } ,
351+ { label : "RFC1459 vertical bar" , nick : "|Claw" , text : "\\claw: hello" , mentioned : true } ,
352+ { label : "RFC1459 caret" , nick : "^Claw" , text : "~claw: hello" , mentioned : true } ,
353+ { label : "RFC1459 tilde" , nick : "~Claw" , text : "^claw: hello" , mentioned : true } ,
354+ { label : "ordinary nick suffix" , nick : "Claw" , text : "Clawbot: hello" , mentioned : false } ,
355+ { label : "ordinary nick prefix" , nick : "Claw" , text : "overClaw: hello" , mentioned : false } ,
356+ { label : "IRC nick punctuation suffix" , nick : "Claw" , text : "Claw-bot: hi" , mentioned : false } ,
357+ { label : "RFC1459 tilde nick suffix" , nick : "Claw" , text : "Claw~bot: hi" , mentioned : false } ,
358+ {
359+ label : "punctuated nick inside a longer nick" ,
360+ nick : "[Claw]" ,
361+ text : "prefix[Claw]: hello" ,
362+ mentioned : false ,
363+ } ,
364+ ] ) (
365+ "recognizes only complete IRC nickname mentions: $label" ,
366+ async ( { nick, text, mentioned } ) => {
367+ const coreRuntime = createPluginRuntimeMock ( ) ;
368+ const runtime = createRuntimeEnv ( ) ;
369+ setIrcRuntime ( coreRuntime as never ) ;
370+
371+ await handleIrcInbound ( {
372+ message : createMessage ( {
373+ target : "#ops" ,
374+ isGroup : true ,
375+ text,
376+ } ) ,
377+ account : createAccount ( {
378+ nick,
379+ config : {
380+ dmPolicy : "open" ,
381+ allowFrom : [ "*" ] ,
382+ groupPolicy : "open" ,
383+ groupAllowFrom : [ ] ,
384+ groups : {
385+ "#ops" : { enabled : true , requireMention : true } ,
386+ } ,
387+ } ,
388+ } ) ,
389+ config : { channels : { irc : { } } } as CoreConfig ,
390+ runtime,
391+ sendReply : vi . fn ( async ( ) => { } ) ,
392+ } ) ;
393+
394+ expect ( coreRuntime . channel . inbound . dispatch ) . toHaveBeenCalledTimes ( mentioned ? 1 : 0 ) ;
395+ if ( ! mentioned ) {
396+ expect ( runtime . log ) . toHaveBeenCalledWith ( "irc: drop channel #ops (missing-mention)" ) ;
397+ }
398+ } ,
399+ ) ;
400+
337401 it ( "drops a spoofed sender for a host-less nick!user DM allowlist entry" , async ( ) => {
338402 const coreRuntime = createPluginRuntimeMock ( ) ;
339403 const runtime = createRuntimeEnv ( ) ;
0 commit comments