@@ -37,24 +37,25 @@ class Bot {
37
37
this . ircStatusNotices = options . ircStatusNotices ;
38
38
this . announceSelfJoin = options . announceSelfJoin ;
39
39
40
- this . format = options . format || { } ;
41
40
// "{$keyName}" => "variableValue"
42
- // nickname: discord nickname
43
- // displayUsername: nickname with wrapped colors
44
- // text: the (IRC-formatted) message content
41
+ // author/nickname: nickname of the user who sent the message
45
42
// discordChannel: Discord channel (e.g. #general)
46
43
// ircChannel: IRC channel (e.g. #irc)
44
+ // text: the (appropriately formatted) message content
45
+ this . format = options . format || { } ;
46
+
47
+ // "{$keyName}" => "variableValue"
48
+ // displayUsername: nickname with wrapped colors
47
49
// attachmentURL: the URL of the attachment (only applicable in formatURLAttachment)
48
- this . formatCommandPrelude = this . format . commandPrelude || 'Command sent from Discord by {$nickname}:' ;
49
50
this . formatIRCText = this . format . ircText || '<{$displayUsername}> {$text}' ;
50
51
this . formatURLAttachment = this . format . urlAttachment || '<{$displayUsername}> {$attachmentURL}' ;
51
52
52
53
// "{$keyName}" => "variableValue"
53
- // author: IRC nickname
54
- // text: the (Discord-formatted) message content
54
+ // side: "Discord" or "IRC"
55
+ this . formatCommandPrelude = this . format . commandPrelude || 'Command sent from {$side} by {$nickname}:' ;
56
+
57
+ // "{$keyName}" => "variableValue"
55
58
// withMentions: text with appropriate mentions reformatted
56
- // discordChannel: Discord channel (e.g. #general)
57
- // ircChannel: IRC channel (e.g. #irc)
58
59
this . formatDiscord = this . format . discord || '**<{$author}>** {$withMentions}' ;
59
60
60
61
// Keep track of { channel => [list, of, usernames] } for ircStatusNotices
@@ -239,6 +240,7 @@ class Bot {
239
240
}
240
241
241
242
const patternMap = {
243
+ author : nickname ,
242
244
nickname,
243
245
displayUsername,
244
246
text,
@@ -247,7 +249,9 @@ class Bot {
247
249
} ;
248
250
249
251
if ( this . isCommandMessage ( text ) ) {
252
+ patternMap . side = 'Discord' ;
250
253
const prelude = Bot . substitutePattern ( this . formatCommandPrelude , patternMap ) ;
254
+ logger . debug ( 'Sending command message to IRC' , ircChannel , text ) ;
251
255
this . ircClient . say ( ircChannel , prelude ) ;
252
256
this . ircClient . say ( ircChannel , text ) ;
253
257
} else {
@@ -299,6 +303,23 @@ class Bot {
299
303
// Convert text formatting (bold, italics, underscore)
300
304
const withFormat = formatFromIRCToDiscord ( text ) ;
301
305
306
+ const patternMap = {
307
+ author,
308
+ nickname : author ,
309
+ text : withFormat ,
310
+ discordChannel : `#${ discordChannel . name } ` ,
311
+ ircChannel : channel
312
+ } ;
313
+
314
+ if ( this . isCommandMessage ( text ) ) {
315
+ patternMap . side = 'IRC' ;
316
+ const prelude = Bot . substitutePattern ( this . formatCommandPrelude , patternMap ) ;
317
+ logger . debug ( 'Sending command message to Discord' , `#${ discordChannel . name } ` , text ) ;
318
+ discordChannel . sendMessage ( prelude ) ;
319
+ discordChannel . sendMessage ( text ) ;
320
+ return ;
321
+ }
322
+
302
323
const withMentions = withFormat . replace ( / @ [ ^ \s ] + \b / g, ( match ) => {
303
324
const search = match . substring ( 1 ) ;
304
325
const guild = discordChannel . guild ;
@@ -320,13 +341,7 @@ class Bot {
320
341
return match ;
321
342
} ) ;
322
343
323
- const patternMap = {
324
- author,
325
- text : withFormat ,
326
- withMentions,
327
- discordChannel : `#${ discordChannel . name } ` ,
328
- ircChannel : channel
329
- } ;
344
+ patternMap . withMentions = withMentions ;
330
345
331
346
// Add bold formatting:
332
347
// Use custom formatting from config / default formatting with bold author
0 commit comments