-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcronbot.php
31 lines (26 loc) · 1.02 KB
/
cronbot.php
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
<?php
require_once('functions.php');
require $_SERVER['DOCUMENT_ROOT'].'/vendor/autoload.php';
use Symfony\Component\Yaml\Yaml;
$conf = Yaml::parseFile('config.yaml');
$api_key = $conf['api_key'];
$body = file_get_contents('php://input');
$arr = json_decode($body, true);
include_once ('telegramgclass.php');
$tg = new tg($api_key);
$gas_res = getPage('https://api.etherscan.io/api?module=gastracker&action=gasoracle');
$gasprice = (float)$gas_res['result']['ProposeGasPrice'];
$chats_json = file_get_contents('chats.json');
$chats = json_decode($chats_json, true);
if ($chats && count($chats) > 0) {
foreach($chats as $id => $options) {
if (isset($options['gas'])) {
$gases = explode('-', $options['gas']);
if (!isset($gases[1]) && (int)$options['gas'] === $gasprice || isset($gases[1]) && $gasprice >= (float)$gases[0] && $gasprice <= (float)$gases[1]) {
$msg = 'Now Ethereum GAS is '.$gasprice.' gwei';
$arInfo = [];
$tg->send($id, $msg, 0, $arInfo);
}
}
}
}