Coin: cleanup code

This commit is contained in:
veselcraft 2022-05-07 18:49:14 +03:00
parent 04ab845382
commit 13f0cc8a66
No known key found for this signature in database
GPG key ID: AED66BC1AC628A4E

View file

@ -33,7 +33,6 @@ class FetchToncoinTransactions extends Command
protected function execute(InputInterface $input, OutputInterface $output): int protected function execute(InputInterface $input, OutputInterface $output): int
{ {
$header = $output->section(); $header = $output->section();
$counter = $output->section();
$header->writeln([ $header->writeln([
"TONCOIN Fetcher", "TONCOIN Fetcher",
@ -41,12 +40,9 @@ class FetchToncoinTransactions extends Command
"", "",
]); ]);
if(!OPENVK_ROOT_CONF["openvk"]["preferences"]["ton"]["enabled"]) if(!OPENVK_ROOT_CONF["openvk"]["preferences"]["ton"]["enabled"]) {
{ $header->writeln("Sorry, but you handn't enabled the TON support in your config file yet.");
$header->writeln([
"Sorry, but you handn't enabled the TON support in your config file yet.",
"",
]);
return Command::FAILURE; return Command::FAILURE;
} }
@ -75,8 +71,7 @@ class FetchToncoinTransactions extends Command
$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;
@ -91,7 +86,7 @@ class FetchToncoinTransactions extends Command
$user->setCoins($user->getCoins() + $value); $user->setCoins($user->getCoins() + $value);
$user->save(); $user->save();
(new CoinsTransferNotification($user, (new Users)->get(OPENVK_ROOT_CONF["openvk"]["preferences"]["support"]["adminAccount"]), 0, "Via TON cryptocurrency"))->emit(); (new CoinsTransferNotification($user, (new Users)->get(OPENVK_ROOT_CONF["openvk"]["preferences"]["support"]["adminAccount"]), 0, "Via TON cryptocurrency"))->emit();
$header->writeln([$value . " coins are added to " . $user->getId() . " user id"]); $header->writeln($value . " coins are added to " . $user->getId() . " user id");
$this->transactions->insert([ $this->transactions->insert([
"id" => NULL, "id" => NULL,
"hash" => $transfer["transaction_id"]["hash"], "hash" => $transfer["transaction_id"]["hash"],