-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqrm.js
86 lines (78 loc) · 2.35 KB
/
qrm.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
83
84
85
86
registerPlugin({
name: 'QRM-PLayback',
version: '1.0',
description: 'Plays a given file all x seconds',
author: 'Michael H. <[email protected]>',
backends: ['ts3', 'discord'],
vars: [
{
name: 'autorestart',
title: 'Auto-Restart every X seconds',
type: 'checkbox'
},
{
name: 'talkpower',
title: 'Remove Talkpower on QRM-Channel during Playback',
type: 'checkbox'
},
{
name: 'Track',
indent: 2,
title: 'Play Track',
type: 'track',
conditions: [
{ field: 'autorestart', value: true }
]
},
{
name: 'restarttime',
indent: 2,
title: 'Seconds:',
type: 'number',
placeholder: '1440',
conditions: [
{ field: 'autorestart', value: true }
]
}
]
}, function(sinusbot, config) {
const engine = require('engine');
const backend = require('backend');
const media = require('media');
const event = require('event');
const channel = backend.getCurrentChannel();
var interval = '';
if (!config || typeof config.Track == 'undefined' || typeof config.autorestart == 'undefined') {
config.autorestart = false;
engine.saveConfig(config);
}
if (typeof config.restarttime == 'undefined' || !config.restarttime || !parseInt(config.restarttime) || config.restarttime < 10) {
config.restarttime = 1440;
engine.saveConfig(config);
}
main();
function main() {
if (config.autorestart) {
interval = setInterval(function(){
if (backend.isConnected) {
// engine.log('Auto-Restart QRM Playback ...');
if (config.talkpower) {
channel.update({
neededTalkPower: 5000
});
}
media.playURL(config.Track["url"]);
}
}, config.restarttime * 1000);
}
}
event.on('trackEnd', function (ev) {
if (config.talkower) {
channel.update({
neededTalkPower: 10
});
}
clearInterval(interval);
main();
});
});