Skip to content

Commit

Permalink
Test Slack message
Browse files Browse the repository at this point in the history
  • Loading branch information
dcadenas committed Mar 27, 2024
1 parent 31f8943 commit 46a0d65
Showing 1 changed file with 60 additions and 6 deletions.
66 changes: 60 additions & 6 deletions src/lib/slack.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,64 @@
const { WebClient } = require("@slack/web-api");

if (!process.env.SLACK_TOKEN) {
throw new Error("SLACK_TOKEN environment variable is required");
}

if (!process.env.CHANNEL_ID) {
throw new Error("CHANNEL_ID environment variable is required");
}

const token = process.env.SLACK_TOKEN;
const channelId = process.env.CHANNEL_ID;
const web = new WebClient(token);
export default class Slack {
static async postManualVerification(reportRequest) {
console.log(
`TODO: Implement Slack.postManualVerification.\n
Event payload: ${JSON.stringify(reportRequest.reportedEvent)}\n
Reporter pubkey: ${reportRequest.reporterPubkey}\n
Reporter text: ${reportRequest.reporterText}`
);
// console.log(
// `TODO: Implement Slack.postManualVerification.\n
// Event payload: ${JSON.stringify(reportRequest.reportedEvent)}\n
// Reporter pubkey: ${reportRequest.reporterPubkey}\n
// Reporter text: ${reportRequest.reporterText}`
// );
try {
const result = await web.chat.postMessage({
channel: channelId,
text: "This is a sample message with buttons",
blocks: [
{
type: "section",
text: {
type: "mrkdwn",
text: "Choose an option:",
},
},
{
type: "actions",
elements: [
{
type: "button",
text: {
type: "plain_text",
text: "Button 1",
},
value: "value-1",
action_id: "action1",
},
{
type: "button",
text: {
type: "plain_text",
text: "Button 2",
},
value: "value-2",
action_id: "action2",
},
],
},
],
});
console.log(result);
} catch (error) {
console.error(error);
}
}
}

0 comments on commit 46a0d65

Please sign in to comment.