Coin: Clean up the code

This commit is contained in:
veselcraft 2022-05-09 15:12:14 +03:00
parent 13f0cc8a66
commit 85cd1c7554
No known key found for this signature in database
GPG key ID: AED66BC1AC628A4E

View file

@ -70,17 +70,17 @@ class FetchToncoinTransactions extends Command
$response = file_get_contents($url . $data, false, stream_context_create($opts)); $response = file_get_contents($url . $data, false, stream_context_create($opts));
$response = json_decode($response, true); $response = json_decode($response, true);
$header->writeln(["Gonna up the balance of users"]); $header->writeln("Gonna up the balance of users");
foreach($response["result"] as $transfer) { foreach($response["result"] as $transfer) {
$output_array; $output_array;
preg_match('/' . OPENVK_ROOT_CONF["openvk"]["preferences"]["ton"]["regex"] . '/', $transfer["in_msg"]["message"], $output_array); preg_match('/' . OPENVK_ROOT_CONF["openvk"]["preferences"]["ton"]["regex"] . '/', $transfer["in_msg"]["message"], $output_array);
$userid = ctype_digit($output_array[1]) ? intval($output_array[1]) : NULL; $userid = ctype_digit($output_array[1]) ? intval($output_array[1]) : NULL;
if($userid === NULL) { if($userid === NULL) {
$header->writeln(["Well, that's a donation. Thanks! XD"]); $header->writeln("Well, that's a donation. Thanks! XD");
} else { } else {
$user = (new Users)->get($userid); $user = (new Users)->get($userid);
if(!$user) { if(!$user) {
$header->writeln(["Well, that's a donation. Thanks! XD"]); $header->writeln("Well, that's a donation. Thanks! XD");
} else { } else {
$value = ($transfer["in_msg"]["value"] / NANOTON) / OPENVK_ROOT_CONF["openvk"]["preferences"]["ton"]["rate"]; $value = ($transfer["in_msg"]["value"] / NANOTON) / OPENVK_ROOT_CONF["openvk"]["preferences"]["ton"]["rate"];
$user->setCoins($user->getCoins() + $value); $user->setCoins($user->getCoins() + $value);
@ -96,7 +96,7 @@ class FetchToncoinTransactions extends Command
} }
} }
$counter->overwrite("Processing finished :3"); $header->writeln("Processing finished :3");
return Command::SUCCESS; return Command::SUCCESS;
} }