mirror of
https://github.com/openvk/openvk
synced 2024-11-13 10:39:24 +03:00
Coin: Add dialog with QR-code and requisites + tweak config
This commit is contained in:
parent
cc6771ea70
commit
04ab845382
6 changed files with 66 additions and 15 deletions
|
@ -51,7 +51,7 @@ class FetchToncoinTransactions extends Command
|
|||
}
|
||||
|
||||
$testnet_subdomain = OPENVK_ROOT_CONF["openvk"]["preferences"]["ton"]["testnet"] ? "testnet." : "";
|
||||
$url = "https://" . $testnet_subdomain . "toncenter.com/api/v2/getTransactions?";
|
||||
$url = "https://" . $testnet_subdomain . "toncenter.com/api/v2/getTransactions?";
|
||||
|
||||
$opts = [
|
||||
"http" => [
|
||||
|
@ -61,8 +61,8 @@ class FetchToncoinTransactions extends Command
|
|||
];
|
||||
|
||||
$selection = $this->transactions->select('hash, lt')->order("id DESC")->limit(1)->fetch();
|
||||
$tr_hash = $selection->hash ?? NULL;
|
||||
$tr_lt = $selection->lt ?? NULL;
|
||||
$tr_hash = $selection->hash ?? NULL;
|
||||
$tr_lt = $selection->lt ?? NULL;
|
||||
|
||||
$data = http_build_query([
|
||||
"address" => OPENVK_ROOT_CONF["openvk"]["preferences"]["ton"]["address"],
|
||||
|
@ -78,17 +78,13 @@ class FetchToncoinTransactions extends Command
|
|||
foreach($response["result"] as $transfer)
|
||||
{
|
||||
$output_array;
|
||||
preg_match('/ovk=([0-9]+)/', $transfer["in_msg"]["message"], $output_array);
|
||||
$userid = ctype_digit($output_array[1]) ? intval($output_array[1]) : null;
|
||||
if($userid === null)
|
||||
{
|
||||
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;
|
||||
if($userid === NULL) {
|
||||
$header->writeln(["Well, that's a donation. Thanks! XD"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$user = (new Users)->get($userid);
|
||||
if(!$user)
|
||||
{
|
||||
if(!$user) {
|
||||
$header->writeln(["Well, that's a donation. Thanks! XD"]);
|
||||
} else {
|
||||
$value = ($transfer["in_msg"]["value"] / NANOTON) / OPENVK_ROOT_CONF["openvk"]["preferences"]["ton"]["rate"];
|
||||
|
@ -97,9 +93,9 @@ class FetchToncoinTransactions extends Command
|
|||
(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"]);
|
||||
$this->transactions->insert([
|
||||
"id" => null,
|
||||
"id" => NULL,
|
||||
"hash" => $transfer["transaction_id"]["hash"],
|
||||
"lt" => $transfer["transaction_id"]["lt"]
|
||||
"lt" => $transfer["transaction_id"]["lt"]
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -449,6 +449,18 @@ final class UserPresenter extends OpenVKPresenter
|
|||
"main", "privacy", "finance", "finance.top-up", "interface"
|
||||
]) ? $this->queryParam("act")
|
||||
: "main";
|
||||
|
||||
if($this->template->mode == "finance") {
|
||||
$address = OPENVK_ROOT_CONF["openvk"]["preferences"]["ton"]["address"];
|
||||
$text = str_replace("$1", $this->user->identity->getId(), OPENVK_ROOT_CONF["openvk"]["preferences"]["ton"]["hint"]);
|
||||
$qrCode = explode("base64,", (new QRCode(new QROptions([
|
||||
"imageTransparent" => false
|
||||
])))->render("ton://transfer/$address?text=$text"));
|
||||
|
||||
$this->template->qrCodeType = substr($qrCode[0], 5);
|
||||
$this->template->qrCodeData = $qrCode[1];
|
||||
}
|
||||
|
||||
$this->template->user = $user;
|
||||
$this->template->themes = Themepacks::i()->getThemeList();
|
||||
}
|
||||
|
|
|
@ -383,7 +383,10 @@
|
|||
{_on_your_account}
|
||||
<div style="width: 100%; height: 60px; font-weight: 100;" id="balance">{$thisUser->getCoins()}</div>
|
||||
{_points_count}<br/>
|
||||
<small><a href="?act=finance.top-up">[{_have_voucher}?]</a></small>
|
||||
<small><a href="?act=finance.top-up">[{_have_voucher}?]</a></small><br>
|
||||
<small n:if="OPENVK_ROOT_CONF['openvk']['preferences']['ton']['enabled']">
|
||||
<a href="javascript:showCoinsTopUpTroughTon()">[{_transfer_trough_ton}]</a>
|
||||
</small>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
@ -393,6 +396,28 @@
|
|||
|
||||
balance.style.width = Math.ceil(balance.parentNode.getBoundingClientRect().width) + "px";
|
||||
textFit(balance, { alignVert: true });
|
||||
|
||||
function convertCurrency(coin) {
|
||||
var currencyTON = {php echo OPENVK_ROOT_CONF['openvk']['preferences']['ton']['rate']};
|
||||
u('.coins_dialog_conv').nodes[0].innerHTML = tr("transfer_ton_currency_per_ton", coin * currencyTON);
|
||||
}
|
||||
|
||||
function showCoinsTopUpTroughTon() {
|
||||
MessageBox(tr("transfer_trough_ton"), `
|
||||
<div class="messagebox-content-header">
|
||||
${ tr("transfer_ton_contents") }
|
||||
</div>
|
||||
<div style="margin-top: 30px">` +
|
||||
{tr("transfer_ton_address", OPENVK_ROOT_CONF['openvk']['preferences']['ton']['address'], str_replace("$1", $thisUser->getId(), OPENVK_ROOT_CONF["openvk"]["preferences"]["ton"]["hint"]))} +
|
||||
`<div style="text-align: center;">
|
||||
<img width="225" height="225" src="data:` + {$qrCodeType} + `;base64,` + {$qrCodeData} + `"><br>
|
||||
<input oninput="convertCurrency(this.value)"> = <span class="coins_dialog_conv">0 TON</span>
|
||||
</div>
|
||||
</div>`
|
||||
, [tr("close")], [
|
||||
Function.noop
|
||||
]);
|
||||
}
|
||||
</script>
|
||||
|
||||
{elseif $isFinanceTU}
|
||||
|
|
|
@ -592,6 +592,11 @@
|
|||
|
||||
"transferred_to_you" = "transferred to you";
|
||||
|
||||
"transfer_trough_ton" = "Top up with TON";
|
||||
"transfer_ton_contents" = "You can top up your balance with TON cryptocurrency. It's just enough to scan the QR-code with the Tonkeeper app, or manually send TON according to the requisites. Within a few minutes you will receive a certain amount of votes.";
|
||||
"transfer_ton_address" = "<b>Wallet address:</b> $1<br/><b>Message content:</b> $2";
|
||||
"transfer_ton_currency_per_ton" = "$1 TON";
|
||||
|
||||
"receiver_address" = "Receiver address";
|
||||
"coins_count" = "Number of votes";
|
||||
"message" = "Message";
|
||||
|
|
|
@ -624,6 +624,11 @@
|
|||
|
||||
"transferred_to_you" = "передал вам";
|
||||
|
||||
"transfer_trough_ton" = "Пополнить с помощью TON";
|
||||
"transfer_ton_contents" = "Вы можете пополнить ваш баланс с помощью криптовалюты TON. Достаточно отсканировать QR-code приложением Tonkeeper, или вручную отправить TON по реквизитам. В течении нескольких минут вам придут определенное количество голосов.";
|
||||
"transfer_ton_address" = "<b>Адрес кошелька:</b> $1<br/><b>Содержание сообщения:</b> $2";
|
||||
"transfer_ton_currency_per_ton" = "$1 TON";
|
||||
|
||||
"receiver_address" = "Адрес получателя";
|
||||
"coins_count" = "Количество голосов";
|
||||
"message" = "Сообщение";
|
||||
|
|
|
@ -53,6 +53,14 @@ openvk:
|
|||
processingLimit: 3000
|
||||
emojiProcessingLimit: 1000
|
||||
commerce: false
|
||||
ton:
|
||||
enabled: false
|
||||
address: "🅿"
|
||||
testnet: false # Only for testing purposes.
|
||||
rate: 0.02 # TONs per 1 coin
|
||||
regex: "ovk=([0-9]+)"
|
||||
hint: "ovk=$1"
|
||||
# Please read docs to understand how to turn on automatic checking for new translations
|
||||
menu:
|
||||
links:
|
||||
- name: "@left_menu_donate"
|
||||
|
|
Loading…
Reference in a new issue