diff --git a/src/DingTalk/Message/Base.php b/src/DingTalk/Message/Base.php index eafcf11..567cef4 100644 --- a/src/DingTalk/Message/Base.php +++ b/src/DingTalk/Message/Base.php @@ -23,13 +23,20 @@ abstract class Base extends SplBean implements MessageInterface public function getAtText($text = '') { - foreach (['atMobiles', 'atUserIds'] as $item) - { - foreach ($this->{$item} as $tel) - { + foreach (['atMobiles', 'atUserIds'] as $item) { + foreach ($this->{$item} as $tel) { $text .= ' @' . $tel; } } return $text; } + + public function getServerText($text = '') + { + return $text . PHP_EOL . implode(PHP_EOL, [ + '系统:' . APP_MODULE, + '服务器:' . config('SERVNAME'), + '时间:' . date('Y年m月d日 H:i:s') + ]); + } } diff --git a/src/DingTalk/Message/Text.php b/src/DingTalk/Message/Text.php index a344061..0288948 100644 --- a/src/DingTalk/Message/Text.php +++ b/src/DingTalk/Message/Text.php @@ -11,7 +11,7 @@ public function fullData() return [ 'msgtype' => 'text', 'text' => [ - 'content' => $this->getAtText($this->content) + 'content' => $this->getServerText($this->getAtText($this->content)) ], 'at' => [ 'atMobiles' => $this->atMobiles, diff --git a/src/WeChat/Config.php b/src/WeChat/Config.php index a6b69f6..5264c59 100644 --- a/src/WeChat/Config.php +++ b/src/WeChat/Config.php @@ -2,10 +2,16 @@ namespace WonderGame\EsNotify\WeChat; +use EasySwoole\Spl\SplBean; use WonderGame\EsNotify\Interfaces\ConfigInterface; use WonderGame\EsNotify\Interfaces\NotifyInterface; -use EasySwoole\Spl\SplBean; +/** + * @document https://developers.weixin.qq.com/doc/offiaccount/Message_Management/Template_Message_Interface.html + * + * 更新公告:https://mp.weixin.qq.com/cgi-bin/announce?action=getannouncement&announce_id=11680142498cInTZ&version=&lang=zh_CN&token=2080631067 + * + */ class Config extends SplBean implements ConfigInterface { /** @@ -86,8 +92,7 @@ public function getAppend() public function setToOpenid($openid) { - if (is_string($openid)) - { + if (is_string($openid)) { $openid = [$openid]; } $this->toOpenid = $openid; diff --git a/src/WeChat/Message/Notice.php b/src/WeChat/Message/Notice.php index 2421dc9..4425743 100644 --- a/src/WeChat/Message/Notice.php +++ b/src/WeChat/Message/Notice.php @@ -4,25 +4,15 @@ class Notice extends Base { - protected $title = ''; - protected $content = ''; - protected $color = '#32CD32'; - public function struct() { return [ - 'first' => [ - 'value' => $this->title, - 'color' => $this->color - ], - 'keyword1' => [ - 'value' => $this->content, - 'color' => $this->color - ], - 'keyword3' => date('Y年m月d日 H:i:s'), - 'remark' => '查看详情' + 'keyword1' => ['value' => $this->content], + 'keyword2' => ['value' => APP_MODULE], + 'keyword3' => ['value' => config('SERVNAME')], + 'keyword4' => ['value' => date('Y年m月d日 H:i:s')], ]; } } diff --git a/src/WeChat/Message/Warning.php b/src/WeChat/Message/Warning.php index 42335b2..85ad870 100644 --- a/src/WeChat/Message/Warning.php +++ b/src/WeChat/Message/Warning.php @@ -4,37 +4,15 @@ class Warning extends Base { - protected $file = ''; - - protected $line = ''; - - protected $servername = ''; - - protected $message = ''; - - protected $color = '#FF0000'; + protected $content = ''; public function struct() { return [ - 'first' => [ - 'value' => "程序异常:第{$this->line}行", - 'color' => $this->color - ], - 'keyword1' => [ - 'value' => "服务器: {$this->servername}", - 'color' => $this->color - ], - 'keyword2' => [ - 'value' => "相关文件: {$this->file}", - 'color' => $this->color - ], - 'keyword3' => [ - 'value' => "相关内容:{$this->message}", - 'color' => $this->color - ], - 'keyword4' => date('Y年m月d日 H:i:s'), - 'remark' => '查看详情' + 'keyword1' => ['value' => $this->content], + 'keyword2' => ['value' => APP_MODULE], + 'keyword3' => ['value' => config('SERVNAME')], + 'keyword4' => ['value' => date('Y年m月d日 H:i:s')], ]; } }