diff --git a/http-local-fwd b/http-local-fwd new file mode 160000 index 00000000..76d56412 --- /dev/null +++ b/http-local-fwd @@ -0,0 +1 @@ +Subproject commit 76d5641211f4d31a4ba04c661e312d2962b3d50c diff --git a/sushi-bot/index.test.js b/sushi-bot/index.test.js index 1fc33e45..367a6bd1 100644 --- a/sushi-bot/index.test.js +++ b/sushi-bot/index.test.js @@ -354,6 +354,37 @@ it('does not react to "twitter.com"', async () => { expect(slack.webClient.reactions.add).not.toHaveBeenCalled(); }); +it('reacts to "X" with :twitter:', () => new Promise((resolve) => { + slack.on('reactions.add', ({name, channel, timestamp}) => { + expect(name).toBe('twitter'); + expect(channel).toBe(slack.fakeChannel); + expect(timestamp).toBe(slack.fakeTimestamp); + resolve(); + }); + + slack.eventClient.emit('message', { + channel: slack.fakeChannel, + text: '私のXアカウントは@Sqrt10_31622776です', + user: slack.fakeUser, + ts: slack.fakeTimestamp, + }); +})); + +it('does not react to words including letter "x" (e.g. "fox", "xylophone")', async () => { + slack.webClient.reactions.add.mockReturnValue(null); + + slack.eventClient.emit('message', { + channel: slack.fakeChannel, + text: 'The quick brown fox jumps over the lazy dog.', + user: slack.fakeUser, + ts: slack.fakeTimestamp, + }); + + await new Promise((resolve) => process.nextTick(resolve)); + + expect(slack.webClient.reactions.add).not.toHaveBeenCalled(); +}); + it('reacts to sushi in an attachment', async () => { slack.on('reactions.add', ({ name, channel, timestamp }) => { expect(name).toBe('sushi'); diff --git a/sushi-bot/index.ts b/sushi-bot/index.ts index 19f95da3..b69a48b1 100644 --- a/sushi-bot/index.ts +++ b/sushi-bot/index.ts @@ -358,6 +358,12 @@ export default async function ({eventClient, webClient: slack}: SlackInterface) slack.reactions.add({name: 'x-logo', channel, timestamp}) } } + + { + if (allText.match(/\bx(?!\.com)\b/i)) { + slack.reactions.add({ name: 'twitter', channel, timestamp}) + } + } }); schedule.scheduleJob('0 19 * * *', async (date) => {