-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandler.js
More file actions
69 lines (54 loc) · 1.7 KB
/
handler.js
File metadata and controls
69 lines (54 loc) · 1.7 KB
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
/**
* @format
*/
const axios = require('axios')
const notification = require('./lib/notification')
const sendTelegramCM = notification.sendTelegramCM
const sendTelegramLogsCM = notification.sendTelegramLogsCM
const checkRozetka = async() => {
const currentTime = Date.now()
const response = await axios.get('https://common-api.rozetka.com.ua/v2/goods/get-price/', {
params: {
id: 223596301
}
})
const data = response.data
if (
(data.sell_status !== 'out_of_stock' && data.sell_status !== 'unavailable') ||
data.has_shops ||
data.show_in_site
) {
sendTelegramCM(`Rozetka: TIME TO BUY PS5 \n currentTime: ${currentTime} \n link https://rozetka.com.ua/playstation_5_digital_edition_2/p223596301/`)
}
const logText = `
--------------------------- \n
log \n
vendor: Rozetka \n
currentTime: ${currentTime} \n
data: ${JSON.stringify(data, '', 2)}
`
sendTelegramLogsCM(logText)
}
const checkALLO = async() => {
const currentTime = Date.now()
const response = await axios.post('https://allo.ua/ua/tsg_catalog/catalog/checkProductsInstock?products=2982445')
const data = response.data['2982445']
if (data.is_salable || data.pre_order) {
sendTelegramCM(`ALLO: TIME TO BUY PS5 \n currentTime: ${currentTime} \n link: https://allo.ua/ua/igrovye-pristavki/konsol-playstation-5-digital-edition.html`)
}
const logText = `
--------------------------- \n
log \n
vendor: ALLO \n
currentTime: ${currentTime} \n
data: ${JSON.stringify(data, '', 2)}
`
sendTelegramLogsCM(logText)
}
const program = async() => {
await checkRozetka()
await checkALLO()
}
module.exports.run = async(event, context, callback) => {
await program()
}