diff --git a/.gitignore b/.gitignore index 9daa824..38657be 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .DS_Store node_modules +.env diff --git a/extension/panel/broadcaster.js b/extension/panel/broadcaster.js new file mode 100644 index 0000000..86ac6a7 --- /dev/null +++ b/extension/panel/broadcaster.js @@ -0,0 +1,35 @@ +sendchat.addEventListener('submit', (e) => { + e.preventDefault(); + + sendChat(); +}); + +async function sendChat() { + master_log('Sending Chat Message'); + + let req = await fetch( + 'https://api.twitch.tv/helix/extensions/chat', + { + method: 'POST', + headers: { + ...gojwt, + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ + broadcaster_id: channelId, + text: 'Test message', + extension_id: gojwt['Client-ID'], + extension_version: extensionVersion + }) + } + ); + + //master_log(`Sent Chat Message: ${req.status}`); + if (req.status == 204) { + master_log('Send Chat Message OK'); + return; + } + master_log(`Failed to send chat message: ${req.status}`); + let data = await req.json(); + master_log(`Response: ${data.message}`); +} diff --git a/extension/panel/index.html b/extension/panel/index.html index 6975d52..9eb7765 100644 --- a/extension/panel/index.html +++ b/extension/panel/index.html @@ -23,6 +23,7 @@ +