Browse Source

refactor webhook

master
beadsland 2 months ago
parent
commit
5f0cf11628
4 changed files with 50 additions and 16 deletions
  1. 1
    1
      NOTICES.md
  2. 1
    0
      html/index.php
  3. 4
    15
      html/js/camera.js
  4. 44
    0
      html/js/webhook.js

+ 1
- 1
NOTICES.md View File

@@ -234,7 +234,7 @@ Public Domain Dedication. https://creativecommons.org/publicdomain/zero/1.0/

Source: https://archive.org/details/slack_sfx

#### html/js/camera.js
#### html/js/webhook.js

incoming-webhooks App API was made by a member of the Slack team to help
connect Slack with a third-party service; these apps may not be tested,

+ 1
- 0
html/index.php View File

@@ -38,6 +38,7 @@
<script src="js/clock.js"></script>
<script src="js/sous.js"></script>
<script src="js/apps.js"></script>
<script src="js/webhook.js"></script>
<script src="js/camera.js"></script>
<script src="js/launch.js"></script>


+ 4
- 15
html/js/camera.js View File

@@ -102,18 +102,12 @@ async function update_frame(node, snap, hook, oldObjectURL) {
var newObjectURL = insert_blob(node, response, oldObjectURL);

if (response.cool) {
var msg = device + " is wonky :'("
await fetch(hook, { method: 'POST', body: JSON.stringify( { text: msg } ) });
console.log(msg)

throwhook( hook, device + " is wonky :'(" );
while(response.cool) {
response = await fetch_frame(node, snap, hook, response.cool);
newObjectURL = insert_blob(node, response, newObjectURL);
}

msg = device + " is steady again :)"
await fetch(hook, { method: 'POST', body: JSON.stringify( { text: msg } ) });
console.log(msg)
throwhook( hook, device + " is steady again :)" );
}

return newObjectURL;
@@ -124,16 +118,11 @@ async function update_frame(node, snap, hook, oldObjectURL) {
*/

async function flipshow_loop(node, snap) {
var hook_url = ".keys/netops_hook"
var response = await fetch(hook_url)
var hook = await response.text()

var oldObjectURL;
var newObjectURL;

var msg = device + " launching on dashcast reload =D"
await fetch(hook, { method: 'POST', body: JSON.stringify( { text: msg } ) });
console.log(msg)
var hook = await gethook(".keys/netops_hook")
throwhook( hook, device + " launching on dashcast reload =D" )

while(true) {
newObjectURL = await update_frame(node, snap, hook, oldObjectURL);

+ 44
- 0
html/js/webhook.js View File

@@ -0,0 +1,44 @@
/*
<!--
####
## Copyright © 2019 Beads Land-Trujillo.
##
## This program is free software: you can redistribute it and/or modify
## it under the terms of the GNU Affero General Public License as published
## by the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU Affero General Public License for more details.
##
## You should have received a copy of the GNU Affero General Public License
## along with this program. If not, see <https://www.gnu.org/licenses/>.
####

incoming-webhooks App API was made by a member of the Slack team to help
connect Slack with a third-party service; these apps may not be tested,
documented, or supported by Slack in the way we support our core offerings,
like Slack Enterprise Grid and Slack for Teams. You may provide feedback
about these apps at <mailto:feedback@slack.com>.

It only uses data Slack already has access to (view our Privacy Policy to
learn more). By enabling and/or using this app, you may be connecting with
a service that is not part of Slack.

Getting started: https://api.slack.com/incoming-webhooks
*/

'use strict';

async function gethook(hook_url) {
var response = await fetch(hook_url)
var hook = await response.text()
return hook
}

async function throwhook(hook, msg) {
await fetch(hook, { method: 'POST', body: JSON.stringify( { text: msg } ) });
console.log(msg)
}

Loading…
Cancel
Save