Skip to content

【JS】询问一下有无1.2新增的seal.createTempCtx(endpoint, msg)方法使用实例 #169

Closed Answered by Szzrain
kakakumous asked this question in Q&A
Discussion options

You must be logged in to vote

createTempCtx 可以主动创建 ctx 对象用于发送消息或者其他需要 ctx 对象的场景,以下代码是我在 gamechat.js 中的一个用于创建 ctx 和 msg 的函数

function getCtxAndMsgById(epId, groupId, guildId, senderId, isPrivate) {
        let eps = seal.getEndPoints();
        for (let i = 0; i < eps.length; i++) {
            if (eps[i].userId === epId) {
                let msg = seal.newMessage();
                if (isPrivate === true) {
                    msg.messageType = "private";
                } else {
                    msg.messageType = "group";
                    msg.groupId = groupId;
                }
                msg.guildId = guildId;
                msg.sender.userId = senderId;
                return [seal.createTempCtx(eps[i], 

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Szzrain
Comment options

Answer selected by Szzrain
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants