forked from quisquous/cactbot
-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathresponses.ts
621 lines (580 loc) · 23 KB
/
responses.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
// This is meant to be used in a trigger as such:
// {
// id: 'Some tankbuster',
// regex: Regexes.startsUsing({source: 'Ye Olde Bosse', id: '666'}),
// condition: Conditions.caresAboutMagical(data),
// response: Responses.tankbuster(),
// },
//
// Note: Breaking out the condition like this lets people override it if they
// always (or never) want to know about it, rather than hiding the logic inside
// the tankbuster callback with a "is healer" check.
//
// If data.role is used, it should be only to differentiate between alert levels,
// and not whether a message is sent at all.
//
// Although this is not true of `response: ` fields on triggers in general,
// all responses in this file should either return an object or a single
// function that sets outputStrings and returns an object without doing
// anything with data or matches. See `responses_test.js`.
import { RaidbossData as Data } from '../types/data';
import { Matches } from '../types/net_matches';
import {
LocaleText,
LooseTrigger,
Output,
ResponseFunc,
ResponseOutput,
TargetedMatches,
TriggerFunc,
TriggerOutput,
} from '../types/trigger';
import Outputs from './outputs';
type TargetedResponseOutput = ResponseOutput<Data, TargetedMatches>;
type TargetedResponseFunc = ResponseFunc<Data, TargetedMatches>;
type TargetedFunc = TriggerFunc<Data, TargetedMatches, TriggerOutput<Data, TargetedMatches>>;
type StaticResponseFunc = ResponseFunc<Data, Matches>;
export const severityList = ['info', 'alert', 'alarm'] as const;
export type Severity = typeof severityList[number];
export type SevText = 'infoText' | 'alertText' | 'alarmText';
export const builtInResponseStr = 'cactbot-builtin-response';
// All valid trigger fields.
export const triggerFunctions: (keyof LooseTrigger)[] = [
'alarmText',
'alertText',
'condition',
'delaySeconds',
'disabled',
'durationSeconds',
'id',
'type',
'infoText',
'preRun',
'promise',
'response',
'run',
'sound',
'soundVolume',
'suppressSeconds',
'tts',
'outputStrings',
];
// Trigger fields that can produce text output.
export const triggerTextOutputFunctions: (keyof LooseTrigger)[] = [
'alarmText',
'alertText',
'infoText',
'response',
'tts',
];
// If a trigger has any of these, then it has a visible/audio effect.
export const triggerOutputFunctions: (keyof LooseTrigger)[] = [
...triggerTextOutputFunctions,
'sound',
];
export const severityMap: { [sev in Severity]: SevText } = {
'info': 'infoText',
'alert': 'alertText',
'alarm': 'alarmText',
};
const getText = (sev: Severity): SevText => {
if (!(sev in severityMap))
throw new Error(`Invalid severity: ${sev}.`);
return severityMap[sev];
};
const defaultInfoText = (sev?: Severity): SevText => {
if (!sev)
return 'infoText';
return getText(sev);
};
const defaultAlertText = (sev?: Severity): SevText => {
if (!sev)
return 'alertText';
return getText(sev);
};
const defaultAlarmText = (sev?: Severity): SevText => {
if (!sev)
return 'alarmText';
return getText(sev);
};
const getTarget = (matches: TargetedMatches) => {
// Often tankbusters can be casted by the boss on the boss.
// Consider this as "not having a target".
if (matches.target === matches.source)
return;
// In hunts, sometimes there are too many people for the target
// to have a name. Treat this as "no target".
if (matches.target === '')
return;
return matches.target;
};
const getSource = (matches: TargetedMatches) => {
return matches?.source;
};
// FIXME: make this work for any number of pairs of params
const combineFuncs = function(
text1: SevText,
func1: TargetedFunc,
text2: SevText,
func2: TargetedFunc,
) {
const obj: TargetedResponseOutput = {};
if (text1 !== text2) {
obj[text1] = func1;
obj[text2] = func2;
} else {
obj[text1] = (data: Data, matches: TargetedMatches, output: Output) => {
return func1(data, matches, output) ?? func2(data, matches, output);
};
}
return obj;
};
const isPlayerId = (id?: string) => {
return id !== undefined && !id.startsWith('4');
};
// For responses that unconditionally return static text.
const staticResponse = (field: SevText, text: LocaleText): StaticResponseFunc => {
return (_data: unknown, _matches: unknown, output: Output) => {
// cactbot-builtin-response
output.responseOutputStrings = {
text: text,
};
return {
[field]: (_data: unknown, _matches: unknown, output: Output) => output.text?.(),
};
};
};
type SingleSevToResponseFunc = (sev?: Severity) => TargetedResponseFunc | StaticResponseFunc;
type DoubleSevToResponseFunc = (targetSev?: Severity, otherSev?: Severity) => TargetedResponseFunc;
type ResponsesMap = {
[response: string]: SingleSevToResponseFunc | DoubleSevToResponseFunc;
};
export const Responses = {
tankBuster: (targetSev?: Severity, otherSev?: Severity) => {
const outputStrings = {
noTarget: Outputs.tankBuster,
busterOnYou: Outputs.tankBusterOnYou,
busterOnTarget: Outputs.tankBusterOnPlayer,
};
const targetFunc = (data: Data, matches: TargetedMatches, output: Output) => {
const target = getTarget(matches);
if (target === undefined) {
if (data.role !== 'tank' && data.role !== 'healer')
return;
return output.noTarget?.();
}
if (target === data.me)
return output.busterOnYou?.();
};
const otherFunc = (data: Data, matches: TargetedMatches, output: Output) => {
const target = getTarget(matches);
if (target === undefined) {
if (data.role === 'tank' || data.role === 'healer')
return;
return output.noTarget?.();
}
if (target === data.me)
return;
return output.busterOnTarget?.({ player: data.party.member(target) });
};
const combined = combineFuncs(
defaultAlertText(targetSev),
targetFunc,
defaultInfoText(otherSev),
otherFunc,
);
return (_data: unknown, _matches: unknown, output: Output): TargetedResponseOutput => {
// cactbot-builtin-response
output.responseOutputStrings = outputStrings;
return combined;
};
},
tankBusterSwap: (busterSev?: Severity, swapSev?: Severity) => {
const outputStrings = {
noTarget: Outputs.tankBuster,
tankSwap: Outputs.tankSwap,
busterOnYou: Outputs.tankBusterOnYou,
busterOnTarget: Outputs.tankBusterOnPlayer,
};
// Note: busterSev and swapSev can be the same priority.
const tankSwapFunc = (data: Data, matches: TargetedMatches, output: Output) => {
const target = getTarget(matches);
if (data.role === 'tank' && target !== data.me)
return output.tankSwap?.();
};
const busterFunc = (data: Data, matches: TargetedMatches, output: Output) => {
const target = getTarget(matches);
if (data.role === 'tank' && target !== data.me)
return;
if (target === data.me)
return output.busterOnYou?.();
if (target === undefined)
return output.noTarget?.();
return output.busterOnTarget?.({ player: data.party.member(target) });
};
const combined = combineFuncs(
defaultAlarmText(swapSev),
tankSwapFunc,
defaultAlertText(busterSev),
busterFunc,
);
return (_data: Data, _matches: unknown, output: Output) => {
// cactbot-builtin-response
output.responseOutputStrings = outputStrings;
return combined;
};
},
tankCleave: (sev?: Severity) => (_data: Data, _matches: unknown, output: Output) => {
// cactbot-builtin-response
output.responseOutputStrings = {
cleaveOnYou: Outputs.tankCleaveOnYou,
cleaveNoTarget: Outputs.tankCleave,
avoidCleave: Outputs.avoidTankCleave,
};
return {
[defaultInfoText(sev)]: (data: Data, matches: TargetedMatches, output: Output) => {
const target = getTarget(matches);
if (target === data.me)
return output.cleaveOnYou?.();
if (data.role === 'tank' || data.job === 'BLU') {
// targetless tank cleave
// BLU players should always get this generic cleave message.
// We have no robust way to determine whether they have tank Mimicry on,
// and it's really annoying for a BLU tank to be told to avoid cleaves when they can't.
return output.cleaveNoTarget?.();
}
return output.avoidCleave?.();
},
};
},
sharedTankBuster: (targetSev?: Severity, otherSev?: Severity) => {
const outputStrings = {
sharedTankbusterOnYou: Outputs.sharedTankbusterOnYou,
sharedTankbusterOnTarget: Outputs.sharedTankbusterOnPlayer,
sharedTankbuster: Outputs.sharedTankbuster,
avoidCleave: Outputs.avoidTankCleave,
};
const targetFunc = (data: Data, matches: TargetedMatches, output: Output) => {
const target = getTarget(matches);
if (target === undefined) {
if (data.role !== 'tank' && data.role !== 'healer')
return;
return output.sharedTankbuster?.();
}
if (target === data.me)
return output.sharedTankbusterOnYou?.();
if (data.role === 'tank' || data.role === 'healer')
return output.sharedTankbusterOnTarget?.({ player: data.party.member(target) });
};
const otherFunc = (data: Data, matches: TargetedMatches, output: Output) => {
const target = getTarget(matches);
if (target === undefined) {
if (data.role === 'tank' || data.role === 'healer')
return;
return output.avoidCleave?.();
}
if (target === data.me || data.role === 'tank' || data.role === 'healer')
return;
return output.avoidCleave?.();
};
const combined = combineFuncs(
defaultAlertText(targetSev),
targetFunc,
defaultInfoText(otherSev),
otherFunc,
);
return (_data: unknown, _matches: unknown, output: Output): TargetedResponseOutput => {
// cactbot-builtin-response
output.responseOutputStrings = outputStrings;
return combined;
};
},
miniBuster: (sev?: Severity) => staticResponse(defaultInfoText(sev), Outputs.miniBuster),
aoe: (sev?: Severity) => staticResponse(defaultInfoText(sev), Outputs.aoe),
bigAoe: (sev?: Severity) => staticResponse(defaultInfoText(sev), Outputs.bigAoe),
bleedAoe: (sev?: Severity) => staticResponse(defaultInfoText(sev), Outputs.bleedAoe),
spread: (sev?: Severity) => staticResponse(defaultInfoText(sev), Outputs.spread),
protean: (sev?: Severity) => staticResponse(defaultInfoText(sev), Outputs.protean),
// for stack marker situations.
stackMarker: (sev?: Severity) => staticResponse(defaultAlertText(sev), Outputs.stackMarker),
// for getting together without stack marker
getTogether: (sev?: Severity) => staticResponse(defaultAlertText(sev), Outputs.getTogether),
stackMarkerOn: (sev?: Severity) => (_data: Data, _matches: unknown, output: Output) => {
// cactbot-builtin-response
output.responseOutputStrings = {
stackOnYou: Outputs.stackOnYou,
stackOnTarget: Outputs.stackOnPlayer,
stackMarker: Outputs.stackMarker,
};
return {
[defaultAlertText(sev)]: (data: Data, matches: TargetedMatches, output: Output) => {
const target = getTarget(matches);
if (target === data.me)
return output.stackOnYou?.();
if (target === undefined)
return output.stackMarker?.();
return output.stackOnTarget?.({ player: data.party.member(target) });
},
};
},
stackMiddle: (sev?: Severity) => staticResponse(defaultInfoText(sev), Outputs.stackMiddle),
doritoStack: (sev?: Severity) => staticResponse(defaultAlertText(sev), Outputs.doritoStack),
spreadThenStack: (sev?: Severity) => {
return staticResponse(defaultAlertText(sev), Outputs.spreadThenStack);
},
stackThenSpread: (sev?: Severity) => {
return staticResponse(defaultAlertText(sev), Outputs.stackThenSpread);
},
knockback: (sev?: Severity) => staticResponse(defaultAlertText(sev), Outputs.knockback),
knockbackOn: (targetSev?: Severity, otherSev?: Severity) => {
const outputStrings = {
knockback: Outputs.knockback,
knockbackOnYou: Outputs.knockbackOnYou,
knockbackOnTarget: Outputs.knockbackOnPlayer,
};
const targetFunc = (data: Data, matches: TargetedMatches, output: Output) => {
const target = getTarget(matches);
if (target === data.me)
return output.knockbackOnYou?.();
};
const otherFunc = (data: Data, matches: TargetedMatches, output: Output) => {
const target = getTarget(matches);
if (target === undefined)
return output.knockback?.();
if (target !== data.me)
return output.knockbackOnTarget?.({ player: data.party.member(target) });
};
const combined = combineFuncs(
defaultInfoText(targetSev),
targetFunc,
defaultInfoText(otherSev),
otherFunc,
);
return (_data: Data, _matches: unknown, output: Output) => {
// cactbot-builtin-response
output.responseOutputStrings = outputStrings;
return combined;
};
},
drawIn: (sev?: Severity) => staticResponse(defaultInfoText(sev), Outputs.drawIn),
lookTowards: (sev?: Severity) => staticResponse(defaultInfoText(sev), Outputs.lookTowardsBoss),
lookAway: (sev?: Severity) => staticResponse(defaultInfoText(sev), Outputs.lookAway),
lookAwayFromTarget: (sev?: Severity) => (_data: Data, _matches: unknown, output: Output) => {
// cactbot-builtin-response
output.responseOutputStrings = {
lookAway: Outputs.lookAway,
lookAwayFrom: Outputs.lookAwayFromTarget,
};
return {
[defaultAlertText(sev)]: (data: Data, matches: TargetedMatches, output: Output) => {
const target = getTarget(matches);
if (target === data.me)
return;
if (target === undefined)
return output.lookAway?.();
const name = isPlayerId(matches?.targetId) ? data.party.member(target) : target;
return output.lookAwayFrom?.({ name: name });
},
};
},
lookAwayFromSource: (sev?: Severity) => (_data: Data, _matches: unknown, output: Output) => {
// cactbot-builtin-response
output.responseOutputStrings = {
lookAwayFrom: Outputs.lookAwayFromTarget,
};
return {
[defaultAlertText(sev)]: (data: Data, matches: TargetedMatches, output: Output) => {
const source = getSource(matches);
if (source === data.me)
return;
const name = isPlayerId(matches?.sourceId) ? data.party.member(source) : source;
return output.lookAwayFrom?.({ name: name });
},
};
},
getBehind: (sev?: Severity) => staticResponse(defaultAlertText(sev), Outputs.getBehind),
goFrontOrSides: (sev?: Severity) => staticResponse(defaultAlertText(sev), Outputs.goFrontOrSides),
// .getUnder() is used when you have to get into the bosses hitbox
getUnder: (sev?: Severity) => staticResponse(defaultInfoText(sev), Outputs.getUnder),
// .getIn() is more like "get close but maybe even melee range is fine"
getIn: (sev?: Severity) => staticResponse(defaultAlertText(sev), Outputs.in),
// .getOut() means get far away
getOut: (sev?: Severity) => staticResponse(defaultAlertText(sev), Outputs.out),
outOfMelee: (sev?: Severity) => staticResponse(defaultInfoText(sev), Outputs.outOfMelee),
getInThenOut: (sev?: Severity) => staticResponse(defaultInfoText(sev), Outputs.inThenOut),
getOutThenIn: (sev?: Severity) => staticResponse(defaultInfoText(sev), Outputs.outThenIn),
getBackThenFront: (sev?: Severity) => staticResponse(defaultInfoText(sev), Outputs.backThenFront),
getFrontThenBack: (sev?: Severity) => staticResponse(defaultInfoText(sev), Outputs.frontThenBack),
goFront: (sev?: Severity) => staticResponse(defaultAlertText(sev), Outputs.goFront),
goMiddle: (sev?: Severity) => staticResponse(defaultAlertText(sev), Outputs.goIntoMiddle),
goRight: (sev?: Severity) => staticResponse(defaultAlertText(sev), Outputs.right),
goLeft: (sev?: Severity) => staticResponse(defaultAlertText(sev), Outputs.left),
goWest: (sev?: Severity) => staticResponse(defaultAlertText(sev), Outputs.getLeftAndWest),
goEast: (sev?: Severity) => staticResponse(defaultAlertText(sev), Outputs.getRightAndEast),
goLeftThenRight: (sev?: Severity) => staticResponse(defaultAlertText(sev), Outputs.leftThenRight),
goRightThenLeft: (sev?: Severity) => staticResponse(defaultAlertText(sev), Outputs.rightThenLeft),
goFrontBack: (sev?: Severity) => staticResponse(defaultAlertText(sev), Outputs.goFrontBack),
goSides: (sev?: Severity) => staticResponse(defaultAlertText(sev), Outputs.sides),
// .killAdds() is used for adds that will always be available
killAdds: (sev?: Severity) => staticResponse(defaultInfoText(sev), Outputs.killAdds),
// .killExtraAdd() is used for adds that appear if a mechanic was not played correctly
killExtraAdd: (sev?: Severity) => staticResponse(defaultInfoText(sev), Outputs.killExtraAdd),
awayFromFront: (sev?: Severity) => staticResponse(defaultAlertText(sev), Outputs.awayFromFront),
sleep: (sev?: Severity) => (_data: Data, _matches: unknown, output: Output) => {
// cactbot-builtin-response
output.responseOutputStrings = {
sleep: Outputs.sleepTarget,
};
return {
[defaultAlertText(sev)]: (_data: Data, matches: TargetedMatches, output: Output) => {
const source = getSource(matches);
return output.sleep?.({ name: source });
},
};
},
stunOrInterruptIfPossible: (sev?: Severity) => {
return (_data: Data, _matches: TargetedMatches, output: Output) => {
// cactbot-builtin-response
output.responseOutputStrings = {
stun: Outputs.stunTarget,
interrupt: Outputs.interruptTarget,
};
return {
[defaultAlertText(sev)]: (data: Data, matches: TargetedMatches, output: Output) => {
const source = getSource(matches);
if (data.CanSilence())
return output.interrupt?.({ name: source });
else if (data.CanStun())
return output.stun?.({ name: source });
},
};
};
},
stun: (sev?: Severity) => (_data: Data, _matches: unknown, output: Output) => {
// cactbot-builtin-response
output.responseOutputStrings = {
stun: Outputs.stunTarget,
};
return {
[defaultAlertText(sev)]: (_data: Data, matches: TargetedMatches, output: Output) => {
const source = getSource(matches);
return output.stun?.({ name: source });
},
};
},
stunIfPossible: (sev?: Severity) => (_data: Data, _matches: unknown, output: Output) => {
// cactbot-builtin-response
output.responseOutputStrings = {
stun: Outputs.stunTarget,
};
return {
[defaultAlertText(sev)]: (data: Data, matches: TargetedMatches, output: Output) => {
const source = getSource(matches);
if (data.CanStun())
return output.stun?.({ name: source });
},
};
},
interrupt: (sev?: Severity) => (_data: Data, _matches: unknown, output: Output) => {
// cactbot-builtin-response
output.responseOutputStrings = {
interrupt: Outputs.interruptTarget,
};
return {
[defaultAlertText(sev)]: (_data: Data, matches: TargetedMatches, output: Output) => {
const source = getSource(matches);
return output.interrupt?.({ name: source });
},
};
},
interruptIfPossible: (sev?: Severity) => (_data: Data, _matches: unknown, output: Output) => {
// cactbot-builtin-response
output.responseOutputStrings = {
interrupt: Outputs.interruptTarget,
};
return {
[defaultAlertText(sev)]: (data: Data, matches: TargetedMatches, output: Output) => {
const source = getSource(matches);
if (data.CanSilence())
return output.interrupt?.({ name: source });
},
};
},
preyOn: (targetSev?: Severity, otherSev?: Severity) => {
const outputStrings = {
preyOnYou: Outputs.preyOnYou,
preyOnTarget: Outputs.preyOnPlayer,
};
const targetFunc = (data: Data, matches: TargetedMatches, output: Output) => {
const target = getTarget(matches);
if (data.me === target)
return output.preyOnYou?.();
};
const otherFunc = (data: Data, matches: TargetedMatches, output: Output) => {
const target = getTarget(matches);
const player = target === undefined ? output.unknown?.() : data.party.member(target);
if (target !== data.me)
return output.preyOnTarget?.({ player: player });
};
const combined = combineFuncs(
defaultAlertText(targetSev),
targetFunc,
defaultInfoText(otherSev),
otherFunc,
);
return (_data: Data, _matches: unknown, output: Output) => {
// cactbot-builtin-response
output.responseOutputStrings = outputStrings;
return combined;
};
},
awayFrom: (sev?: Severity) => (_data: Data, _matches: unknown, output: Output) => {
// cactbot-builtin-response
output.responseOutputStrings = {
awayFromGroup: Outputs.awayFromGroup,
awayFromTarget: Outputs.awayFromPlayer,
unknown: Outputs.unknown,
};
return {
[defaultAlertText(sev)]: (data: Data, matches: TargetedMatches, output: Output) => {
const target = getTarget(matches);
if (data.me === target)
return output.awayFromGroup?.();
const player = target === undefined ? output.unknown?.() : data.party.member(target);
return output.awayFromTarget?.({ player: player });
},
};
},
meteorOnYou: (sev?: Severity) => staticResponse(defaultAlarmText(sev), Outputs.meteorOnYou),
stopMoving: (sev?: Severity) => staticResponse(defaultAlarmText(sev), Outputs.stopMoving),
stopEverything: (sev?: Severity) => staticResponse(defaultAlarmText(sev), Outputs.stopEverything),
// move away to dodge aoes
moveAway: (sev?: Severity) => staticResponse(defaultInfoText(sev), Outputs.moveAway),
// move around (e.g. jumping) to avoid being frozen
moveAround: (sev?: Severity) => staticResponse(defaultInfoText(sev), Outputs.moveAround),
breakChains: (sev?: Severity) => staticResponse(defaultInfoText(sev), Outputs.breakChains),
moveChainsTogether: (sev?: Severity) =>
staticResponse(defaultInfoText(sev), Outputs.moveChainsTogether),
earthshaker: (sev?: Severity) => (_data: Data, _matches: unknown, output: Output) => {
// cactbot-builtin-response
output.responseOutputStrings = {
earthshaker: Outputs.earthshakerOnYou,
};
return {
[defaultAlertText(sev)]: (data: Data, matches: TargetedMatches, output: Output) => {
const target = getTarget(matches);
if (target !== data.me)
return;
return output.earthshaker?.();
},
};
},
wakeUp: (sev?: Severity) => staticResponse(defaultAlarmText(sev), Outputs.wakeUp),
getTowers: (sev?: Severity) => staticResponse(defaultInfoText(sev), Outputs.getTowers),
} as const;
// Don't give `Responses` a type in its declaration so that it can be treated as more strict
// than `ResponsesMap`, but do assert that its type is correct. This allows callers to know
// which properties are defined in Responses without having to conditionally check for undefined.
const responseMapTypeAssertion: ResponsesMap = Responses;
// Suppress unused variable warning.
console.assert(responseMapTypeAssertion);