Skip to content

Commit e76aff5

Browse files
Merge pull request #101 from stephenyeargin/fix-adapter-name-drift
Fix adapter name drift
2 parents 017469a + 64ea4e4 commit e76aff5

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

src/hockey.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ const AFTER_GAME_STATES = [
3434
];
3535

3636
module.exports = (robot) => {
37+
// Cache adapter name to avoid issues with it being reset in newer Hubot versions
38+
const adapterName = robot.adapterName || robot.adapter?.name || '';
39+
3740
const periodFormat = (periodDescriptor) => {
3841
if (periodDescriptor.type === 'SO') {
3942
return 'SO';
@@ -214,7 +217,7 @@ module.exports = (robot) => {
214217

215218
// Say it
216219
switch (true) {
217-
case /slack/.test(robot.adapterName):
220+
case /slack/.test(adapterName):
218221
msg.send({
219222
attachments: [
220223
{
@@ -232,7 +235,7 @@ module.exports = (robot) => {
232235
],
233236
});
234237
break;
235-
case /discord/.test(robot.adapterName):
238+
case /discord/.test(adapterName):
236239
output.push(`${moment(game.startTimeUTC).tz(team.time_zone).format('l')} - ${howToWatch}`);
237240
output.push(`\`\`\`\n${table.toString()}\n\`\`\``);
238241
output.push(`${gameStatus} - https://www.nhl.com/gamecenter/${game.id}`);
@@ -343,7 +346,7 @@ module.exports = (robot) => {
343346

344347
// Say it
345348
switch (true) {
346-
case /slack/.test(robot.adapterName):
349+
case /slack/.test(adapterName):
347350
msg.send({
348351
attachments: [
349352
{
@@ -359,7 +362,7 @@ module.exports = (robot) => {
359362
],
360363
});
361364
break;
362-
case /discord/.test(robot.adapterName):
365+
case /discord/.test(adapterName):
363366
msg.send(`__**MoneyPuck.com**__\n${discordFields.join('\n')}`);
364367
break;
365368
default:
@@ -506,7 +509,7 @@ module.exports = (robot) => {
506509
});
507510

508511
// Format based on adapter
509-
if (/(slack|discord)/.test(robot.adapterName)) {
512+
if (/(slack|discord)/.test(adapterName)) {
510513
msg.send(`\`\`\`\n${table.toString()}\n\`\`\``);
511514
} else {
512515
msg.send(table.toString());

0 commit comments

Comments
 (0)