@@ -338,7 +338,8 @@ int iCount = GetTriggerArray ().GetSize (); // how many there are
338
338
false , // expand wildcards
339
339
true , // convert regexps
340
340
trigger_item->bRegexp , // is it regexp or normal?
341
- false ); // don't throw exceptions
341
+ false , // don't throw exceptions
342
+ NULL ); // no name substitution in match text
342
343
343
344
344
345
LONGLONG iOldTimeTaken = 0 ;
@@ -420,6 +421,11 @@ int iCount = GetTriggerArray ().GetSize (); // how many there are
420
421
421
422
// copy contents to output area, replacing %1, %2 etc. with appropriate contents
422
423
424
+ // get unlabelled trigger's internal name
425
+ const char * pLabel = trigger_item->strLabel ;
426
+ if (pLabel [0 ] == 0 )
427
+ pLabel = GetTriggerRevMap () [trigger_item].c_str ();
428
+
423
429
output += FixSendText (::FixupEscapeSequences (trigger_item->contents ),
424
430
trigger_item->iSendTo , // where it is going
425
431
trigger_item->regexp , // regexp
@@ -429,7 +435,8 @@ int iCount = GetTriggerArray ().GetSize (); // how many there are
429
435
true , // expand wildcards
430
436
false , // convert regexps
431
437
false , // is it regexp or normal?
432
- false ); // don't throw exceptions
438
+ false , // don't throw exceptions
439
+ pLabel);
433
440
434
441
break ; // break out of loop, we have a trigger match
435
442
@@ -846,6 +853,11 @@ bool CMUSHclientDoc::ProcessOneAliasSequence (const CString strCurrentLine,
846
853
else
847
854
Trace (" Matched alias %s" , (LPCTSTR) alias_item->strLabel );
848
855
856
+ // get unlabelled alias's internal name
857
+ const char * pLabel = alias_item->strLabel ;
858
+ if (pLabel [0 ] == 0 )
859
+ pLabel = GetAliasRevMap () [alias_item].c_str ();
860
+
849
861
// if we have to do parameter substitution on the alias, do it now
850
862
851
863
CString strSendText;
@@ -863,7 +875,8 @@ bool CMUSHclientDoc::ProcessOneAliasSequence (const CString strCurrentLine,
863
875
true , // expand wildcards
864
876
false , // convert regexps
865
877
false , // is it regexp or normal?
866
- true ); // throw exceptions
878
+ true , // throw exceptions
879
+ pLabel);
867
880
}
868
881
catch (CException* e)
869
882
{
@@ -1022,6 +1035,7 @@ bool CMUSHclientDoc::ExecuteAliasScript (CAlias * alias_item,
1022
1035
// %<22> : contents of wildcard 22
1023
1036
// %% : %
1024
1037
// %C : contents of (text) clipboard
1038
+ // %N : name of trigger / timer / alias
1025
1039
1026
1040
// If bThrowExceptions is set certain conditions (such as variable not existing)
1027
1041
// cause an exception to be thrown (eg. for alias handling),
@@ -1037,7 +1051,8 @@ CString CMUSHclientDoc::FixSendText (const CString strSource,
1037
1051
const bool bExpandWildcards, // convert %x
1038
1052
const bool bFixRegexps, // convert \ to \\ for instance
1039
1053
const bool bIsRegexp, // true = regexp trigger
1040
- const bool bThrowExceptions)
1054
+ const bool bThrowExceptions, // throw exception on error
1055
+ const char * sName ) // the name of the trigger/timer/alias (for %N)
1041
1056
{
1042
1057
CString strOutput; // result of expansion
1043
1058
@@ -1324,6 +1339,26 @@ const char * pText,
1324
1339
}
1325
1340
break ; // end of %c
1326
1341
1342
+ /* -------------------------------------------------------------------- *
1343
+ * %N - name of the thing *
1344
+ * -------------------------------------------------------------------- */
1345
+
1346
+ case ' N' :
1347
+ case ' n' :
1348
+ {
1349
+ // copy up to the percent sign
1350
+ strOutput += CString (pStartOfGroup, pText - pStartOfGroup);
1351
+
1352
+ if (sName )
1353
+ strOutput += sName ;
1354
+
1355
+ // get ready for next batch from beyond the 'n'
1356
+
1357
+ pText += 2 ;
1358
+ pStartOfGroup = pText;
1359
+ }
1360
+ break ; // end of %n
1361
+
1327
1362
/* -------------------------------------------------------------------- *
1328
1363
* %(something else) *
1329
1364
* -------------------------------------------------------------------- */
0 commit comments