-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
171 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,4 +86,4 @@ import io.github.kloping.qqbot.impl.ListenerHost; | |
|
||
更多使用方式参考查看 [test](./src/test/java) | ||
|
||
SDK尚在完善中... | ||
SDK尚在完善中... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/main/java/io/github/kloping/qqbot/entities/ex/Keyboard.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package io.github.kloping.qqbot.entities.ex; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
|
||
/** | ||
* 无模板 暂未适配自定义按钮 | ||
* 按钮不可单独发送 | ||
* 需与md一并发送 | ||
* | ||
* @author github.kloping | ||
*/ | ||
@Data | ||
@AllArgsConstructor | ||
public class Keyboard { | ||
private String id; | ||
} |
98 changes: 98 additions & 0 deletions
98
src/main/java/io/github/kloping/qqbot/entities/ex/Markdown.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
package io.github.kloping.qqbot.entities.ex; | ||
|
||
import com.alibaba.fastjson.JSON; | ||
import com.alibaba.fastjson.annotation.JSONField; | ||
import com.sun.istack.internal.Nullable; | ||
import io.github.kloping.qqbot.api.SendAble; | ||
import io.github.kloping.qqbot.api.SenderAndCidMidGetter; | ||
import io.github.kloping.qqbot.entities.ex.enums.EnvType; | ||
import io.github.kloping.qqbot.entities.qqpd.message.RawPreMessage; | ||
import io.github.kloping.qqbot.http.data.Result; | ||
import io.github.kloping.qqbot.http.data.V2MsgData; | ||
import io.github.kloping.qqbot.http.data.V2Result; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.LinkedList; | ||
import java.util.List; | ||
|
||
import static io.github.kloping.qqbot.entities.qqpd.Channel.SEND_MESSAGE_HEADERS; | ||
|
||
/** | ||
* @author github.kloping | ||
*/ | ||
@Getter | ||
public class Markdown implements SendAble { | ||
private String custom_template_id; | ||
private List<Param> params = new LinkedList<>(); | ||
|
||
/** | ||
* 原生md可用 | ||
*/ | ||
@Nullable | ||
private String content; | ||
|
||
@JSONField(serialize = false, deserialize = false) | ||
private Keyboard keyboard; | ||
|
||
/** | ||
* 需要再<a href="https://q.qq.com/qqbot/#/developer/advanced-features">QQ机器人管理平台</a> 申请并审核通过后使用 | ||
* | ||
* @param custom_template_id | ||
*/ | ||
public Markdown(String custom_template_id) { | ||
this.custom_template_id = custom_template_id; | ||
} | ||
|
||
public Markdown addParam(String key, String value) { | ||
params.add(new Param(key, new String[]{value})); | ||
return this; | ||
} | ||
|
||
public Markdown setContent(String content) { | ||
this.content = content; | ||
return this; | ||
} | ||
|
||
public Markdown setKeyboard(Keyboard keyboard) { | ||
this.keyboard = keyboard; | ||
return this; | ||
} | ||
|
||
public Markdown setKeyboard(String id) { | ||
return setKeyboard(new Keyboard(id)); | ||
} | ||
|
||
@Data | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public static class Param { | ||
|
||
public String key; | ||
private String[] values; | ||
} | ||
|
||
@Override | ||
public Result<V2Result> send(SenderAndCidMidGetter er) { | ||
return send(er, 1); | ||
} | ||
|
||
public Result<V2Result> send(SenderAndCidMidGetter er, Integer msgSeq) { | ||
if (er.getEnvType() == EnvType.GROUP) { | ||
V2MsgData v2MsgData = new V2MsgData(); | ||
v2MsgData.setMarkdown(this); | ||
v2MsgData.setMsg_type(2); | ||
v2MsgData.setMsg_id(er.getMid()); | ||
if (keyboard != null) v2MsgData.setKeyboard(getKeyboard()); | ||
return new Result(er.getBot().groupBaseV2.send(er.getCid(), JSON.toJSONString(v2MsgData), SEND_MESSAGE_HEADERS)); | ||
} else if (er.getEnvType() == EnvType.GUILD) { | ||
RawPreMessage preMessage = new RawPreMessage(); | ||
preMessage.setMarkdown(this); | ||
preMessage.setMsgId(er.getMid()); | ||
return new Result(er.getBot().messageBase.send(er.getCid(), preMessage, SEND_MESSAGE_HEADERS)); | ||
} | ||
return er.send(this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters