-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.ts
121 lines (112 loc) · 2.66 KB
/
app.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
const { App } = require("@slack/bolt");
let { getMeme1: getMeme, getWaifu1: getWaifu } = require("./calls.ts");
//dotenv config
const dotenv = require("dotenv");
dotenv.config();
// Initializes your app with your bot token and signing secret
const app = new App({
token: process.env.SLACK_BOT_TOKEN,
signingSecret: process.env.SLACK_SIGNING_SECRET,
socketMode: true,
appToken: process.env.SLACK_APP_TOKEN,
});
// Listens to incoming messages
//will only catch msgs starting with "yukino"
interface msg {
user: object;
}
app.message(
/^yukino hello/,
async ({ message, say }: { message: msg; say: Function }) => {
await say(
`Hellowo <@${message.user}> san,\n type:'yukino help' for help b-d`
);
}
);
app.message(
/^yukino meme/,
async ({ message, say }: { message: msg; say: Function }) => {
const url: string = await getMeme();
await say({
blocks: [
{
type: "section",
text: {
type: "mrkdwn",
text: `your funny material, <@${message.user}> senpai`,
},
},
{
type: "image",
image_url: `${url}`,
alt_text: "hehe",
},
],
});
}
);
app.message(
/^yukino waifu/,
async ({ message, say }: { message: msg; say: Function }) => {
const url: string = await getWaifu();
await say({
blocks: [
{
type: "section",
text: {
type: "mrkdwn",
text: `presenting you today's waifu <@${message.user}> '~'`,
},
},
{
type: "image",
image_url: `${url}`,
alt_text: "kawaii",
},
],
});
}
);
app.message(
/^yukino help/,
async ({ message, say }: { message: msg; say: Function }) => {
// say() sends a message to the channel where the event was triggered
await say({
blocks: [
{
type: "section",
text: {
type: "mrkdwn",
text: `Here are all my commands, <@${message.user}> sama`,
},
},
{
type: "section",
text: {
type: "mrkdwn",
text: "make sure to call me by *writing my name first*",
},
},
{
type: "section",
text: {
type: "plain_text",
text: ">>meme: get a random anime meme UwU",
},
},
{
type: "section",
text: {
type: "plain_text",
text: ">>waifu: will show you a random waifu >.<",
},
},
],
});
}
);
(async () => {
// Start app
await app.start();
console.log("yukino chan is up and runnin");
})();