First working version.

This commit is contained in:
t1amak
2025-05-29 00:34:19 +00:00
parent d6ca3049ae
commit 9f9738591c
10 changed files with 235 additions and 189 deletions

View File

@@ -0,0 +1,24 @@
<?php
function sendMessage(int $chatId, string $text, array $options = []): void {
global $config;
$url = "https://api.telegram.org/bot{$config['TELEGRAM_BOT_TOKEN']}/sendMessage";
$payload = array_merge(['chat_id' => $chatId, 'text' => $text], $options);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($payload));
if (!empty($config['IPV4_ONLY'])) {
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
}
curl_exec($ch);
curl_close($ch);
}
function isValidSalviumAddress(string $address): bool {
// Accepts standard and subaddress prefixes for Salvium (e.g. SaLvd, SaLvs)
return preg_match('/^SaLv[a-zA-Z0-9]{95}$/', $address) === 1;
}
?>