-
Notifications
You must be signed in to change notification settings - Fork 1
/
interface.js
82 lines (70 loc) · 2.17 KB
/
interface.js
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
const {ipcMain, ipcRenderer, app, BrowserWindow, globalShortcut} = require('electron');
const channelLogin = require('./channelLogin.js');
const delay = ms => new Promise(res => setTimeout(res, ms));
function boot()
{
var win = new BrowserWindow
({
width: 1280,
height: 720,
resizable: true,
webPreferences: {
contextIsolation: false,
enableRemoteModule: true,
nodeIntegration: true,
nativeWindowOpen: true
}
});
win.loadURL(`file://${__dirname}/interface/index.html`);
win.removeMenu();
//win.webContents.openDevTools();
ipcMain.on("channelConnect", async (event) =>
{
var connect = await channelLogin.boot();
if(connect === true)
{
win.webContents.executeJavaScript("channelConnected();");
require('./bot.js').botStart();
}
else
{
win.webContents.executeJavaScript("channelConnectFailed();");
}
});
ipcMain.on("channelDisconnect", function()
{
win.webContents.executeJavaScript("channelDisconnected();");
require('./bot.js').botDisconnect();
channelLogin.closeChat();
});
ipcMain.on("channelLogOut", function()
{
const ses = win.webContents.session;
ses.clearStorageData();
});
ipcMain.on("restartBot", async function()
{
require('./bot.js').botDisconnect();
require('./bot.js').botStart();
await delay(5000);
win.webContents.executeJavaScript("botRestarted();");
});
win.on('closed', () => {
app.exit(0);
});
win.on("focus", () => {
globalShortcut.register("CommandOrControl+F", function () {
if (win && win.webContents)
{
win.webContents.send("on-find", "");
}
});
});
win.on("blur", () => {
globalShortcut.unregister("CommandOrControl+F");
});
app.on("window-all-closed", () => {
globalShortcut.unregister("CommandOrControl+F");
});
};
app.on('ready', boot);