Skip to content

Commit

Permalink
Merge pull request #118 from wonder-game/develop
Browse files Browse the repository at this point in the history
feat: 飞书可自定义模板内容(昝薪)
  • Loading branch information
linkunyuan authored Jul 4, 2024
2 parents 0f7946a + 820f4ff commit fa55571
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 18 deletions.
18 changes: 18 additions & 0 deletions src/Notify/Feishu/Message/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,24 @@ abstract class Base extends SplBean implements MessageInterface
*/
protected $atUserID = [];

/**
* 是否使用内部消息格式
* @var boolean
*/
protected $inner = true;

/**
* 主标题
* @var string
*/
protected $title = '程序异常';

/**
* 内容
* @var string
*/
protected $content = '';

protected $isAtAll = false;

public function getAtText($text = '')
Expand Down
8 changes: 3 additions & 5 deletions src/Notify/Feishu/Message/Card.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

class Card extends Base
{
protected $content = '';

public function fullData()
{
$data = [
Expand All @@ -16,7 +14,7 @@ public function fullData()
'tag' => 'div',
'text' => [
'tag' => 'lark_md',
'content' => $this->getServerText($this->content),
'content' => $this->inner ? $this->getServerText($this->content) : $this->content,
],
],
[
Expand All @@ -26,7 +24,7 @@ public function fullData()
'tag' => 'button',
'text' => [
'tag' => 'lark_md',
'content' => $this->getServerText($this->content),
'content' => $this->inner ? $this->getServerText($this->content) : $this->content,
],
'url' => 'https://www.baidu.com',
'type' => 'default',
Expand All @@ -45,7 +43,7 @@ public function fullData()
'header' => [
'title' => [
'tag' => 'plain_text',
'content' => '程序异常',
'content' => $this->title,
],
],
],
Expand Down
6 changes: 0 additions & 6 deletions src/Notify/Feishu/Message/CardError.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ class CardError extends Base
*/
protected $titleColor = 'red';

/**
* 主标题
* @var string
*/
protected $title = '程序异常';

/**
* 副标题,可不设置
* @var string
Expand Down
4 changes: 1 addition & 3 deletions src/Notify/Feishu/Message/Text.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@

class Text extends Base
{
protected $content = '';

public function fullData()
{
return [
'msg_type' => 'text',
'content' => [
'text' => $this->getAtText($this->getServerText($this->content)),
'text' => $this->inner ? $this->getAtText($this->getServerText($this->content)) : $this->content,
],
];
}
Expand Down
6 changes: 2 additions & 4 deletions src/Notify/Feishu/Message/Textarea.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,19 @@

class Textarea extends Base
{
protected $content = '';

public function fullData()
{
$data = [
'msg_type' => 'post',
'content' => [
'post' => [
'zh_cn' => [
'title' => '程序异常',
'title' => $this->title,
'content' => [
[
[
'tag' => 'text',
'text' => $this->getServerText($this->content),
'text' => $this->inner ? $this->getServerText($this->content) : $this->content,
],
],
],
Expand Down

0 comments on commit fa55571

Please sign in to comment.