-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
43 lines (40 loc) · 1.4 KB
/
index.html
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
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/comfy.js@latest/dist/comfy.min.js"></script>
</head>
<body>
<script type="text/javascript">
const twitchChannel = new URLSearchParams(location.search).get("channel");
const twitchToken = new URLSearchParams(location.search).get("token");
const webhookUrl = new URLSearchParams(location.search).get("webhook");
ComfyJS.onCommand = async ( user, command, message, flags, extra ) => {
if( command === "suggest" ) {
try {
const rsp = await fetch(webhookUrl, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
username: `SuggestBot - ${user}`,
content: `>>> ${message}`,
})
});
if(rsp.ok) {
ComfyJS.Say(`TwitchVotes Thank you (${user}) for the suggestion!`);
} else {
ComfyJS.Say(`CrreamAwk There was a problem saving the suggestion`);
}
} catch(e) {
return `CrreamAwk There was a problem saving the suggestion`;
}
}
}
if(twitchToken) {
ComfyJS.Init( twitchChannel, twitchToken );
} else {
ComfyJS.Init( twitchChannel );
}
</script>
</body>
</html>