Skip to content

Commit 0ec3242

Browse files
feat: ✨ slack bot replies in public channel now
1 parent 25f297f commit 0ec3242

File tree

3 files changed

+24
-12
lines changed

3 files changed

+24
-12
lines changed

cloud-functions/package-lock.json

+8-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cloud-functions/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@
4242
"web3": "^1.10.0"
4343
},
4444
"devDependencies": {
45-
"@types/cors": "^2.8.13",
45+
"@types/cors": "^2.8.17",
4646
"@types/ejs": "^3.1.2",
4747
"@types/html-to-text": "^9.0.0",
48-
"@types/node-telegram-bot-api": "^0.61.6",
48+
"@types/node-telegram-bot-api": "^0.61.11",
4949
"@types/showdown": "^2.0.1",
5050
"@types/turndown": "^5.0.1",
5151
"@types/uuid": "^9.0.0",

cloud-functions/src/index.ts

+14-2
Original file line numberDiff line numberDiff line change
@@ -1904,9 +1904,15 @@ export const polkasafeSlackBotCommands = functions.https.onRequest(async (req, r
19041904
try {
19051905
// slack needs an acknowledgement response within 3 seconds
19061906
res.status(200).end();
1907-
const { command, text, user_id } = req.body;
1907+
const { command, text, user_id: slackUserId, channel_id } = req.body;
19081908
functions.logger.info('polkasafeSlackBotCommands req :', { req });
19091909

1910+
if (!channel_id && !slackUserId) {
1911+
return;
1912+
}
1913+
1914+
const user_id = channel_id || slackUserId;
1915+
19101916
if (command == '/polkasafe-add') {
19111917
await sendSlackMessage(NOTIFICATION_SOURCE.POLKASAFE, String(user_id), 'Adding address...');
19121918

@@ -2697,9 +2703,15 @@ export const polkassemblySlackBotCommands = functions.https.onRequest(async (req
26972703
try {
26982704
// slack needs an acknowledgement response within 3 seconds
26992705
res.status(200).end();
2700-
const { command, text, user_id } = req.body;
2706+
const { command, text, user_id: slackUserId, channel_id } = req.body;
27012707
functions.logger.info('polkassemblySlackBotCommands req :', { req });
27022708

2709+
if (!slackUserId && !channel_id) {
2710+
return;
2711+
}
2712+
2713+
const user_id = channel_id || slackUserId;
2714+
27032715
if (command == '/polkassembly-add') {
27042716
await sendSlackMessage(NOTIFICATION_SOURCE.POLKASSEMBLY, String(user_id), 'Adding username...');
27052717

0 commit comments

Comments
 (0)