Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ PostMessage message = PostMessage.build().lang(
.title("项目更新通知")
.addTags(
PostTags.build().addTags(
TextTag.builder().text("项目有更新: ").build(),
TextTag.builder().text("项目有更新: ").enter().build(),
ATag.builder().text("请查看").href("http://www.example.com/").build(),
AtTag.builder().atAll(true).build()
)
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>io.github.group-robot</groupId>
<artifactId>feishu-robot-core</artifactId>
<version>1.0.4</version>
<version>1.0.5</version>

<packaging>jar</packaging>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ public class TextTag extends PostTag {
* 表示是不是 unescape 解码,默认为 false ,不用可以不填
*/
private Boolean unEscape;
/**
* 换行
*/
private boolean enter;

@Override
public String tag() {
Expand All @@ -34,6 +38,9 @@ public String tag() {
public Map<String, Object> toMessage() {
Map<String, Object> textMap = new HashMap<>(3);
textMap.put("tag", tag());
if (this.enter) {
this.text = this.text + "\n";
}
textMap.put("text", this.text);
textMap.put("un_escape", this.unEscape);
return textMap;
Expand Down Expand Up @@ -78,6 +85,29 @@ public TextTagBuilder text(String text) {
return this;
}

/**
* 文本内容
*
* @param text .
* @param enter .
* @return .
*/
public TextTagBuilder text(String text, boolean enter) {
this.textTag.setText(text);
this.textTag.setEnter(enter);
return this;
}

/**
* 换行
*
* @return .
*/
public TextTagBuilder enter() {
this.textTag.setEnter(true);
return this;
}

/**
* 表示是不是 unescape 解码,默认为 false ,不用可以不填
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,33 @@ public void issues4Test() {
FeishuRobotResponse feiShuRobotResponse = send.sendMessage(message);
System.out.println(feiShuRobotResponse.getMsg());
}

@Test
public void pr8Test() {
PostMessage message = PostMessage.build().lang(
PostLang.builder()
.lang("zh_cn")
.unit(
PostUnit.build()
.title("订单支付成功")
.addTags(
PostTags.build().addTags(
TextTag.builder().text("商品为: ").enter().build(),
TextTag.builder().text("支付金额为: ").enter().build(),
TextTag.builder().text("取餐码为: ").enter().build(),
ATag.builder().text("请查看").href("http://www.example.com/").build(),
AtTag.builder().atAll(true).build()
)
)
)
.build()
);
String webhok = System.getenv("webhook");
String secret = System.getenv("secret");
FeishuRobotClient send = new FeishuRobotClient();
send.setSecret(secret);
send.setWebhook(webhok);
FeishuRobotResponse feiShuRobotResponse = send.sendMessage(message);
System.out.println(feiShuRobotResponse.getMsg());
}
}