From 36de4e8ee35e39c04b3eb4ccae0820b0ad18ff1c Mon Sep 17 00:00:00 2001 From: Rico Date: Sat, 5 Jan 2019 22:30:56 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E5=A4=84=E7=90=86=EF=BC=8C=E4=BF=AE=E6=94=B9=E4=BA=86USER=20mo?= =?UTF-8?q?del=20=E8=8E=B7=E5=8F=96attributs=E7=9A=84=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Command/XCat.php | 7 ++++++- app/Models/User.php | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/Command/XCat.php b/app/Command/XCat.php index f6362737..0a314661 100644 --- a/app/Command/XCat.php +++ b/app/Command/XCat.php @@ -281,7 +281,12 @@ class XCat 今日之前已使用 " . $user->LastusedTraffic() . " " . number_format($user->last_day_t / $user->transfer_enable * 100, 2) . "% 未使用 " . $user->unusedTraffic() . " " . number_format(($user->transfer_enable - ($user->u + $user->d)) / $user->transfer_enable * 100, 2) . "% "; - $bot->sendMessage($user->get_telegram_id(), $reply_message , $parseMode = null, $disablePreview = false, $replyToMessageId = null); + try{ + $bot->sendMessage($user->get_user_attributes("telegram_id"), $reply_message , $parseMode = null, $disablePreview = false, $replyToMessageId = null); + + } catch (\TelegramBot\Api\HttpException $e){ + echo 'Message: 用户ID: '.$user->get_user_attributes("user_name")." 删除了账号或者屏蔽了宝宝"; + } } } } diff --git a/app/Models/User.php b/app/Models/User.php index 0e04179d..edc11b04 100755 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -341,8 +341,8 @@ class User extends Model $ref_user_id, $ref_user_name); return $return_array; } - public function get_telegram_id() + public function get_user_attributes($key) { - return $this->attributes['telegram_id']; + return $this->attributes[$key]; } } From 8d8566ae92ec38f066ac9e566720333b4e6a5641 Mon Sep 17 00:00:00 2001 From: Rico Date: Sat, 5 Jan 2019 22:31:23 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9message?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Command/XCat.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Command/XCat.php b/app/Command/XCat.php index 0a314661..3897badb 100644 --- a/app/Command/XCat.php +++ b/app/Command/XCat.php @@ -285,7 +285,7 @@ class XCat $bot->sendMessage($user->get_user_attributes("telegram_id"), $reply_message , $parseMode = null, $disablePreview = false, $replyToMessageId = null); } catch (\TelegramBot\Api\HttpException $e){ - echo 'Message: 用户ID: '.$user->get_user_attributes("user_name")." 删除了账号或者屏蔽了宝宝"; + echo 'Message: 用户: '.$user->get_user_attributes("user_name")." 删除了账号或者屏蔽了宝宝"; } } }