limit(5)->select(); foreach ($userlist as $value) { $Telegram = new Telegrambot($value['botkey']); $Telegram->sendMessage($value['userid'], $value['text']); Db::name('push')->where('id', $value['id'])->delete(); } } public function tijiao(){ $Customer=new Customer(); // $reqx = $Customer->submitkt('384', '0772ce075192dca13187ad2823d87cab','8032909529',time(), 15, '@zf789', 0, 'https://premium.konline.top/'); //var_dump("222222",$reqx); } public function billusdt(){ //查询所有机器人的地址 $addinfo_all = Db::name("admin_bot")->cache(120)->whereNull('delete_time')->select(); $xiayige=Cache::get("sxiyigejuhu"); if($xiayige==null){ $xiayige=0; } if(empty($addinfo_all[$xiayige])){ $xiayige=-1; }else{ $valuex=$addinfo_all[$xiayige]; } Cache::set("sxiyigejuhu",$xiayige+1,200); if(!empty($valuex)){ $ym= $this->getbill($valuex['trxadd']); //var_dump($valuex['trxadd'],$ym); foreach ($ym as $key => $value) { // code... $transaction_id=$value['transaction_id']; $timestamp = $value['block_ts'] / 1000; $tokenName= isset($value['trigger_info']['method'])?$value['trigger_info']['method']:null; if($tokenName=="transfer(address _to,uint256 _value)"){ //var_dump($value,$timestamp); if($timestamp+600>time()){ if (!Db::name("k_chuliok")->where("transaction_id", $transaction_id)->find()) { $addinfo =$valuex; $money = $value['quant'] / 1000000; $address = $value['to_address']; $amount = $value['quant'] / 1000000; $formAmount = number_format($money, 5, '.', ''); $transaction_id = $value['transaction_id']; $from = $value['from_address']; $to = $value['to_address']; $timestamp = $value['block_ts'] / 1000; $Telegram = new Telegrambot($addinfo['botkey']); $Customer=new Customer(); //防止二次处理 涉及到钱 Db::name("k_chuliok")->insert(['transaction_id' => $transaction_id, "from" => $from, "to" => $to, "money" => $amount]); //查询没有处理的订单 $order = Db::name("order")->where('botid', $addinfo['botid'])->where([["end_time", ">=", time()], ["trxadd", "=", $address], ["paymoney", "=", $formAmount], ["start", "=", 0]])->find(); if (!empty($order["id"])) { Cache::set($order["order_no"], $order["order_no"], 320); Db::name("order")->where("id", $order["id"])->update(array("start" => 1)); $xianshi = "USDT-TRC20"; $typeoto = "转入"; $dhshi = date("Y-m-d H:i:s ", $timestamp); $bbaoadd = $from; $usr = "https://tronscan.org/#/transaction/" . $transaction_id; $tancan = isset($order["tancan"]) ? $order["tancan"] : "无"; $pushu = "交易成功 商品标题:" . $order["name"] . " 开通时间:" . $tancan . " 订单:" . $order["order_no"] . " 代币:" . $xianshi . " 时间:" . $dhshi . " 金额:" . $formAmount . " " . $xianshi . " 类型:" . $typeoto . " 提醒地址:" . $address . " " . $typeoto . "地址:" . $bbaoadd . "" . "\r\n" . "\r\n" . '查询详细信息'; $Telegram->sendMessage($addinfo['botad'], $pushu); $info = Db::name("order")->where("id", $order["id"])->find(); $tmuid = Db::name("conf")->where("key", 'tmuid')->value('value'); $tmkey = Db::name("conf")->where("key", 'tmkey')->value('value'); $cycleMap = ['3' => '0', '6' => '1', '12' => '2']; $mappedValue = $cycleMap[$info['tancan']] ?? '3'; //区分是批量 还是单个 if ($order['moth'] == "pkaihuiy") { //批量开通 $dakai = json_decode($order['username'], true); foreach ($dakai as $key => $value) { $reqx = $Customer->submitkt($tmuid, $tmkey, $addinfo['botid'],$info["order_no"], $order['danprice'], "@" . $value, $mappedValue, $addinfo['apiurl']); if ($reqx['code'] == 0) { $Telegram->sendMessage($addinfo['botad'], $reqx['msg'] . "\r\n" . "单号:" . $order["order_no"] . "" . "\r\n" . "用户名:" . $order['username'] . "" . "\r\n" . "开通时间:" . $order['tancan'] . "" . "\r\n" . "消费金额:" . $order['money'] . "" . "\r\n" . "处理方法:充值余额后手动提交给机器人代替客户开通"); //return true; $Telegram->sendMessage($order['userid'], "订单提交成功!请联系客服,尽快处理!单号:" . $order["order_no"] . ""); } else { $Telegram->sendMessage($order['userid'], $reqx['msg']); //return true; } } } if ($order['moth'] == "huiyuangoumaai") { //单个会员开通 $reqx = $Customer->submitkt($tmuid, $tmkey, $addinfo['botid'],$info["order_no"], $info['money'], $info['username'], $mappedValue, $addinfo['apiurl']); var_dump($reqx); if ($reqx['code'] == 0) { $Telegram->sendMessage($addinfo['botad'], $reqx['msg'] . "\r\n" . "单号:" . $info["order_no"] . "" . "\r\n" . "用户名:" . $info['username'] . "" . "\r\n" . "开通时间:" . $info['tancan'] . "" . "\r\n" . "消费金额:" . $info['money'] . "" . "\r\n" . "处理方法:充值余额后手动提交给机器人代替客户开通"); //return true; $Telegram->sendMessage($info['userid'], "订单提交成功!请联系客服,尽快处理!单号:" . $order["order_no"] . ""); } else { $Telegram->sendMessage($info['userid'], $reqx['msg']); //return true; } } //余额充值 if($order['moth'] == "yuepay"){ $Customer-> ChangeMoney($info['userid'], 'member', "+", $amount, $addinfo['botid'], "u充值"); $Telegram->sendMessage($info['userid'], "充值成功了 【".$amount."】"); var_dump($info,"1111");exit(); } if (!empty($info['smessage_id'])) { $Telegram->deleteMessage($info['userid'], $info['smessage_id']); } if (!empty($info['message_id'])) { $Telegram->deleteMessage($info['userid'], $info['message_id']); } return json(['code' => 'success']); } else { $xianshi = "USDT-TRC20"; $typeoto = "转入"; $dhshi = date("Y-m-d H:i:s ", $timestamp); $bbaoadd = $from; $usr = "https://tronscan.org/#/transaction/" . $transaction_id; $pushu = "发现新的交易 没有匹配到订单 代币:" . $xianshi . " 时间:" . $dhshi . " 金额:" . $formAmount . " " . $xianshi . " 类型:" . $typeoto . " 提醒地址:" . $address . " " . $typeoto . "地址:" . $bbaoadd . "" . "\r\n" . "\r\n" . '查询详细信息'; if ($amount > 0.9) { //var_dump($pushu,$addinfo,$amount); $Telegram->sendMessage($addinfo['botad'], $pushu, null, null, 'HTML', true); } } // return json(['code'=>'success']); var_dump("处理ok success"); //return $this->success("处理ok success"); }else{ var_dump("处理了 跳出"); break; } }else{ var_dump("跳过 超时".$valuex['trxadd']); break; } } // var_dump($transaction_id); } } } public function getbill($trxadd){ if(strlen($trxadd)<20){ return []; } $url= "https://apilist.tronscanapi.com/api/filter/trc20/transfers?limit=20&start=0&sort=-timestamp&count=true&filterTokenValue=0&relatedAddress=".$trxadd; $ym=json_decode(file_get_contents($url),true) ; $retdata=isset($ym['token_transfers'])?$ym['token_transfers']:null; return $retdata; } public function curl_get($url, $data = []) { // 处理get数据 if (!empty($data)) { $url = $url . '?' . http_build_query($data); } $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);//这个是重点。 $result = curl_exec($curl); curl_close($curl); return $result; } public function admincallback() { var_dump('success');exit; $data = $this->request->only(['to', 'from', 'money', 'hash', 'method', 'contract_address', 'paytype', 'timestamp']); if ($data['contract_address'] == "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t") { if ($data['method'] == "transfer(address _to,uint256 _value)") { if ($data['paytype'] == "in") { $money = $data['money'] / 1000000; $address = $data['to']; $amount = $data['money'] / 1000000; $formAmount = number_format($money, 5, '.', ''); $transaction_id = $data['hash']; $from = $data['from']; $to = $data['to']; $timestamp = $data['timestamp'] / 1000; //通过地址获取到机器人的信息 $addinfo = Db::name("admin_bot")->where('trxadd', $address)->find(); $Telegram = new Telegrambot($addinfo['botkey']); $Customer=new Customer(); if (!empty($addinfo['trxadd'])) { if (!Db::name("k_chuliok")->where("transaction_id", $transaction_id)->find()) { //防止二次处理 涉及到钱 Db::name("k_chuliok")->insert(['transaction_id' => $transaction_id, "from" => $from, "to" => $to, "money" => $amount]); //查询没有处理的订单 $order = Db::name("order")->where('botid', $addinfo['botid'])->where([["end_time", ">=", time()], ["trxadd", "=", $address], ["paymoney", "=", $formAmount], ["start", "=", 0]])->find(); // var_dump($order,$formAmount); if (!empty($order["id"])) { Cache::set($order["order_no"], $order["order_no"], 320); Db::name("order")->where("id", $order["id"])->update(array("start" => 1)); $xianshi = "USDT-TRC20"; $typeoto = "转入"; $dhshi = date("Y-m-d H:i:s ", $timestamp); $bbaoadd = $data['from']; $usr = "https://tronscan.org/#/transaction/" . $data['hash']; $tancan = isset($order["tancan"]) ? $order["tancan"] : "无"; $pushu = "交易成功 商品标题:" . $order["name"] . " 开通时间:" . $tancan . " 订单:" . $order["order_no"] . " 代币:" . $xianshi . " 时间:" . $dhshi . " 金额:" . $formAmount . " " . $xianshi . " 类型:" . $typeoto . " 提醒地址:" . $address . " " . $typeoto . "地址:" . $bbaoadd . "" . "\r\n" . "\r\n" . '查询详细信息'; $Telegram->sendMessage($addinfo['botad'], $pushu); $info = Db::name("order")->where("id", $order["id"])->find(); $tmuid = Db::name("conf")->where("key", 'tmuid')->value('value'); $tmkey = Db::name("conf")->where("key", 'tmkey')->value('value'); $cycleMap = ['3' => '0', '6' => '1', '12' => '2']; $mappedValue = $cycleMap[$info['tancan']] ?? '3'; //区分是批量 还是单个 if ($order['moth'] == "pkaihuiy") { //批量开通 $dakai = json_decode($order['username'], true); foreach ($dakai as $key => $value) { $reqx = $Customer->submitkt($tmuid, $tmkey, $addinfo['botid'],$info["order_no"], $order['danprice'], "@" . $value, $mappedValue, $addinfo['apiurl']); if ($reqx['code'] == 0) { $Telegram->sendMessage($addinfo['botad'], $reqx['msg'] . "\r\n" . "单号:" . $order["order_no"] . "" . "\r\n" . "用户名:" . $order['username'] . "" . "\r\n" . "开通时间:" . $order['tancan'] . "" . "\r\n" . "消费金额:" . $order['money'] . "" . "\r\n" . "处理方法:充值余额后手动提交给机器人代替客户开通"); //return true; $Telegram->sendMessage($order['userid'], "订单提交成功!请联系客服,尽快处理!单号:" . $order["order_no"] . ""); } else { $Telegram->sendMessage($order['userid'], $reqx['msg']); //return true; } } } if ($order['moth'] == "huiyuangoumaai") { //单个会员开通 $reqx = $Customer->submitkt($tmuid, $tmkey, $addinfo['botid'],$info["order_no"], $info['money'], $info['username'], $mappedValue, $addinfo['apiurl']); //var_dump($reqx); if ($reqx['code'] == 0) { $Telegram->sendMessage($addinfo['botad'], $reqx['msg'] . "\r\n" . "单号:" . $info["order_no"] . "" . "\r\n" . "用户名:" . $info['username'] . "" . "\r\n" . "开通时间:" . $info['tancan'] . "" . "\r\n" . "消费金额:" . $info['money'] . "" . "\r\n" . "处理方法:充值余额后手动提交给机器人代替客户开通"); //return true; $Telegram->sendMessage($info['userid'], "订单提交成功!请联系客服,尽快处理!单号:" . $order["order_no"] . ""); } else { $Telegram->sendMessage($info['userid'], $reqx['msg']); //return true; } } //余额充值 if($order['moth'] == "yuepay"){ $Customer-> ChangeMoney($info['userid'], 'member', "+", $amount, $addinfo['botid'], "u充值"); $Telegram->sendMessage($info['userid'], "充值成功了 【".$amount."】"); var_dump($info,"1111");exit(); } if (!empty($info['smessage_id'])) { $Telegram->deleteMessage($info['userid'], $info['smessage_id']); } if (!empty($info['message_id'])) { $Telegram->deleteMessage($info['userid'], $info['message_id']); } return json(['code' => 'success']); } else { $xianshi = "USDT-TRC20"; $typeoto = "转入"; $dhshi = date("Y-m-d H:i:s ", $timestamp); $bbaoadd = $data['from']; $usr = "https://tronscan.org/#/transaction/" . $data['hash']; $pushu = "发现新的交易 没有匹配到订单 代币:" . $xianshi . " 时间:" . $dhshi . " 金额:" . $formAmount . " " . $xianshi . " 类型:" . $typeoto . " 提醒地址:" . $address . " " . $typeoto . "地址:" . $bbaoadd . "" . "\r\n" . "\r\n" . '查询详细信息'; if ($amount > 0.9) { //var_dump($pushu,$addinfo,$amount); $Telegram->sendMessage($addinfo['botad'], $pushu, null, null, 'HTML', true); } } // return json(['code'=>'success']); return $this->success("处理ok success"); }else{ return $this->success("已被处理 success"); } } else { return $this->success('ok success 地址没有绑定机器人'); } } } } //var_dump($data); } public function apicallback() { $data = $this->request->only(['uid', 'umoney', 'start', 'username', 'orderid']); $tmuid = Db::name("conf")->where("key", 'tmuid')->value('value'); if ($tmuid != $data['uid']) { return $this->error('uid 错误'); } if ($data['start'] == 2) { //验证单号 $odder = Db::name('ok_order')->where("order_no", $data['orderid'])->find(); if (empty($odder['order_no'])) { return $this->error('订单不存在'); } if ($odder['call'] == 1) { return $this->error('订单已处理'); } $odder = Db::name('order')->where("order_no", $odder['sn'])->find(); //更新订单状态 发送用户通知 $botid = $odder['botid']; //查询机器人 $botinfo = Db::name("admin_bot")->cache(60)->where("botid", $botid)->whereNull('delete_time')->find(); $Telegram = new Telegrambot($botinfo['botkey']); $msg = "会员开通成功了" . "\r\n" . "开通用户名:" . $data['username'] . "" . "\r\n" . "开通时间: " . $odder['tancan'] . "" . "\r\n" . "订单单号:" . $odder['order_no'] . "" . "\r\n" . "感谢您的支持!"; // var_dump($msg);exit(); $Telegram->sendMessage($odder['userid'], $msg); //通知机器人管理员一份儿 if($odder['userid']!=$botinfo['botad']){ $Telegram->sendMessage($botinfo['botad'], "开通成功通知"."\r\n". "开通用户名:" . $data['username'] . "" . "\r\n" . "开通时间: " . $odder['tancan'] . "" . "\r\n" . "订单单号:" . $odder['order_no'] . "" ); } Db::name('ok_order')->where("order_no", $data['orderid'])->update(['call' => 1]); return $this->success('ok'); } if ($data['start'] == 4) { //退单 $odder = Db::name('ok_order')->where("order_no", $data['orderid'])->find(); if (empty($odder['order_no'])) { return $this->error('订单不存在'); } if ($odder['call'] == 1) { return $this->error('订单已处理'); } $botid = $odder['botid']; $odder = Db::name('order')->where("order_no", $odder['sn'])->find(); //查询机器人 $botinfo = Db::name("admin_bot")->where("botid", $botid)->find(); $Telegram = new Telegrambot($botinfo['botkey']); $msg = "会员开通失败了" . "\r\n" . "开通用户名:" . $data['username'] . "" . "\r\n" . "开通时间: " . $odder['tancan'] . "" . "\r\n" . "订单单号:" . $odder['order_no'] . "" . "\r\n" . "消费金额:" . $odder['paymoney'] . "[已退回余额]" . "\r\n" . "如需开通请联系客服手动开通"; $Customer=new Customer(); $Customer-> ChangeMoney($odder['userid'], 'member', "+", $odder['money'], $botid, "退款" . $data['username']); $Telegram->sendMessage($odder['userid'], $msg); Db::name('ok_order')->where("order_no", $data['orderid'])->update(['call' => 1]); return $this->success('ok'); } // var_dump($odder,$data,"222"); } public function task() { $systemadd = Db::name("conf")->cache(600)->where("key", 'system')->value('value'); $conftask = cache::get("conftask"); if (empty($conftask)) { if (!empty($systemadd)) { if (preg_match('/^T(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]+$/', $systemadd)) { //var_dump("4444","地址合规"); cache::set("conftask", $systemadd, 10); $this->Queryamountchange($systemadd); } } } $this->send(); } public function Queryamountchange($trxadd) { $curl = curl_init(); curl_setopt_array($curl, [ CURLOPT_URL => "https://api.trongrid.io/v1/accounts/" . $trxadd . "/transactions/trc20?only_to=true&limit=10&contract_address=TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t", CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 30, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => [ "Accept: application/json" ], ]); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { $hui = json_decode($response, true); } foreach ($hui["data"] as $key => $value) { // var_dump($value); $hash = $value['transaction_id']; $timestamp = $value['block_timestamp'] / 1000 + 200; if ($timestamp > time()) { // 处理过的 写入缓存 过期即可 不处理 $chuliguo = Cache::get("chuliguodehaxi" . $hash); if (!$chuliguo) { $owner_address = $value['from']; $to_address = $value['to']; $amount = $value['value'] / 1000000; if ($amount > 1) { //查询 用户地址 对应的用户 $hot = Db::name("admin_bot")->where(['trxadd' => $owner_address])->find(); if ($value['type'] == "Transfer") { if (isset($hot["id"])) { $Customer=new Customer(); $Customer-> ChangeMoney($hot['botid'], 'admin', "+", $amount, "", "u充值"); Cache::set("chuliguodehaxi" . $hash, 1, 300); $system = Db::name("conf")->where("key", 'botkey')->value('value'); $masterid = Db::name("conf")->where("key", 'masterid')->value('value'); if (!empty($system)) { if (!empty($masterid)) { $Telegram = new Telegrambot($system); $msg = "充值成功" . "\r\n" . "来源:" . $owner_address . "" . "\r\n" . "金额:" . $amount . "" ."\r\n". "bot昵称:" . $hot['name'] . "" ."\r\n". "botbotuser:" . $hot['botuser'] . "" . "\r\n" . "请注意查看"; $Telegram->sendMessage($masterid, $msg); } } } else { //未找到用户 充值失败 $system = Db::name("conf")->where("key", 'botkey')->value('value'); $masterid = Db::name("conf")->where("key", 'masterid')->value('value'); if (!empty($system)) { if (!empty($masterid)) { $Telegram = new Telegrambot($system); $msg = "充值订单为匹配" . "\r\n" . "来源:" . $owner_address . "" . "\r\n" . "金额:" . $amount . "" . "\r\n" . "请注意查看"; $Telegram->sendMessage($masterid, $msg); } } } } // var_dump($owner_address,$to_address,$amount,$timestamp,$hash,$hot); } } else { echo "已处理"; } } // code... } } public function callback() { Log::record('测试日志信息'); $botid = Request::param("botid"); $parseMessage = $this->parseMessage(); //var_dump($parseMessage); $className = 'app\service\plugins\Premium'; $botinfo = Db::name("admin_bot")->cache(120)->where("botid", $botid)->whereNull('delete_time')->find(); if(!empty($botinfo)){ $class = new $className($parseMessage['data'], $botid); if (!empty($parseMessage["func"])) { echo $parseMessage["func"]; call_user_func_array(array($class, "init"), $parseMessage["intparam"]); if (method_exists($class, $parseMessage["func"])) { call_user_func_array(array($class, $parseMessage["func"]), $parseMessage["param"]); } } }else{ return $this->error('bot error'); } // var_dump($parseMessage); return $this->success('返回成功', ['action' => 'callback']); } public function setwebhook() { return $this->success('返回成功', ['action' => 'setwebhook']); } public function parseMessage() { $data = json_decode(file_get_contents("php://input"), true); Log::record(Request::url() . file_get_contents("php://input") . "\n", FILE_APPEND); if (isset($data['message'])) { if (isset($data['message']['text'])) { if (isset($data['message']['reply_to_message'])) { $data['message']['chat']['reply_to_message'] = $data['message']['reply_to_message']; } /** 艾特处理 */ if (isset($data['message']['entities'])) { foreach ($data['message']['entities'] as $entities) { if ($entities['type'] == 'text_mention') { $mentionUserId = $entities['user']['id']; $mentionUserName = $entities['user']['first_name']; } if ($entities['type'] == 'mention') { $tmp = mb_substr($data['message']['text'], $entities['offset'] + 1, $entities['length'], "utf-8"); $mentionUserId = $tmp; $mentionUserName = $tmp; } $mentionUserId = isset($mentionUserId) ? $mentionUserId : ""; $mentionUserName = isset($mentionUserName) ? $mentionUserName : ""; $data['message']['at_array'][] = ['id' => $mentionUserId, 'name' => $mentionUserName]; $data['message']['at_ids'][] = $mentionUserId; } } if ($data['message']['text'][0] == '/') { $data['message']['text'] = str_replace("\n", " ", $data['message']['text']); $messageExplode = explode(' ', $data['message']['text']); $commandExplode = explode('@', $messageExplode[0]); if (isset($commandExplode[1]) && $commandExplode[1] != BOTNAME) exit(); $func = 'command'; $param = [ $commandExplode[0], array(), $data['message']['message_id'], $data['message']['from'], $data['message']['chat'], $data['message']['date'], ]; $initParam = [ $func, $data['message']['from'], $data['message']['chat'], $data['message']['date'], ]; if (isset($messageExplode[1])) { $param[1] = array_slice($messageExplode, 1); } } else { if (isset($data['message']) && !isset($data['message']['reply_to_message'])) { $func = 'message'; $param = [ $data['message']['text'], $data['message']['message_id'], $data['message']['from'], $data['message']['chat'], $data['message']['date'], ]; $initParam = [ $func, $data['message']['from'], $data['message']['chat'], $data['message']['date'], ]; } else { $func = 'reply_message'; $param = [ $data['message']['text'], $data['message']['message_id'], $data['message']['reply_to_message']['text'], $data['message']['reply_to_message']['message_id'], $data['message']['reply_to_message']['date'], $data['message']['from'], $data['message']['chat'], $data['message']['reply_to_message']['from']['is_bot'], ]; $initParam = [ $func, $data['message']['from'], $data['message']['chat'], $data['message']['date'], ]; } } } else if (isset($data['message']['new_chat_title'])) { $func = 'new_chat_title'; $param = [ $data['message']['new_chat_title'], $data['message']['message_id'], $data['message']['from'], $data['message']['chat'], $data['message']['date'], ]; $initParam = [ $func, $data['message']['from'], $data['message']['chat'], $data['message']['date'], ]; } else if (isset($data['message']['new_chat_member'])) { $func = 'new_member'; $param = [ $data['message']['new_chat_member'], $data['message']['message_id'], $data['message']['from'], $data['message']['chat'], $data['message']['date'], ]; $initParam = [ $func, $data['message']['from'], $data['message']['chat'], $data['message']['date'], ]; } else if (isset($data['message']['left_chat_member'])) { $func = 'left_member'; $param = [ $data['message']['left_chat_member'], $data['message']['message_id'], $data['message']['from'], $data['message']['chat'], $data['message']['date'], ]; $initParam = [ $func, $data['message']['from'], $data['message']['chat'], $data['message']['date'], ]; } else if (isset($data['message']['sticker'])) { $func = 'sticker'; $param = [ $data['message']['sticker'], $data['message']['message_id'], $data['message']['from'], $data['message']['chat'], $data['message']['date'], ]; $initParam = [ $func, $data['message']['from'], $data['message']['chat'], $data['message']['date'], ]; } else if (isset($data['message']['photo'])) { $caption = ''; if (isset($data['message']['caption'])) { $caption = $data['message']['caption']; } $func = 'photo'; $param = [ $data['message']['photo'], $caption, $data['message']['message_id'], $data['message']['from'], $data['message']['chat'], $data['message']['date'], ]; $initParam = [ $func, $data['message']['from'], $data['message']['chat'], $data['message']['date'], ]; } else if (isset($data['message']['document'])) { $caption = ''; if (isset($data['message']['caption'])) { $caption = $data['message']['caption']; } $func = 'document'; $param = [ $data['message']['document'], $caption, $data['message']['message_id'], $data['message']['from'], $data['message']['chat'], $data['message']['date'], ]; $initParam = [ $func, $data['message']['from'], $data['message']['chat'], $data['message']['date'], ]; } } else if (isset($data['callback_query'])) { if (isset($data['callback_query']['data'])) { //['callback_query']['chat_instance'] $func = 'callback_query'; $param = [ $data['callback_query']['data'], $data['callback_query']['id'], $data['callback_query']['from'], $data['callback_query']['message']['message_id'], $data['callback_query']['message']['from'], $data['callback_query']['message']['chat'], $data['callback_query']['message']['date'] ]; $initParam = [ $func, $data['callback_query']['from'], $data['callback_query']['message']['chat'], $data['callback_query']['message']['date'] ]; } else if (isset($data['callback_query']['game_short_name'])) { $func = 'callback_game'; $param = [ $data['callback_query']['game_short_name'], $data['callback_query']['id'], $data['callback_query']['from'] ]; $initParam = [ $func, $data['callback_query']['from'], $data['callback_query']['from'], time() ]; } } else if (isset($data['inline_query'])) { $func = 'inline_query'; $param = [ $data['inline_query']['query'], $data['inline_query']['offset'], $data['inline_query']['id'], $data['inline_query']['from'] ]; $initParam = [ $func, $data['inline_query']['from'], $data['inline_query']['from'], time() ]; } else if (isset($data['business_message'])) { if (isset($data['business_message']['text'])) { $data['business_message']['from']['business_connection_id'] = $data['business_message']['business_connection_id']; if ($data['business_message']['text'][0] == '/') { $data['business_message']['text'] = str_replace("\n", " ", $data['business_message']['text']); $messageExplode = explode(' ', $data['business_message']['text']); $commandExplode = explode('@', $messageExplode[0]); if (isset($commandExplode[1]) && $commandExplode[1] != BOTNAME) exit(); $func = 'qiye_command'; $param = [ $commandExplode[0], array(), $data['business_message']['message_id'], $data['business_message']['from'], $data['business_message']['chat'], $data['business_message']['date'], ]; $initParam = [ $func, $data['business_message']['from'], $data['business_message']['chat'], $data['business_message']['date'], ]; // var_dump($param,$initParam); if (isset($messageExplode[1])) { $param[1] = array_slice($messageExplode, 1); } } else { if (isset($data['business_message']) && !isset($data['message']['reply_to_message'])) { $func = 'business_message'; $param = [ $data['business_message']['text'], $data['business_message']['message_id'], $data['business_message']['from'], $data['business_message']['chat'], $data['business_message']['date'], ]; $initParam = [ $func, $data['business_message']['from'], $data['business_message']['chat'], $data['business_message']['date'], ]; } } } } if (isset($func)) { return array("func" => $func, "param" => $param, "intparam" => $initParam, "data" => $data); } else { return array("func" => null, "param" => null, "intparam" => null, "data" => null); } } }