MonitorWalletBlockLostV2.php 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  1. <?php
  2. namespace App\Task;
  3. use App\Model\Monitor\MonitorWallet;
  4. use App\Library\Log;
  5. use App\Service\Bus\TronServices;
  6. class MonitorWalletBlockLostV2
  7. {
  8. public function execute()
  9. {
  10. try {
  11. $lostblock = json_decode(getRedis('lostblock'),true) ?? [];
  12. if(!empty($lostblock)){
  13. $data = MonitorWallet::from('monitor_wallet as a')
  14. ->Join('telegram_bot as b','a.bot_rid','b.rid')
  15. ->where('a.status',0)
  16. ->whereNotNull('a.monitor_wallet')
  17. ->where('a.chain_type','trc')
  18. ->select('a.monitor_wallet','a.tg_notice_obj','b.bot_token','a.comments','a.monitor_usdt_transaction','a.monitor_trx_transaction','a.monitor_approve_transaction','a.monitor_multi_transaction','a.monitor_pledge_transaction')
  19. ->get()
  20. ->toArray();
  21. if(!empty($data) && !empty($lostblock)){
  22. $api_key = config('apikey.gridapikey');
  23. $apikeyrand = $api_key[array_rand($api_key)];
  24. //波场接口API
  25. $TronApiConfig = [
  26. 'url' => 'https://api.trongrid.io',
  27. 'api_key' => $apikeyrand,
  28. ];
  29. $tron = new TronServices($TronApiConfig,'1111111','222222');
  30. $tronres = $tron->getBlock(current($lostblock));
  31. if(!empty($tronres['transactions'])){
  32. $currentblock = $tronres['block_header']['raw_data']['number'];
  33. $blocktimestamp = $tronres['block_header']['raw_data']['timestamp'];
  34. array_shift($lostblock);
  35. setRedis('lostblock',json_encode($lostblock));
  36. //区块的交易详细
  37. foreach ($tronres['transactions'] as $x => $y) {
  38. //如果是合约事件
  39. if($y['raw_data']['contract'][0]['type'] == 'TriggerSmartContract'){
  40. $dataaa = $y['raw_data']['contract'][0]['parameter']['value']['data'];
  41. $contract_address = $y['raw_data']['contract'][0]['parameter']['value']['contract_address']; //USDT:41a614f803b6fd780986a42c78ec9c7f77e6ded13c
  42. //取合约的transfer方法
  43. if(in_array(mb_substr($dataaa,0,8),['d73dd623','a9059cbb','095ea7b3']) && $contract_address == '41a614f803b6fd780986a42c78ec9c7f77e6ded13c'){
  44. $toaddress = $tron->addressFromHex('41' . mb_substr($dataaa,32,40));
  45. $fromaddress = $tron->addressFromHex($y['raw_data']['contract'][0]['parameter']['value']['owner_address']);
  46. $amount = $tron->dataAmountFormat(mb_substr($dataaa,72,64));
  47. //转入地址是否在监控列表
  48. $isto = array_search($toaddress,array_column($data,'monitor_wallet'));
  49. $isfrom = array_search($fromaddress,array_column($data,'monitor_wallet'));
  50. //如果是转入
  51. if(($isto !== false && $amount > 0 && mb_substr($dataaa,0,8) == 'a9059cbb') || ($isto !== false && mb_substr($dataaa,0,8) != 'a9059cbb')){
  52. $contractret = $y['ret'][0]['contractRet'];
  53. $found_obj = $data[$isto];
  54. $type = mb_substr($dataaa,0,8) == 'a9059cbb' ?'1':($amount == 0 ?'11':'12');
  55. //判断功能开关
  56. if(($type == 1 && mb_substr($found_obj['monitor_usdt_transaction'],0,1) == 'Y' && $amount >= 0.01) || ($type == 11 && mb_substr($found_obj['monitor_approve_transaction'],1,1) == 'Y') || ($type == 12 && mb_substr($found_obj['monitor_approve_transaction'],0,1) == 'Y')){
  57. $this->sendTgMessage($contractret,$toaddress,$type,$fromaddress,$toaddress,'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t',$amount,$currentblock,$blocktimestamp,$y['txID'],$found_obj['tg_notice_obj'],$found_obj['bot_token'],$found_obj['comments']);
  58. }
  59. }
  60. //如果是转出
  61. if(($isfrom !== false && $amount > 0 && mb_substr($dataaa,0,8) == 'a9059cbb') || ($isfrom !== false && mb_substr($dataaa,0,8) != 'a9059cbb')){
  62. $contractret = $y['ret'][0]['contractRet'];
  63. $found_obj = $data[$isfrom];
  64. $type = mb_substr($dataaa,0,8) == 'a9059cbb' ?'2':($amount == 0 ?'21':'22');
  65. //判断功能开关
  66. if(($type == 2 && mb_substr($found_obj['monitor_usdt_transaction'],1,1) == 'Y' && $amount >= 0.01) || ($type == 21 && mb_substr($found_obj['monitor_approve_transaction'],1,1) == 'Y') || ($type == 22 && mb_substr($found_obj['monitor_approve_transaction'],0,1) == 'Y')){
  67. $this->sendTgMessage($contractret,$fromaddress,$type,$fromaddress,$toaddress,'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t',$amount,$currentblock,$blocktimestamp,$y['txID'],$found_obj['tg_notice_obj'],$found_obj['bot_token'],$found_obj['comments']);
  68. }
  69. }
  70. //取合约的transferFrom方法
  71. }elseif(mb_substr($dataaa,0,8) == '23b872dd' && $contract_address == '41a614f803b6fd780986a42c78ec9c7f77e6ded13c'){
  72. $toaddress = $tron->addressFromHex('41' . mb_substr($dataaa,96,40));
  73. $fromaddress = $tron->addressFromHex('41' . mb_substr($dataaa,32,40));
  74. $amount = $tron->dataAmountFormat(mb_substr($dataaa,136,64));
  75. //转入地址是否在监控列表
  76. $isto = array_search($toaddress,array_column($data,'monitor_wallet'));
  77. $isfrom = array_search($fromaddress,array_column($data,'monitor_wallet'));
  78. //如果是转入
  79. if($isto !== false && $amount >= 0.01){
  80. $contractret = $y['ret'][0]['contractRet'];
  81. $found_obj = $data[$isto];
  82. //判断功能开关
  83. if(mb_substr($found_obj['monitor_usdt_transaction'],0,1) == 'Y' && $amount >= 0.01){
  84. $this->sendTgMessage($contractret,$toaddress,3,$fromaddress,$toaddress,'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t',$amount,$currentblock,$blocktimestamp,$y['txID'],$found_obj['tg_notice_obj'],$found_obj['bot_token'],$found_obj['comments']);
  85. }
  86. }
  87. //如果是转出
  88. if($isfrom !== false && $amount >= 0.01){
  89. $contractret = $y['ret'][0]['contractRet'];
  90. $found_obj = $data[$isfrom];
  91. //判断功能开关
  92. if(mb_substr($found_obj['monitor_usdt_transaction'],1,1) == 'Y' && $amount >= 0.01){
  93. $this->sendTgMessage($contractret,$fromaddress,4,$fromaddress,$toaddress,'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t',$amount,$currentblock,$blocktimestamp,$y['txID'],$found_obj['tg_notice_obj'],$found_obj['bot_token'],$found_obj['comments']);
  94. }
  95. }
  96. }
  97. // trx交易
  98. }elseif($y['raw_data']['contract'][0]['type'] == 'TransferContract'){
  99. $toaddress = $tron->addressFromHex($y['raw_data']['contract'][0]['parameter']['value']['to_address']);
  100. $fromaddress = $tron->addressFromHex($y['raw_data']['contract'][0]['parameter']['value']['owner_address']);
  101. $amount = calculationExcept($y['raw_data']['contract'][0]['parameter']['value']['amount'],6);
  102. //转入地址是否在监控列表
  103. $isto = array_search($toaddress,array_column($data,'monitor_wallet'));
  104. $isfrom = array_search($fromaddress,array_column($data,'monitor_wallet'));
  105. //如果是转入
  106. if($isto !== false && $amount >= 0.01){
  107. $contractret = $y['ret'][0]['contractRet'];
  108. $found_obj = $data[$isto];
  109. //判断功能开关
  110. if(mb_substr($found_obj['monitor_trx_transaction'],0,1) == 'Y'){
  111. $this->sendTgMessage($contractret,$toaddress,1,$fromaddress,$toaddress,'TRX',$amount,$currentblock,$blocktimestamp,$y['txID'],$found_obj['tg_notice_obj'],$found_obj['bot_token'],$found_obj['comments']);
  112. }
  113. }
  114. //如果是转出
  115. if($isfrom !== false && $amount >= 0.01){
  116. $contractret = $y['ret'][0]['contractRet'];
  117. $found_obj = $data[$isfrom];
  118. //判断功能开关
  119. if(mb_substr($found_obj['monitor_trx_transaction'],1,1) == 'Y'){
  120. $this->sendTgMessage($contractret,$fromaddress,2,$fromaddress,$toaddress,'TRX',$amount,$currentblock,$blocktimestamp,$y['txID'],$found_obj['tg_notice_obj'],$found_obj['bot_token'],$found_obj['comments']);
  121. }
  122. }
  123. // 代理资源或者回收资源
  124. }elseif(in_array($y['raw_data']['contract'][0]['type'],['UnDelegateResourceContract','DelegateResourceContract'])){
  125. $toaddress = $tron->addressFromHex($y['raw_data']['contract'][0]['parameter']['value']['receiver_address']);
  126. $fromaddress = $tron->addressFromHex($y['raw_data']['contract'][0]['parameter']['value']['owner_address']);
  127. $amount = calculationExcept($y['raw_data']['contract'][0]['parameter']['value']['balance'],6);
  128. $resource = $y['raw_data']['contract'][0]['parameter']['value']['resource'] ?? ' ';
  129. //转入地址是否在监控列表
  130. $isto = array_search($toaddress,array_column($data,'monitor_wallet'));
  131. $isfrom = array_search($fromaddress,array_column($data,'monitor_wallet'));
  132. //如果是转入
  133. if($isto !== false && $amount > 0){
  134. $contractret = $y['ret'][0]['contractRet'];
  135. $found_obj = $data[$isto];
  136. $type = $y['raw_data']['contract'][0]['type'] == 'DelegateResourceContract' ?6:61;
  137. //判断功能开关
  138. if(($type == 6 && mb_substr($found_obj['monitor_pledge_transaction'],0,1) == 'Y') || ($type == 61 && mb_substr($found_obj['monitor_pledge_transaction'],1,1) == 'Y')){
  139. $this->sendTgMessage($contractret,$toaddress,$type,$fromaddress,$toaddress,$resource,$amount,$currentblock,$blocktimestamp,$y['txID'],$found_obj['tg_notice_obj'],$found_obj['bot_token'],$found_obj['comments']);
  140. }
  141. }
  142. //如果是转出
  143. if($isfrom !== false && $amount > 0){
  144. $contractret = $y['ret'][0]['contractRet'];
  145. $found_obj = $data[$isfrom];
  146. $type = $y['raw_data']['contract'][0]['type'] == 'DelegateResourceContract' ?7:71;
  147. //判断功能开关
  148. if(($type == 7 && mb_substr($found_obj['monitor_pledge_transaction'],0,1) == 'Y') || ($type == 71 && mb_substr($found_obj['monitor_pledge_transaction'],1,1) == 'Y')){
  149. $this->sendTgMessage($contractret,$fromaddress,$type,$fromaddress,$toaddress,$resource,$amount,$currentblock,$blocktimestamp,$y['txID'],$found_obj['tg_notice_obj'],$found_obj['bot_token'],$found_obj['comments']);
  150. }
  151. }
  152. // 账号更新权限
  153. }elseif($y['raw_data']['contract'][0]['type'] == 'AccountPermissionUpdateContract'){
  154. $fromaddress = $tron->addressFromHex($y['raw_data']['contract'][0]['parameter']['value']['owner_address']);
  155. $returnlist = '';
  156. $isOwn_set = 'N'; //监控地址是否有在所有权限中
  157. $isActive_set = 'N'; //监控地址是否有在活跃权限中
  158. $isJiankong = 'N'; //是否监控地址变更权限
  159. $isFound = 'N'; //是否找到监控钱包
  160. //监控地址变更权限
  161. $isfrom = array_search($fromaddress,array_column($data,'monitor_wallet'));
  162. if($isfrom !== false){
  163. $found_obj = $data[$isfrom];
  164. $isJiankong = 'Y';
  165. $isFound = 'Y';
  166. }
  167. //查询所有者权限
  168. if(isset($y['raw_data']['contract'][0]['parameter']['value']['owner'])){
  169. $ownerPermission = $y['raw_data']['contract'][0]['parameter']['value']['owner'];
  170. $returnlist = $returnlist . "\n🟠🟠所有权限-阈值:".$ownerPermission['threshold']."🟠🟠\n";
  171. $ownerPermissionList = '';
  172. for($i=0;$i<count($ownerPermission['keys']);$i++){
  173. $ownerAddress = $tron->addressFromHex($ownerPermission['keys'][$i]['address']);
  174. //检测是否存在所有者地址权限
  175. $isOwn = array_search($ownerAddress,array_column($data,'monitor_wallet'));
  176. if($isOwn !== false){
  177. $isOwn_set = 'Y';
  178. if($isFound == 'N'){
  179. $found_obj = $data[$isOwn];
  180. $isFound == 'Y';
  181. }
  182. }
  183. $ownerPermissionList = $ownerPermissionList."地址:<code>".$ownerAddress."</code> (权重:".$ownerPermission['keys'][$i]['weight'].")\n";
  184. }
  185. $returnlist = $returnlist.$ownerPermissionList;
  186. }
  187. //查询活跃权限
  188. if(isset($y['raw_data']['contract'][0]['parameter']['value']['actives'])){
  189. $activePermissions = $y['raw_data']['contract'][0]['parameter']['value']['actives'];
  190. if(count($activePermissions) > 0){
  191. $returnlist = $returnlist . "\n🔴🔴活跃权限-共:".count($activePermissions)."个🔴🔴\n";
  192. for($i=0;$i<count($activePermissions);$i++){
  193. $activepermissionname = isset($activePermissions[$i]['permission_name']) ?$activePermissions[$i]['permission_name']:$activePermissions[$i]['type'];
  194. $returnlist = $returnlist . "第". ($i+1) ."个-权限名称:".$activepermissionname." 权限阈值:".$activePermissions[$i]['threshold']."\n";
  195. $activePermissionList = '';
  196. for($j=0;$j<count($activePermissions[$i]['keys']);$j++){
  197. $activeAddress = $tron->addressFromHex($activePermissions[$i]['keys'][$j]['address']);
  198. //检测是否存在活跃地址权限
  199. $isActive = array_search($activeAddress,array_column($data,'monitor_wallet'));
  200. if($isActive !== false){
  201. $isActive_set = 'Y';
  202. if($isFound == 'N'){
  203. $found_obj = $data[$isActive];
  204. $isFound == 'Y';
  205. }
  206. }
  207. $activePermissionList = $activePermissionList."地址:<code>".$activeAddress."</code> (权重:".$activePermissions[$i]['keys'][$j]['weight'].")\n";
  208. }
  209. $returnlist = $returnlist.$activePermissionList;
  210. }
  211. }
  212. }
  213. //判断发送消息
  214. if($isfrom !== false || $isActive_set == 'Y' || $isOwn_set == 'Y'){
  215. $contractret = $y['ret'][0]['contractRet'];
  216. $type = $isJiankong == 'Y' ?5:51;
  217. //判断功能开关
  218. if(($type == 5 && mb_substr($found_obj['monitor_multi_transaction'],0,1) == 'Y') || ($type == 51 && mb_substr($found_obj['monitor_multi_transaction'],1,1) == 'Y')){
  219. $this->sendTgMessage($contractret,$found_obj['monitor_wallet'],$type,$fromaddress,'',$returnlist,0,$currentblock,$blocktimestamp,$y['txID'],$found_obj['tg_notice_obj'],$found_obj['bot_token'],$found_obj['comments']);
  220. }
  221. }
  222. }
  223. }
  224. }
  225. }
  226. }
  227. }catch (\Exception $e){
  228. $this->log('monitorwallet','----------Lost任务执行报错,请联系管理员。报错原因:----------'.$e->getMessage());
  229. }
  230. }
  231. /**
  232. * 发送tg消息
  233. */
  234. protected function sendTgMessage($contractret,$monitoraddress,$type,$fromaddress,$toaddress,$contract_address,$value,$currentblock,$blocktimestamp,$txid,$tg_notice_obj,$bot_token,$comments){
  235. if($type == 1){
  236. $transtype = '正常转账 ↓';
  237. }elseif($type == 2){
  238. $transtype = '正常转账 ↑';
  239. }elseif($type == 3){
  240. $transtype = '授权转账 ↓';
  241. }elseif($type == 4){
  242. $transtype = '授权转账 ↑';
  243. }elseif($type == 11){
  244. $transtype = '给监控地址取消授权';
  245. }elseif($type == 21){
  246. $transtype = '监控地址给其他地址取消授权';
  247. }elseif($type == 12){
  248. $transtype = '给监控地址授权 ↓';
  249. }elseif($type == 22){
  250. $transtype = '监控地址给其他地址授权 ↑';
  251. }elseif($type == 5){
  252. $transtype = '监控地址变更多签账户';
  253. }elseif($type == 51){
  254. $transtype = '其他地址变更监控地址为多签';
  255. }elseif($type == 6){
  256. $transtype = '给监控地址代理质押 ↓';
  257. }elseif($type == 61){
  258. $transtype = '给监控地址回收质押 ↑';
  259. }elseif($type == 7){
  260. $transtype = '监控地址给其他地址代理质押 ↑';
  261. }elseif($type == 71){
  262. $transtype = '监控地址给其他地址回收质押 ↓';
  263. }else{
  264. $transtype = '其他';
  265. }
  266. if(empty($comments) || $comments == ''){
  267. $comments = '无';
  268. }
  269. //多签
  270. if($type == 5 || $type == 51){
  271. $replytext = "监控钱包:<code>".$monitoraddress."</code>\n"
  272. ."监控钱包备注:".$comments."\n"
  273. ."变更钱包:<code>".$fromaddress."</code>\n"
  274. ."---------------------------------------\n"
  275. ."交易类型:<b>".$transtype."</b>\n"
  276. ."交易结果:".$contractret."\n"
  277. .$contract_address."\n"
  278. ."---------------------------------------\n"
  279. ."交易时间:<code>".date('Y-m-d H:i:s', $blocktimestamp/1000)."</code>\n"
  280. ."当前区块号:<code>".$currentblock."</code>\n"
  281. ."当前交易哈希:<code>".$txid."</code>\n";
  282. }elseif(in_array($type,[6,61,7,71])){
  283. $replytext = "监控钱包:<code>".$monitoraddress."</code>\n"
  284. ."监控钱包备注:".$comments."\n"
  285. ."---------------------------------------\n"
  286. ."交易类型:<b>".$transtype."</b>\n"
  287. ."交易结果:".$contractret."\n"
  288. ."代理资源:".$contract_address."\n"
  289. ."代理数量:".$value."\n"
  290. ."---------------------------------------\n"
  291. ."交易时间:<code>".date('Y-m-d H:i:s', $blocktimestamp/1000)."</code>\n"
  292. ."当前区块号:<code>".$currentblock."</code>\n"
  293. ."当前交易哈希:<code>".$txid."</code>\n";
  294. //转账
  295. }elseif(in_array($type,[1,2,3,4])){
  296. $url = 'https://apilist.tronscanapi.com/api/accountv2?address='.$monitoraddress;
  297. $api_key = config('apikey.tronapikey');
  298. $apikeyrand = $api_key[array_rand($api_key)];
  299. $heders = [
  300. "TRON-PRO-API-KEY:".$apikeyrand
  301. ];
  302. $res = Get_Pay($url,null,$heders);
  303. $accountBalance = "未知";
  304. if(empty($res)){
  305. //为空则查询一次grid api
  306. $url = 'https://api.trongrid.io/v1/accounts/'.$monitoraddress;
  307. $api_key = config('apikey.gridapikey');
  308. $apikeyrand = $api_key[array_rand($api_key)];
  309. $heders = [
  310. 'TRON-PRO-API-KEY:'.$apikeyrand
  311. ];
  312. $res = Get_Pay($url,null,$heders);
  313. if(empty($res)){
  314. //为空则不处理
  315. }else{
  316. $res = json_decode($res,true);
  317. if(isset($res['success'])){
  318. if(empty($res['data'])){
  319. $accountBalance = '地址还未激活!';
  320. }else{
  321. $accountBalance = "";
  322. $accountBalance = $accountBalance.(empty($res['data'][0]['balance']) ? 0 : bcdiv($res['data'][0]['balance'],1000000,6) + 0)." TRX";
  323. $usdt = 0;
  324. if(!empty($res['data'][0]['trc20'])){
  325. for($i=1; $i<=count($res['data'][0]['trc20']); $i++){
  326. if(!empty($res['data'][0]['trc20'][$i-1]['TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t'])){
  327. $usdt = bcdiv($res['data'][0]['trc20'][$i-1]['TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t'],1000000,6) + 0;
  328. break;
  329. }
  330. }
  331. }
  332. $accountBalance = $accountBalance.",".$usdt." USDT";
  333. }
  334. }
  335. }
  336. }else{
  337. $res = json_decode($res,true);
  338. //查询余额
  339. if(isset($res['withPriceTokens'])){
  340. $accountBalance = "";
  341. $withPriceTokens = $res['withPriceTokens'];
  342. $trxkey = array_search('_', array_column($withPriceTokens, 'tokenId'));
  343. $usdtkey = array_search('TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t', array_column($withPriceTokens, 'tokenId'));
  344. if($trxkey >= 0){
  345. $accountBalance = $accountBalance.($withPriceTokens[$trxkey]['amount'] + 0) ." TRX";
  346. }else{
  347. $accountBalance = $accountBalance."0 TRX";
  348. }
  349. if(is_bool($usdtkey)){
  350. $accountBalance = $accountBalance.",0 USDT";
  351. }else{
  352. $usdtamount = calculationExcept($withPriceTokens[$usdtkey]['balance'] ,$withPriceTokens[$usdtkey]['tokenDecimal']);
  353. $accountBalance = $accountBalance.",".$usdtamount." USDT";
  354. }
  355. }
  356. }
  357. $replytext = "监控钱包:<code>".$monitoraddress."</code>\n"
  358. ."监控钱包备注:".$comments."\n"
  359. ."---------------------------------------\n"
  360. ."<b>".(in_array($type,[1,3]) ?'🟢收入':'🔴支出').($contract_address == 'TRX' ?'TRX':'USDT')."提醒 ".(in_array($type,[1,3]) ?'+':'-').$value." ".($contract_address == 'TRX' ?'TRX':'USDT')."</b>\n\n"
  361. ."付款地址:<code>".$fromaddress."</code>\n"
  362. ."收款地址:<code>".$toaddress."</code>\n"
  363. ."交易时间:<code>".date('Y-m-d H:i:s', $blocktimestamp/1000)."</code>\n"
  364. ."交易金额:<b>".(in_array($type,[1,3]) ?'+':'-').$value." ".($contract_address == 'TRX' ?'TRX':'USDT')."</b>\n"
  365. ."---------------------------------------\n"
  366. ."账户余额:".$accountBalance."\n"
  367. ."交易结果:".($contractret == 'SUCCESS' ?'成功':'失败'.$contractret)." 类型:".$transtype;
  368. }else{
  369. $replytext = "监控钱包:<code>".$monitoraddress."</code>\n"
  370. ."监控钱包备注:".$comments."\n"
  371. ."---------------------------------------\n"
  372. ."转出地址:<code>".$fromaddress."</code>\n"
  373. ."接收地址:<code>".$toaddress."</code>\n"
  374. ."交易类型:<b>".$transtype."</b>\n"
  375. ."交易金额:<b>".$value."</b>\n"
  376. ."交易结果:".$contractret."\n"
  377. ."---------------------------------------\n"
  378. ."交易时间:<code>".date('Y-m-d H:i:s', $blocktimestamp/1000)."</code>\n"
  379. ."合约地址:<code>".$contract_address."</code>\n"
  380. ."当前区块号:<code>".$currentblock."</code>\n"
  381. ."当前交易哈希:<code>".$txid."</code>\n";
  382. }
  383. $url = 'https://tronscan.io/#/transaction/'.$txid;
  384. //内联按钮
  385. $keyboard = [
  386. 'inline_keyboard' => [
  387. [
  388. ['text' => '查看交易', 'url' => $url]
  389. ]
  390. ]
  391. ];
  392. $encodedKeyboard = json_encode($keyboard);
  393. $sendlist = explode(',',$tg_notice_obj);
  394. foreach ($sendlist as $x => $y) {
  395. $sendmessageurl = 'https://api.telegram.org/bot'.$bot_token.'/sendMessage?chat_id='.$y.'&text='.urlencode($replytext).'&parse_mode=HTML&reply_markup='.urlencode($encodedKeyboard);
  396. Get_Pay($sendmessageurl);
  397. }
  398. }
  399. /**
  400. * 记入日志
  401. * @param $log_title [日志路径]
  402. * @param $message [内容,不支持数组]
  403. * @param $remarks [备注]
  404. */
  405. protected function log($log_title,$message,$remarks='info'){
  406. Log::get($remarks,$log_title)->info($message);
  407. }
  408. }