forked from dvishal485/price-tracker-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAutomation.js
43 lines (40 loc) · 1.42 KB
/
Automation.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
function subhe() {
del()
ScriptApp.newTrigger('pincodeBatchCompare').timeBased().everyMinutes(5).create();
ScriptApp.newTrigger('raat').timeBased().atHour(1).nearMinute(45).inTimezone('Asia/Kolkata').everyHours(1).create()
var keyboardButtons = [
{ "text": "Turn Off", "callback_data": `/raat` }
]
sendButtonMessage('🌞 Turned on Pincode mode feature!', null, ownerid, keyboardButtons)
}
function raat() {
del()
ScriptApp.newTrigger('subhe').timeBased().atHour(10).nearMinute(30).inTimezone('Asia/Kolkata').everyHours(1).create()
var keyboardButtons = [
{ "text": "Turn On", "callback_data": `/subhe` }
]
sendButtonMessage('🌑 Turned off Pincode mode feature!', null, ownerid, keyboardButtons)
}
function batchCompare() {
compare(null, null, true)
}
function pincodeBatchCompare() {
pincodeCompare(null, null, true)
}
function restart(time, data) {
// Do not use restart function
try {
var t = parseInt(time)
if (t == 5 || t == 10 || t == 30 || t == 15) {
del()
ScriptApp.newTrigger('batchCompare').timeBased().everyMinutes(t).create();
sendMessage(`Running code every ${t} minute`, data)
}
} catch (e) { sendReport(Error(e).message) }
}
function del() {
var Triggers = ScriptApp.getProjectTriggers();
for (var i = 0; i < Triggers.length; i++) {
ScriptApp.deleteTrigger(Triggers[i])
}
}