{"id":383786,"date":"2024-06-29T05:06:21","date_gmt":"2024-06-29T05:06:21","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=383786"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=383786","title":{"rendered":"<span>\u0422\u0435\u043b\u0435\u0433\u0440\u0430\u043c-\u0431\u043e\u0442 \u043a\u0440\u0438\u043f\u0442\u043e\u0432\u0430\u043b\u044e\u0442\u043d\u043e\u0433\u043e \u043a\u043e\u0448\u0435\u043b\u044c\u043a\u0430 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435\u00a0 php-telegram-bot<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442-\u043a\u043e\u043c\u043c\u0435\u0440\u0446\u0438\u0438 \u0441\u0435\u0439\u0447\u0430\u0441 \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u0435\u0441\u0441\u0435\u043d\u0434\u0436\u0435\u0440\u043e\u0432. \u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0431\u043e\u0442\u044b \u0440\u0430\u0441\u0442\u0443\u0442, \u043a\u0430\u043a \u0433\u0440\u0438\u0431\u044b \u043f\u043e\u0441\u043b\u0435 \u0434\u043e\u0436\u0434\u044f. \u0422\u0443\u0442 \u0432\u0430\u043c \u0438 \u043c\u0430\u0433\u0430\u0437\u0438\u043d\u044b, \u0438 \u043e\u043d\u043b\u0430\u0439\u043d-\u043f\u043e\u043c\u043e\u0449\u043d\u0438\u043a\u0438, \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0438, \u0438 \u043f\u0440\u043e\u0447\u0438\u0435 \u0432\u0430\u0436\u043d\u044b\u0435 \u0438 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f. \u0421\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u0431\u043e\u0442 \u0432 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043c\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0446\u0435\u043b\u044b\u0439 \u0441\u0430\u0439\u0442 \u0438 \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0431\u0438\u0437\u043d\u0435\u0441 \u043d\u0430 \u043d\u043e\u0432\u044b\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c. \u0414\u0430\u0436\u0435 \u043a\u0440\u0438\u043f\u0442\u043e\u0432\u0430\u043b\u044e\u0442\u043d\u044b\u0439 \u043a\u043e\u0448\u0435\u043b\u0435\u043a \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0431\u043e\u0442\u0430. \u042d\u0442\u0438\u043c \u0438 \u0437\u0430\u0439\u043c\u0435\u043c\u0441\u044f.<\/p>\n<p>\u0414\u043b\u044f \u0431\u044b\u0441\u0442\u0440\u043e\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c PHP, \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u043e\u0434\u043d\u0443 \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0441 core.telegram.org (<a href=\"https:\/\/core.telegram.org\/bots\/samples\" rel=\"noopener noreferrer nofollow\"><u>https:\/\/core.telegram.org\/bots\/samples<\/u><\/a>) php-telegram-bot\u00a0 (<a href=\"https:\/\/github.com\/php-telegram-bot\/core\/\" rel=\"noopener noreferrer nofollow\"><u>https:\/\/github.com\/php-telegram-bot\/core\/<\/u><\/a>). \u042d\u0442\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0447\u0430\u0441\u0442\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u043e\u0442\u0430.<\/p>\n<p>\u0412 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u0435 \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e API-\u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043a\u0440\u0438\u043f\u0442\u043e\u0432\u0430\u043b\u044e\u0442\u0430\u043c\u0438:<\/p>\n<ol>\n<li>\n<p><a href=\"https:\/\/www.coinpayments.net\/apidoc\" rel=\"noopener noreferrer nofollow\"><u>https:\/\/www.coinpayments.net\/apidoc<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/confirmonetapi.docs.apiary.io\" rel=\"noopener noreferrer nofollow\"><u>https:\/\/confirmonetapi.docs.apiary.io<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.blockchain.com\/ru\/api\/blockchain_wallet_api\" rel=\"noopener noreferrer nofollow\"><u>https:\/\/www.blockchain.com\/ru\/api\/blockchain_wallet_api<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.alfacoins.com\/developers\/api-documentation\" rel=\"noopener noreferrer nofollow\"><u>https:\/\/www.alfacoins.com\/developers\/api-documentation<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/apirone.com\/docs\/wallet\" rel=\"noopener noreferrer nofollow\">https:\/\/apirone.com\/docs\/wallet<\/a><\/p>\n<\/li>\n<\/ol>\n<p>\u0412\u043e \u0432\u0441\u0435\u0445 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u0445 \u043d\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 KYC \u0438 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u0430\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f. Blockchain.info \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0442\u043e\u043a\u0435\u043d\u0430 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b, \u043e\u043d \u0443\u0441\u043b\u043e\u0432\u043d\u043e \u0431\u0435\u0437 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438, \u043d\u043e \u0435\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u043d\u044f\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u043d\u0435\u0439 \u0438\u043b\u0438 \u0434\u0430\u0436\u0435 \u043d\u0435\u0434\u0435\u043b\u044c.<\/p>\n<p>\u0412\u044b\u0431\u043e\u0440 \u043f\u0430\u043b \u043d\u0430 \u0441\u0435\u0440\u0432\u0438\u0441 Apirone, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0442\u0443\u0442 \u043d\u0435\u0442 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439 \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043a\u043e\u0448\u0435\u043b\u044c\u043a\u043e\u0432 \u0438 \u0430\u0434\u0440\u0435\u0441\u043e\u0432.<\/p>\n<p>    \u0418\u0442\u0430\u043a, \u043d\u0430\u0448 \u0431\u043e\u0442 \u0431\u0443\u0434\u0435\u0442 \u0443\u043c\u0435\u0442\u044c:<\/p>\n<ul>\n<li>\n<p>\u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043a\u0440\u0438\u043f\u0442\u043e\u0432\u0430\u043b\u044e\u0442\u043d\u044b\u0439 \u043a\u043e\u0448\u0435\u043b\u0435\u043a \u0432 \u043d\u0443\u0436\u043d\u043e\u0439 \u0432\u0430\u043b\u044e\u0442\u0435,\u00a0<\/p>\n<\/li>\n<li>\n<p>\u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0431\u0430\u043b\u0430\u043d\u0441,\u00a0<\/p>\n<\/li>\n<li>\n<p>\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0440\u0438\u043f\u0442\u043e\u0432\u0430\u043b\u044e\u0442\u043d\u044b\u0439 \u0430\u0434\u0440\u0435\u0441,\u00a0<\/p>\n<\/li>\n<li>\n<p>\u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0442\u043d\u0443\u044e \u0441\u0432\u044f\u0437\u044c (\u043a\u043e\u043b\u0431\u044d\u043a) \u043e\u0442 \u043a\u0440\u0438\u043f\u0442\u043e\u0432\u0430\u043b\u044e\u0442\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0438\u043d\u0433\u0430,\u00a0<\/p>\n<\/li>\n<li>\n<p>\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0438\u043c\u0435\u044e\u0449\u0438\u0445\u0441\u044f \u0441\u0440\u0435\u0434\u0441\u0442\u0432.\u00a0<\/p>\n<\/li>\n<\/ul>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/dab\/1bb\/9cd\/dab1bb9cd25d227fdd14f0470a9f8b58.png\" width=\"431\" height=\"129\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/dab\/1bb\/9cd\/dab1bb9cd25d227fdd14f0470a9f8b58.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412\u0441\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043a\u043e\u043b\u0431\u044d\u043a\u043e\u0432 \u043e\u0442 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u0430 \u0443\u0436\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0432 php-telegram-bot .<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0447\u0435\u0440\u0435\u0437 <a href=\"https:\/\/telegram.me\/BotFather\" rel=\"noopener noreferrer nofollow\"><u>@BotFather<\/u><\/a> \u043d\u043e\u0432\u043e\u0433\u043e \u0431\u043e\u0442\u0430, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0431\u043e\u0442\u0430 \u0438 \u043a\u043b\u044e\u0447 API. \u0414\u0430\u043b\u0435\u0435 \u0440\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c php-telegram-bot\u00a0 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Composer. \u041d\u0430\u0434\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0431\u043e\u0442\u0430 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f SSL \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442 \u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0435 \u0434\u043e\u043c\u0435\u043d\u043d\u043e\u0435 \u0438\u043c\u044f. \u0412 \u043a\u043e\u043d\u0444\u0438\u0433 composer.json \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 monolog, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u0442\u043b\u0430\u0434\u043a\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439.\u00a0\u0412 \u0441\u0435\u043a\u0446\u0438\u0438 autoload \u0441\u0440\u0430\u0437\u0443 \u0443\u043a\u0430\u0436\u0435\u043c, \u0447\u0442\u043e \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e Classes \u0432 \u043f\u0430\u043f\u043a\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<pre><code class=\"bash\">{    \"require\": {        \"longman\/telegram-bot\": \"^0.74.0\",        \"monolog\/monolog\": \"^2.2\"    },    \"autoload\": {        \"classmap\": [\"Classes\"]    } }<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c composer update \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b. \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0435\u0435 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0442\u0443\u0434\u0430 \u043f\u0430\u043f\u043a\u0443\u00a0 Apirone \u0438 \u0432 \u043d\u0435\u0435 \u0444\u0430\u0439\u043b ApironeWallet.php, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043a\u043b\u0430\u0441\u0441 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u043a\u0440\u0438\u043f\u0442\u043e\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0438\u043d\u0433\u043e\u043c.<\/p>\n<p>\u0412 \u043d\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<pre><code class=\"bash\">getWallets($user_id, $currencyId = null) \/\/\u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043a\u043e\u0448\u0435\u043b\u044c\u043a\u0438 \u0434\u043b\u044f telegram \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f addWallet($user_id, $wallet, $address) \/\/add generated wallet into DB postWallet($user_id, $currency) \/\/get wallet from Apirone createWallets($user_id) \/\/create all available wallets getCurrencyId($currency,$units = null) \/\/get currency id from DB getAddress($chat_id, $user_id, $currency) \/\/outputs wallet from DB getAvailableCurrencies() \/\/collect available currencies from DB getCurrencyById($id, $units = null) \/\/ return currency by Id getBalance($chat_id, $user_id, $wallet_id = null) \/\/ get wallet or wallets balance checkAddress($currency, $address) \/\/ validate crypto address estimate($user_id, $currencyName, $address, $amount) \/\/ pre-calculation of crypto transaction transfer($user_id, $currencyName, $address, $amount) \/\/ transfer funds explorerUrl($currency, $tx) \/\/ get explorer link<\/code><\/pre>\n<p>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0443 \u044d\u0442\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435.\u00a0\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c <strong>MySQL <\/strong>\u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445, \u043e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u043d\u0443\u0436\u043d\u0430 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0438\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u0434\u0438\u0430\u043b\u043e\u0433\u043e\u0432. \u0412 \u043d\u0435\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0442\u0440\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b: apirone_currencies,\u00a0 apirone_transactions \u0438\u00a0 apirone_users.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/5ab\/d3f\/135\/5abd3f1358de4b5b012cef3a9464a894.png\" width=\"1529\" height=\"709\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/5ab\/d3f\/135\/5abd3f1358de4b5b012cef3a9464a894.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041d\u0430\u0441\u0442\u0440\u043e\u0438\u043c config.php:<\/p>\n<pre><code class=\"php\">&lt;?php   return [    \/\/ Add you bot's API key and name    'api_key'      => 'key',    'bot_username' => 'botName', \/\/ Without \"@\"      \/\/ When using the getUpdates method, this can be commented out    'webhook'      => [        'url' => 'https:\/\/example.com\/hook.php',    ],      'apirone_secret' => 'secret',    'apirone_callback' => 'http:\/\/example.com\/callback.php',    \/\/ All command related configs go here    'commands'     => [        \/\/ Define all paths for your custom commands        'paths'   => [            __DIR__ . '\/Commands',        ],      \/\/ Define all IDs of admin users    'admins'       => [        00000,    ],      \/\/ Enter your MySQL database credentials    'mysql'        => [        'host'     => 'localhost',        'user'     => 'telegram_bot',        'password' => 'password',        'database' => 'telegram_bot',    ],      \/\/Logging (Debug, Error and Raw Updates)    'logging'  => [        'debug'  => __DIR__ . '\/php-telegram-bot-debug.log',        'error'  => __DIR__ . '\/php-telegram-bot-error.log',        'update' => __DIR__ . '\/php-telegram-bot-update.log',    ],      \/\/ Set custom Upload and Download paths    'paths'        => [        'download' => __DIR__ . '\/Download',        'upload'   => __DIR__ . '\/Upload',    ],      \/\/ Requests Limiter (tries to prevent reaching Telegram API limits)    'limiter'      => [        'enabled' => true,    ], ];<\/code><\/pre>\n<p>\u0421 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043e\u043c \u0431\u0443\u0434\u0435\u043c \u043e\u0431\u0449\u0430\u0442\u044c\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u0435\u0431\u0445\u0443\u043a\u043e\u0432 (Webhook). \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e <strong>set.php<\/strong> \u0438 <strong>unset.php<\/strong> &#8212; \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u0431\u044d\u043a\u043e\u0432. <strong>hook.php <\/strong>\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0441\u0430\u043c\u0438 \u043a\u043e\u043b\u0431\u044d\u043a\u0438 \u0438\u0437 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u0430:<\/p>\n<pre><code class=\"php\">   $telegram->handle();<\/code><\/pre>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0432\u0435\u0431\u0445\u0443\u043a\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0432 \u0434\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<pre><code>   $result = $telegram->setWebhook($config['webhook']['url']);    $result = $telegram->deleteWebhook();<\/code><\/pre>\n<p>\u0412 \u043a\u043e\u0440\u043d\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043d\u0443\u0436\u043d\u0430 \u043f\u0430\u043f\u043a\u0430 Commands, \u0432 \u043d\u0435\u0435 \u0437\u0430\u043f\u0438\u0448\u0435\u043c \u043d\u0430\u0448\u0438 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435. \u0418\u0437 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u0430\u0445 \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441 \u043c\u0435\u043d\u044e \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0445\u0441\u044f \u0441\u043e \u0441\u043b\u044d\u0448\u0430, \u043d\u043e \u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 \u043f\u0430\u043f\u043a\u0435 Commands \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0430\u043f\u043a\u0443 ServiceMessages \u0438 \u0432 \u043d\u0435\u0439 \u0441\u043e\u0437\u0434\u0430\u0435\u043c GenericmessageCommand.php , \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0443\u0442\u0435\u043c \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0432\u043d\u043e\u0441\u0438\u043c \u043d\u0443\u0436\u043d\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0438 \u0440\u0435\u0430\u043a\u0446\u0438\u0438 \u043d\u0430 \u043d\u0438\u0445:  <\/p>\n<pre><code class=\"bash\">       \/\/ Fetch conversation command if it exists and execute it.        if ($conversation->exists() &amp;&amp; $command = $conversation->getCommand()) {            return $this->telegram->executeCommand($command);        }               if($type === \"text\") {            $text = $message->getText(true);            if (stripos($text, 'Receive') === 0) {                return $this->telegram->executeCommand('receive');            }            if (stripos($text, 'Menu') === 0) {                return $this->telegram->executeCommand('menu');            }              if (stripos($text, 'Balance') === 0) {                return $this->telegram->executeCommand('balance');            }            if (stripos($text, 'Send') === 0) {                return $this->telegram->executeCommand('send');            }            return $this->replyToChat(                'Command not found'            );        }<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u0430\u0448\u0438 \u0447\u0435\u0442\u044b\u0440\u0435 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b BalanceCommand.php , MenuCommand.php , ReceiveCommand.php \u0438 SendCommand.php.\u00a0<\/p>\n<p>\u041a\u0430\u0436\u0434\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u0435 \u0434\u0435\u043b\u0430\u0435\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u043c \u0432\u0435\u0440\u0441\u0438\u044e.<\/p>\n<pre><code class=\"bash\">   protected $name = 'balance';    protected $description = 'Show balance of wallet';    protected $usage = '\/balance';    protected $version = '1.2.0';<\/code><\/pre>\n<p>\u0421\u0430\u043c \u043a\u043e\u0434 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0437\u0430\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e execute(). \u0412 \u043d\u0435\u0439 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u043e\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043c\u043e\u0442\u0440\u0438\u0442 \u0431\u0430\u043b\u0430\u043d\u0441<\/p>\n<pre><code class=\"bash\">       $message = $this->getMessage();        $text    = $message->getText(true);        $chat    = $message->getChat();        $user    = $message->getFrom();        $chat_id = $chat->getId();        $user_id = $user->getId();    $sql = '        SELECT *        FROM `apirone_currencies`      ';      $pdo = DB::getPdo();      $sth = $pdo->prepare($sql);      $sth->execute();      $result = $sth->fetchAll(PDO::FETCH_ASSOC);      foreach ($result as $currency) {        if (stripos($text, $currency['name']) === 8) {            $response = new ApironeWallet;     $response->getAddress($chat_id,$user_id,$currency['name']);            return Request::emptyResponse();        }      }      if ($text === 'Balance' || $text ==='') {        $response = new ApironeWallet;        $response->getBalance($chat_id, $user_id);    }      return Request::emptyResponse();<\/code><\/pre>\n<p>SendCommand.php \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u043c. \u0412 \u043d\u0435\u043c \u0431\u043e\u0442 \u0441\u043f\u0440\u043e\u0441\u0438\u0442 \u043a\u0440\u0438\u043f\u0442\u043e\u0432\u0430\u043b\u044e\u0442\u0443, \u0430\u0434\u0440\u0435\u0441 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430 \u0441\u0440\u0435\u0434\u0441\u0442\u0432 \u0438 \u0441\u0443\u043c\u043c\u0443 \u043f\u043b\u0430\u0442\u0435\u0436\u0430.<\/p>\n<pre><code class=\"bash\">$this->conversation = new Conversation($user_id, $chat_id, $this->getName());          \/\/ Load any existing notes from this conversation        $notes = &amp;$this->conversation->notes; \u2026      \/\/ Every time a step is achieved the state is updated          if($text === 'Cancel') {            $state = 4;            $notes['answer'] = 'Cancel';        }        if($text === 'Send') {            $text = '';        }        switch ($state) {            case 0:                $currencies = $apirone->getAvailableCurrencies();                if ($text === '' || !in_array(strtoupper($text), $currencies, true)) {                   ...                    $data['reply_markup'] = (new Keyboard(                    [$currencies[0],$currencies[1]],                    [$currencies[2],$currencies[3],$currencies[4]],                    ['Cancel']))                            ->setResizeKeyboard(true)                            ->setOneTimeKeyboard(true)                            ->setSelective(true);                                   $result = Request::sendMessage($data);                    break;                }                $notes['currency'] = strtolower($text);                $text          = '';             case 1:                if ($text === ''|| !$apirone->checkAddress($notes['currency'], $text)) {                    $notes['state'] = 1;                    $this->conversation->update();                      $data['text'] = 'Type address for transfer:';                    if ($text !== '') {               ...                    break;                }                  $notes['address'] = $text;                $text          = '';              \/\/ No break!            case 2:                   \u2026            case 3:                if ($text === '' || !in_array($text, ['Ok', 'Cancel'], true)) {                    $notes['state'] = 3;                    $this->conversation->update();                    $currency = $apirone->getCurrencyId($notes['currency'], true);                    $estimate = $apirone->estimate($user_id, $notes['currency'], $notes['address'], $notes['amount']);                    if(isset($estimate['message'])) {                        $data['text'] = 'Message from Apirone:'. PHP_EOL. '*'.$estimate['message'].'*' .PHP_EOL. 'Operation cancelled.';                        $data['parse_mode'] = 'markdown';                        $data['reply_markup'] = (new Keyboard(['Receive', 'Send'],                        ['Balance']))                            ->setResizeKeyboard(true)                            ->setOneTimeKeyboard(true)                            ->setSelective(true);                        $this->conversation->stop();                    } else {                    $data['reply_markup'] = (new Keyboard(['Ok', 'Cancel']))                        ->setResizeKeyboard(true)                        ->setOneTimeKeyboard(true)                        ->setSelective(true);                    $data['text'] = 'Please double check that all data correct. Send \"Ok\" message in answer. If you want to stop sending type \"Cancel\"'. PHP_EOL; ...                    if ($text !== '') {                        $data['text'] = 'Simply type Ok or Cancel.';                    }                    }                    $result = Request::sendMessage($data);                    break;                }                $notes['answer'] = $text;              \/\/ No break!            case 4:                $this->conversation->update();                unset($notes['state']);                if($notes['answer'] === 'Ok') {                    $transfer = $apirone->transfer($user_id, $notes['currency'], $notes['address'], $notes['amount']);                      if(isset($transfer['message'])) {                        $data['text'] = 'Message from Apirone:'. PHP_EOL. '*'.$transfer['message'].'*' .PHP_EOL. 'Operation cancelled.';                     ...                        $this->conversation->stop();                    } else {                        $data['text'] = 'Transfer successfully complete.'.PHP_EOL.                        'Transactions:'. PHP_EOL ;                        foreach ($transfer['txs'] as $tx) {                            $data['text'].= $tx .PHP_EOL. $apirone->explorerUrl($notes['currency'], $tx).PHP_EOL;                        };                    }                }  ...                $result = Request::sendMessage($data);                $this->conversation->stop();                break;        }        return $result;<\/code><\/pre>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c StartCommand.php \u0418 \u0432 \u043d\u0435\u043c \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0439 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445<\/p>\n<pre><code class=\"bash\">       $message = $this->getMessage();        $user_id = $message->getFrom()->getId();        $apirone = new ApironeWallet;        $apirone->createWallets($user_id);        return $this->replyToChat(            'Welcome to Apirone wallet bot! You are ready to use BTC,BCH,DOGE and LTC wallets right now' . PHP_EOL .            'Type \/menu to start using it now!'        );<\/code><\/pre>\n<p>\u0412 \u043a\u043e\u0440\u043d\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0441\u043e\u0437\u0434\u0430\u0435\u043c callback.php . \u0417\u0434\u0435\u0441\u044c \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c\u0441\u044f \u043a\u043e\u043b\u0431\u044d\u043a \u043e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0438\u043d\u0433\u0430:<\/p>\n<pre><code class=\"bash\">require_once __DIR__ . '\/vendor\/autoload.php'; use Longman\\TelegramBot\\Request; use Classes\\Apirone\\ApironeWallet;   $config = require __DIR__ . '\/config.php';   $telegram = new Longman\\TelegramBot\\Telegram($config['api_key'], $config['bot_username']); $apirone = new ApironeWallet; $telegram->enableMySql($config['mysql']);;   $apironeData = file_get_contents('php:\/\/input');   if ($apironeData) {    $params = json_decode($apironeData, true);      \/\/ check your secret code    if ($params[\"data\"][\"secret\"] !== $config['apirone_secret']) die();      $user_id = $params[\"data\"][\"user_id\"];    $input_address = $params[\"input_address\"];    $input_transaction_hash = $params[\"input_transaction_hash\"];    $value_in_satoshi = $params[\"value\"];      $wallets = $apirone->getWallets($user_id);      foreach ($wallets as $wallet) {       if($wallet['wallet_id'] === $params['wallet']) {        $currency = $apirone->getCurrencyById($wallet['currency'], true);       }    }      \/\/Save unconfirmed transactions and data to your Database.        $data['chat_id'] = $user_id;        $data['parse_mode'] = 'markdown';    if ($params[\"confirmations\"] &lt; 2 ) {        $data['text'] = '*'.strtoupper($currency['name']) .' wallet*: '. PHP_EOL .        \"Transaction \". $input_transaction_hash . PHP_EOL.        'Waiting *'. number_format($value_in_satoshi\/pow(10, $currency['units-factor']), 8, '.', ''). strtoupper($currency['name']) .'*'. PHP_EOL .        $params[\"confirmations\"].' of 2 confirmations received'. PHP_EOL .        $apirone->explorerUrl($currency['name'], $input_transaction_hash);      }       if ($params[\"confirmations\"] >= 2) {        $balance = $apirone->getBalance($user_id, $user_id, $params['wallet']);        $data['text'] = '*'.strtoupper($currency['name']) .' wallet*: '. PHP_EOL .        \"Transaction \". $input_transaction_hash . PHP_EOL.        'Payment successfully received!'. PHP_EOL .'Amount: *'. number_format($value_in_satoshi\/pow(10, $currency['units-factor']), 8, '.', ''). strtoupper($currency['name']) .'*'. PHP_EOL.        'Current balance:'. PHP_EOL .        $balance . PHP_EOL.        $apirone->explorerUrl($currency['name'], $input_transaction_hash);        echo \"*ok*\";    }    return Request::sendMessage($data);<\/code><\/pre>\n<p>\u0412 \u0438\u0442\u043e\u0433\u043e\u0432\u043e\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0438\u043c\u0435\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0431\u043e\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0434\u043e\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c, \u0442.\u043a. \u0437\u0430\u043b\u043e\u0436\u0435\u043d\u0430 \u0441\u0435\u0440\u044c\u0435\u0437\u043d\u0430\u044f \u0431\u0430\u0437\u0430 \u0432 \u0432\u0438\u0434\u0435\u00a0 php-telegram-bot.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d71\/7e4\/621\/d717e4621c3b90f33ed67501f3742ab1.png\" width=\"499\" height=\"749\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d71\/7e4\/621\/d717e4621c3b90f33ed67501f3742ab1.png\"\/><figcaption><\/figcaption><\/figure>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/a6b\/7c9\/e90\/a6b7c9e9033ff5ce6334a4cf09e5b427.png\" width=\"452\" height=\"233\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a6b\/7c9\/e90\/a6b7c9e9033ff5ce6334a4cf09e5b427.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041f\u0440\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u0431\u043e\u0442\u0430 \u0431\u044b\u043b\u043e \u0438\u0437\u0443\u0447\u0435\u043d\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432. \u0418 \u043a\u0430\u043a \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0433\u043e\u0442\u043e\u0432\u044b\u0445 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u0432 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0439 \u0431\u043e\u0442\u043e\u0432 \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u0440\u0430\u0445 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430 \u043e\u0447\u0435\u043d\u044c \u043c\u0430\u043b\u043e. \u0414\u0430\u043d\u043d\u044b\u0439 \u0431\u043e\u0442 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u0435\u043d \u0442\u0435\u043c, \u043a\u0442\u043e \u0445\u043e\u0447\u0435\u0442 \u0434\u043e\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0434\u043b\u044f \u043f\u0440\u0438\u0435\u043c\u0430 \u043a\u0440\u0438\u043f\u0442\u043e\u0432\u0430\u043b\u044e\u0442\u044b \u0438\u043b\u0438 \u0445\u043e\u0447\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0432\u043e\u0439 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u043a\u0440\u0438\u043f\u0442\u043e\u0432\u0430\u043b\u044e\u0442\u043d\u044b\u0439 \u043a\u043e\u0448\u0435\u043b\u0435\u043a \u0432 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u0435.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/572692\/\"> https:\/\/habr.com\/ru\/articles\/572692\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442-\u043a\u043e\u043c\u043c\u0435\u0440\u0446\u0438\u0438 \u0441\u0435\u0439\u0447\u0430\u0441 \u0430\u043a\u0442\u0438\u0432\u043d\u043e \u0440\u0430\u0437\u0432\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u044f \u043c\u0435\u0441\u0441\u0435\u043d\u0434\u0436\u0435\u0440\u043e\u0432. \u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0431\u043e\u0442\u044b \u0440\u0430\u0441\u0442\u0443\u0442, \u043a\u0430\u043a \u0433\u0440\u0438\u0431\u044b \u043f\u043e\u0441\u043b\u0435 \u0434\u043e\u0436\u0434\u044f. \u0422\u0443\u0442 \u0432\u0430\u043c \u0438 \u043c\u0430\u0433\u0430\u0437\u0438\u043d\u044b, \u0438 \u043e\u043d\u043b\u0430\u0439\u043d-\u043f\u043e\u043c\u043e\u0449\u043d\u0438\u043a\u0438, \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u0434\u043b\u044f \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0438, \u0438 \u043f\u0440\u043e\u0447\u0438\u0435 \u0432\u0430\u0436\u043d\u044b\u0435 \u0438 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f. \u0421\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0439 \u0431\u043e\u0442 \u0432 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043c\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043b\u043d\u043e\u0446\u0435\u043d\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u0446\u0435\u043b\u044b\u0439 \u0441\u0430\u0439\u0442 \u0438 \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u0431\u0438\u0437\u043d\u0435\u0441 \u043d\u0430 \u043d\u043e\u0432\u044b\u0439 \u0443\u0440\u043e\u0432\u0435\u043d\u044c. \u0414\u0430\u0436\u0435 \u043a\u0440\u0438\u043f\u0442\u043e\u0432\u0430\u043b\u044e\u0442\u043d\u044b\u0439 \u043a\u043e\u0448\u0435\u043b\u0435\u043a \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0431\u043e\u0442\u0430. \u042d\u0442\u0438\u043c \u0438 \u0437\u0430\u0439\u043c\u0435\u043c\u0441\u044f.<\/p>\n<p>\u0414\u043b\u044f \u0431\u044b\u0441\u0442\u0440\u043e\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u0430 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c PHP, \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u043e\u0434\u043d\u0443 \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0441 core.telegram.org (<a href=\"https:\/\/core.telegram.org\/bots\/samples\" rel=\"noopener noreferrer nofollow\"><u>https:\/\/core.telegram.org\/bots\/samples<\/u><\/a>) php-telegram-bot\u00a0 (<a href=\"https:\/\/github.com\/php-telegram-bot\/core\/\" rel=\"noopener noreferrer nofollow\"><u>https:\/\/github.com\/php-telegram-bot\/core\/<\/u><\/a>). \u042d\u0442\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0447\u0430\u0441\u0442\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u043c\u0430\u0441\u0448\u0442\u0430\u0431\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u043e\u0442\u0430.<\/p>\n<p>\u0412 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u0435 \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e API-\u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043a\u0440\u0438\u043f\u0442\u043e\u0432\u0430\u043b\u044e\u0442\u0430\u043c\u0438:<\/p>\n<ol>\n<li>\n<p><a href=\"https:\/\/www.coinpayments.net\/apidoc\" rel=\"noopener noreferrer nofollow\"><u>https:\/\/www.coinpayments.net\/apidoc<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/confirmonetapi.docs.apiary.io\" rel=\"noopener noreferrer nofollow\"><u>https:\/\/confirmonetapi.docs.apiary.io<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.blockchain.com\/ru\/api\/blockchain_wallet_api\" rel=\"noopener noreferrer nofollow\"><u>https:\/\/www.blockchain.com\/ru\/api\/blockchain_wallet_api<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/www.alfacoins.com\/developers\/api-documentation\" rel=\"noopener noreferrer nofollow\"><u>https:\/\/www.alfacoins.com\/developers\/api-documentation<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/apirone.com\/docs\/wallet\" rel=\"noopener noreferrer nofollow\">https:\/\/apirone.com\/docs\/wallet<\/a><\/p>\n<\/li>\n<\/ol>\n<p>\u0412\u043e \u0432\u0441\u0435\u0445 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u0445 \u043d\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 KYC \u0438 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u0430\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f. Blockchain.info \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0442\u043e\u043a\u0435\u043d\u0430 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b, \u043e\u043d \u0443\u0441\u043b\u043e\u0432\u043d\u043e \u0431\u0435\u0437 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438, \u043d\u043e \u0435\u0433\u043e \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u043d\u044f\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u043d\u0435\u0439 \u0438\u043b\u0438 \u0434\u0430\u0436\u0435 \u043d\u0435\u0434\u0435\u043b\u044c.<\/p>\n<p>\u0412\u044b\u0431\u043e\u0440 \u043f\u0430\u043b \u043d\u0430 \u0441\u0435\u0440\u0432\u0438\u0441 Apirone, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0442\u0443\u0442 \u043d\u0435\u0442 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u0439 \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043a\u043e\u0448\u0435\u043b\u044c\u043a\u043e\u0432 \u0438 \u0430\u0434\u0440\u0435\u0441\u043e\u0432.<\/p>\n<p>    \u0418\u0442\u0430\u043a, \u043d\u0430\u0448 \u0431\u043e\u0442 \u0431\u0443\u0434\u0435\u0442 \u0443\u043c\u0435\u0442\u044c:<\/p>\n<ul>\n<li>\n<p>\u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043a\u0440\u0438\u043f\u0442\u043e\u0432\u0430\u043b\u044e\u0442\u043d\u044b\u0439 \u043a\u043e\u0448\u0435\u043b\u0435\u043a \u0432 \u043d\u0443\u0436\u043d\u043e\u0439 \u0432\u0430\u043b\u044e\u0442\u0435,\u00a0<\/p>\n<\/li>\n<li>\n<p>\u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0431\u0430\u043b\u0430\u043d\u0441,\u00a0<\/p>\n<\/li>\n<li>\n<p>\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0440\u0438\u043f\u0442\u043e\u0432\u0430\u043b\u044e\u0442\u043d\u044b\u0439 \u0430\u0434\u0440\u0435\u0441,\u00a0<\/p>\n<\/li>\n<li>\n<p>\u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0442\u043d\u0443\u044e \u0441\u0432\u044f\u0437\u044c (\u043a\u043e\u043b\u0431\u044d\u043a) \u043e\u0442 \u043a\u0440\u0438\u043f\u0442\u043e\u0432\u0430\u043b\u044e\u0442\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0438\u043d\u0433\u0430,\u00a0<\/p>\n<\/li>\n<li>\n<p>\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u0438\u043c\u0435\u044e\u0449\u0438\u0445\u0441\u044f \u0441\u0440\u0435\u0434\u0441\u0442\u0432.\u00a0<\/p>\n<\/li>\n<\/ul>\n<figure class=\"\"><figcaption><\/figcaption><\/figure>\n<p>\u0412\u0441\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u043a\u043e\u043b\u0431\u044d\u043a\u043e\u0432 \u043e\u0442 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u0430 \u0443\u0436\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u0432 php-telegram-bot .<\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0447\u0435\u0440\u0435\u0437 <a href=\"https:\/\/telegram.me\/BotFather\" rel=\"noopener noreferrer nofollow\"><u>@BotFather<\/u><\/a> \u043d\u043e\u0432\u043e\u0433\u043e \u0431\u043e\u0442\u0430, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0431\u043e\u0442\u0430 \u0438 \u043a\u043b\u044e\u0447 API. \u0414\u0430\u043b\u0435\u0435 \u0440\u0430\u0437\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c php-telegram-bot\u00a0 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Composer. \u041d\u0430\u0434\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0431\u043e\u0442\u0430 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f SSL \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442 \u0438 \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0435 \u0434\u043e\u043c\u0435\u043d\u043d\u043e\u0435 \u0438\u043c\u044f. \u0412 \u043a\u043e\u043d\u0444\u0438\u0433 composer.json \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 monolog, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u043e\u0442\u043b\u0430\u0434\u043a\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0439.\u00a0\u0412 \u0441\u0435\u043a\u0446\u0438\u0438 autoload \u0441\u0440\u0430\u0437\u0443 \u0443\u043a\u0430\u0436\u0435\u043c, \u0447\u0442\u043e \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u044e Classes \u0432 \u043f\u0430\u043f\u043a\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430.<\/p>\n<pre><code class=\"bash\">{    \"require\": {        \"longman\/telegram-bot\": \"^0.74.0\",        \"monolog\/monolog\": \"^2.2\"    },    \"autoload\": {        \"classmap\": [\"Classes\"]    } }<\/code><\/pre>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c composer update \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b. \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0435\u0435 \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0442\u0443\u0434\u0430 \u043f\u0430\u043f\u043a\u0443\u00a0 Apirone \u0438 \u0432 \u043d\u0435\u0435 \u0444\u0430\u0439\u043b ApironeWallet.php, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u043a\u043b\u0430\u0441\u0441 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 \u043a\u0440\u0438\u043f\u0442\u043e\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0438\u043d\u0433\u043e\u043c.<\/p>\n<p>\u0412 \u043d\u0435\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<pre><code class=\"bash\">getWallets($user_id, $currencyId = null) \/\/\u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043a\u043e\u0448\u0435\u043b\u044c\u043a\u0438 \u0434\u043b\u044f telegram \u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f addWallet($user_id, $wallet, $address) \/\/add generated wallet into DB postWallet($user_id, $currency) \/\/get wallet from Apirone createWallets($user_id) \/\/create all available wallets getCurrencyId($currency,$units = null) \/\/get currency id from DB getAddress($chat_id, $user_id, $currency) \/\/outputs wallet from DB getAvailableCurrencies() \/\/collect available currencies from DB getCurrencyById($id, $units = null) \/\/ return currency by Id getBalance($chat_id, $user_id, $wallet_id = null) \/\/ get wallet or wallets balance checkAddress($currency, $address) \/\/ validate crypto address estimate($user_id, $currencyName, $address, $amount) \/\/ pre-calculation of crypto transaction transfer($user_id, $currencyName, $address, $amount) \/\/ transfer funds explorerUrl($currency, $tx) \/\/ get explorer link<\/code><\/pre>\n<p>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0443 \u044d\u0442\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435.\u00a0\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c <strong>MySQL <\/strong>\u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445, \u043e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u043d\u0443\u0436\u043d\u0430 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0438\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u0434\u0438\u0430\u043b\u043e\u0433\u043e\u0432. \u0412 \u043d\u0435\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0442\u0440\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u044b: apirone_currencies,\u00a0 apirone_transactions \u0438\u00a0 apirone_users.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041d\u0430\u0441\u0442\u0440\u043e\u0438\u043c config.php:<\/p>\n<pre><code class=\"php\">&lt;?php   return [    \/\/ Add you bot's API key and name    'api_key'      => 'key',    'bot_username' => 'botName', \/\/ Without \"@\"      \/\/ When using the getUpdates method, this can be commented out    'webhook'      => [        'url' => 'https:\/\/example.com\/hook.php',    ],      'apirone_secret' => 'secret',    'apirone_callback' => 'http:\/\/example.com\/callback.php',    \/\/ All command related configs go here    'commands'     => [        \/\/ Define all paths for your custom commands        'paths'   => [            __DIR__ . '\/Commands',        ],      \/\/ Define all IDs of admin users    'admins'       => [        00000,    ],      \/\/ Enter your MySQL database credentials    'mysql'        => [        'host'     => 'localhost',        'user'     => 'telegram_bot',        'password' => 'password',        'database' => 'telegram_bot',    ],      \/\/Logging (Debug, Error and Raw Updates)    'logging'  => [        'debug'  => __DIR__ . '\/php-telegram-bot-debug.log',        'error'  => __DIR__ . '\/php-telegram-bot-error.log',        'update' => __DIR__ . '\/php-telegram-bot-update.log',    ],      \/\/ Set custom Upload and Download paths    'paths'        => [        'download' => __DIR__ . '\/Download',        'upload'   => __DIR__ . '\/Upload',    ],      \/\/ Requests Limiter (tries to prevent reaching Telegram API limits)    'limiter'      => [        'enabled' => true,    ], ];<\/code><\/pre>\n<p>\u0421 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043e\u043c \u0431\u0443\u0434\u0435\u043c \u043e\u0431\u0449\u0430\u0442\u044c\u0441\u044f \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u0435\u0431\u0445\u0443\u043a\u043e\u0432 (Webhook). \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e <strong>set.php<\/strong> \u0438 <strong>unset.php<\/strong> &#8212; \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u043b\u0431\u044d\u043a\u043e\u0432. <strong>hook.php <\/strong>\u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0441\u0430\u043c\u0438 \u043a\u043e\u043b\u0431\u044d\u043a\u0438 \u0438\u0437 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u0430:<\/p>\n<pre><code class=\"php\">   $telegram->handle();<\/code><\/pre>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0432\u0435\u0431\u0445\u0443\u043a\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0432 \u0434\u0432\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<pre><code>   $result = $telegram->setWebhook($config['webhook']['url']);    $result = $telegram->deleteWebhook();<\/code><\/pre>\n<p>\u0412 \u043a\u043e\u0440\u043d\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043d\u0443\u0436\u043d\u0430 \u043f\u0430\u043f\u043a\u0430 Commands, \u0432 \u043d\u0435\u0435 \u0437\u0430\u043f\u0438\u0448\u0435\u043c \u043d\u0430\u0448\u0438 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u043c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435. \u0418\u0437 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432 \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u0430\u0445 \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0441 \u043c\u0435\u043d\u044e \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u0445\u0441\u044f \u0441\u043e \u0441\u043b\u044d\u0448\u0430, \u043d\u043e \u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 \u043f\u0430\u043f\u043a\u0435 Commands \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u0430\u043f\u043a\u0443 ServiceMessages \u0438 \u0432 \u043d\u0435\u0439 \u0441\u043e\u0437\u0434\u0430\u0435\u043c GenericmessageCommand.php , \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0443\u0442\u0435\u043c \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0432\u043d\u043e\u0441\u0438\u043c \u043d\u0443\u0436\u043d\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0438 \u0440\u0435\u0430\u043a\u0446\u0438\u0438 \u043d\u0430 \u043d\u0438\u0445:  <\/p>\n<pre><code class=\"bash\">       \/\/ Fetch conversation command if it exists and execute it.        if ($conversation->exists() &amp;&amp; $command = $conversation->getCommand()) {            return $this->telegram->executeCommand($command);        }               if($type === \"text\") {            $text = $message->getText(true);            if (stripos($text, 'Receive') === 0) {                return $this->telegram->executeCommand('receive');            }            if (stripos($text, 'Menu') === 0) {                return $this->telegram->executeCommand('menu');            }              if (stripos($text, 'Balance') === 0) {                return $this->telegram->executeCommand('balance');            }            if (stripos($text, 'Send') === 0) {                return $this->telegram->executeCommand('send');            }            return $this->replyToChat(                'Command not found'            );        }<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u0430\u0448\u0438 \u0447\u0435\u0442\u044b\u0440\u0435 \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b BalanceCommand.php , MenuCommand.php , ReceiveCommand.php \u0438 SendCommand.php.\u00a0<\/p>\n<p>\u041a\u0430\u0436\u0434\u043e\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u0435 \u0434\u0435\u043b\u0430\u0435\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u043c \u0432\u0435\u0440\u0441\u0438\u044e.<\/p>\n<pre><code class=\"bash\">   protected $name = 'balance';    protected $description = 'Show balance of wallet';    protected $usage = '\/balance';    protected $version = '1.2.0';<\/code><\/pre>\n<p>\u0421\u0430\u043c \u043a\u043e\u0434 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0437\u0430\u043a\u043b\u0430\u0434\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u044e execute(). \u0412 \u043d\u0435\u0439 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u043e\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0441\u043c\u043e\u0442\u0440\u0438\u0442 \u0431\u0430\u043b\u0430\u043d\u0441<\/p>\n<pre><code class=\"bash\">       $message = $this->getMessage();        $text    = $message->getText(true);        $chat    = $message->getChat();        $user    = $message->getFrom();        $chat_id = $chat->getId();        $user_id = $user->getId();    $sql = '        SELECT *        FROM `apirone_currencies`      ';      $pdo = DB::getPdo();      $sth = $pdo->prepare($sql);      $sth->execute();      $result = $sth->fetchAll(PDO::FETCH_ASSOC);      foreach ($result as $currency) {        if (stripos($text, $currency['name']) === 8) {            $response = new ApironeWallet;     $response->getAddress($chat_id,$user_id,$currency['name']);            return Request::emptyResponse();        }      }      if ($text === 'Balance' || $text ==='') {        $response = new ApironeWallet;        $response->getBalance($chat_id, $user_id);    }      return Request::emptyResponse();<\/code><\/pre>\n<p>SendCommand.php \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u043c. \u0412 \u043d\u0435\u043c \u0431\u043e\u0442 \u0441\u043f\u0440\u043e\u0441\u0438\u0442 \u043a\u0440\u0438\u043f\u0442\u043e\u0432\u0430\u043b\u044e\u0442\u0443, \u0430\u0434\u0440\u0435\u0441 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430 \u0441\u0440\u0435\u0434\u0441\u0442\u0432 \u0438 \u0441\u0443\u043c\u043c\u0443 \u043f\u043b\u0430\u0442\u0435\u0436\u0430.<\/p>\n<pre><code class=\"bash\">$this->conversation = new Conversation($user_id, $chat_id, $this->getName());          \/\/ Load any existing notes from this conversation        $notes = &amp;$this->conversation->notes; \u2026      \/\/ Every time a step is achieved the state is updated          if($text === 'Cancel') {            $state = 4;            $notes['answer'] = 'Cancel';        }        if($text === 'Send') {            $text = '';        }        switch ($state) {            case 0:                $currencies = $apirone->getAvailableCurrencies();                if ($text === '' || !in_array(strtoupper($text), $currencies, true)) {                   ...                    $data['reply_markup'] = (new Keyboard(                    [$currencies[0],$currencies[1]],                    [$currencies[2],$currencies[3],$currencies[4]],                    ['Cancel']))                            ->setResizeKeyboard(true)                            ->setOneTimeKeyboard(true)                            ->setSelective(true);                                   $result = Request::sendMessage($data);                    break;                }                $notes['currency'] = strtolower($text);                $text          = '';             case 1:                if ($text === ''|| !$apirone->checkAddress($notes['currency'], $text)) {                    $notes['state'] = 1;                    $this->conversation->update();                      $data['text'] = 'Type address for transfer:';                    if ($text !== '') {               ...                    break;                }                  $notes['address'] = $text;                $text          = '';              \/\/ No break!            case 2:                   \u2026            case 3:                if ($text === '' || !in_array($text, ['Ok', 'Cancel'], true)) {                    $notes['state'] = 3;                    $this->conversation->update();                    $currency =<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-383786","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/383786","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=383786"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/383786\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=383786"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=383786"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=383786"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}