Skip to content

Commit

Permalink
booyah >> twitch
Browse files Browse the repository at this point in the history
  • Loading branch information
elmarceloc committed Apr 15, 2022
1 parent f145090 commit e9d4d41
Show file tree
Hide file tree
Showing 34 changed files with 18,434 additions and 560 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ node_modules/
dist/
electron-builder.yml
render.js
dev-app-update.yml
dev-app-update.yml
renderer/javascript/credentials.js
115 changes: 114 additions & 1 deletion main/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// Modules to control application life and create native browser window
const { Menu, app, BrowserWindow, ipcMain, globalShortcut, dialog } = require("electron");
const AutoLaunch = require('auto-launch');

const pjson = require('../package.json');

const windowStateKeeper = require('electron-window-state');


const http = require('http');
const fs = require('fs');

Expand All @@ -25,9 +27,11 @@ const testVideos = ['WCi2DLYE82A', 'Zvv_0cO-k7M']

const server = require("./server");

const { getAudioUrl } = require('uberduck-api');

try {
if (isDev) {
//require("electron-reloader")(module);
require("electron-reloader")(module);
}
} catch (_) {}

Expand Down Expand Up @@ -185,6 +189,11 @@ async function createWindow() {
settings.get("songrequest.volume").then((volume) => {
mainWindow.webContents.send("getVolume", volume || 100); // default volume of 100
});
// volume
settings.get("polls.slots").then((polls) => {
mainWindow.webContents.send("setPolls", polls); // default volume of 100
});

});

// opens external links in default browser
Expand Down Expand Up @@ -318,6 +327,85 @@ async function createWindow() {
links.clips(username, message, platform);
});


// slots


ipcMain.on("saveSlot", function (e, poll) {
settings.get("polls.slots").then((polls) => {

// if the poll list is null, make it an empty array
if (polls == null) polls = [];

// removes the poll if it is in the saved polls
polls.forEach((testPoll, index, object) => {
if (poll.slot == testPoll.slot) {
object.splice(index, 1);
}
});

// adds the poll to the saved polls
const newPolls = [...(polls || []), poll];

console.log('polls', newPolls)

// save in settings
settings.set("polls", {
slots: newPolls,
});
});

});

ipcMain.on('uberduck', function (id, message) {
getAudioUrl(
'pub_ieyjizcjizsdjdcgmn',
'pk_8ae7bb6a-019f-4aa8-bf26-002f87c87041',
'fernanfloo',
message)
.then((url) => {
console.log('uberduck', url)
mainWindow.webContents.send('uberduck', {
url: url,
id: id
})

})

})


ipcMain.on("removeSlot", function (e, slot) {
settings.get("polls.slots").then((polls) => {

// if the poll list is null, make it an empty array
if (polls == null) polls = [];

// removes the poll if it is in the saved polls
polls.forEach((testPoll, index, object) => {
if (slot == testPoll.slot) {
object.splice(index, 1);
}
});

// save in settings
console.log('polls', polls)

settings.set("polls", {
slots: polls,
});
});
});










mainWindow.once("ready-to-show", () => {
console.log("checking updates...");
autoUpdater.checkForUpdatesAndNotify();
Expand All @@ -330,6 +418,15 @@ async function createWindow() {
app.whenReady().then(() => {
createWindow();

let autoLaunch = new AutoLaunch({
name: 'BooyahVideos',
path: app.getPath('exe'),
});

autoLaunch.isEnabled().then((isEnabled) => {
if (isEnabled) autoLaunch.disable();
});

globalShortcut.register('Alt+CommandOrControl+I', () => {
mainWindow.webContents.send('toggleSongRequest')
})
Expand Down Expand Up @@ -366,7 +463,23 @@ app.whenReady().then(() => {
mainWindow.webContents.send('reduceVolume')
})

globalShortcut.register('Alt+CommandOrControl+h', () => {
mainWindow.webContents.send('reduceVolume')
})

// poll slots (0 - 9)
for (let i = 0; i <= 9; i++) {

globalShortcut.register('Alt+CommandOrControl+'+i, () => {
console.log('Poll slot #'+i)

mainWindow.webContents.send('pollSlot', i)

})

}


/*mainWindow.on('close', (event) => {
event.preventDefault();
dialog.showMessageBox(mainWindow,{
Expand Down
61 changes: 10 additions & 51 deletions main/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,32 +194,6 @@ var menu = Menu.buildFromTemplate([
.catch(console.error);
});
},
},
{
label: "Canal de Booyah.live",
click: function (item, browser) {
settings.get("booyah.name").then((channelURL) => {

prompt({
title: 'Canal de Booyah!',
label: 'Link del Popup del Chat:',
value: channelURL || 'https://booyah.live/standalone/chatroom/79543340',
type: 'input',
alwaysOnTop: true,
})
.then((newChannelURL) => {
if(newChannelURL === null) {

} else {

settings.set("booyah", {
name: newChannelURL,
});
}
})
.catch(console.error);
});
},
}
],
},
Expand All @@ -235,44 +209,29 @@ var menu = Menu.buildFromTemplate([
{
label: "Encuestas",
click: function (item, browser) {
clipboard.writeText('http://199.195.254.68:3000/overlay', 'clipboard')
clipboard.writeText('http://localhost:8080/overlay', 'clipboard')
},
},
{
label: "Preguntas",
click: function (item, browser) {
clipboard.writeText('http://199.195.254.68:3000/overlayquestions', 'clipboard')
clipboard.writeText('http://localhost:8080/overlayquestions', 'clipboard')
},
},
{
label: "Song request",
click: function (item, browser) {
clipboard.writeText('http://199.195.254.68:3000/overlaysongrequest', 'clipboard')
clipboard.writeText('http://localhost:8080/overlaysongrequest', 'clipboard')
},
},
{
label: "Fondo",
click: function (item, browser) {
clipboard.writeText('http://localhost:8080/overlaybackground', 'clipboard')
},
}
],
},
{
label: "Otorgar emblema",
click: function (item, browser) {
prompt({
title: 'Nombre de usuario',
label: 'Nombre de usuario',
value: '',
type: 'input',
alwaysOnTop: true,
})
.then((user) => {
var domain = 'https://bapi.zzls.xyz'
if (isDev) 'http://localhost:40030'

request.post(domain + '/dashboard/donations/remote').form({booyah: user})

})
.catch(console.error);

},
},
}
]);

module.exports = menu;
Loading

0 comments on commit e9d4d41

Please sign in to comment.