-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refa: MessageEncoder
related changes
#20
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不要用 this.channelId.startsWith('private:')
或 this.session.isDirect
- 前者是创建 Session 时才应该使用的方法,在 Session 外部可以调用 Session 的封装来判断
- 后者已被 Satori 协议标准的
session.event.channel.type
替代,session.event.channel.type
会在 Satori 协议中传输而isDirect
不会
session.event.channel.type
目前没有在创建 Session 时填充,需要在 prepare()
方法中做五件事来填充,可以看这里:
直接在当前类里新写 async prepare() {}
即可,Satori 会自动调用
写完以后记得本地测试一下
MessageEncoder
related changes
src/bot/message.ts
Outdated
? Universal.Channel.Type.DIRECT | ||
: Universal.Channel.Type.TEXT | ||
} | ||
this.session.isDirect = channel.type === Universal.Channel.Type.DIRECT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个要设吗,core 里面的 isDirect 的 setter 和这个作用一样吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不知道,il让这样改的
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个要设吗,core 里面的 isDirect 的 setter 和这个作用一样吧
在哪里
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isDirect 是 accessor,已经设置了 type 的情况下不应该手动设置。
应当仅同步 type 本身。
session.messageId = this.guildId | ||
? '' + await this.bot.internal.sendGroupForwardMsg(this.guildId, this.stack[0].children) | ||
: '' + await this.bot.internal.sendPrivateForwardMsg(this.channelId.slice(8), this.stack[0].children) | ||
session.messageId = this.session.event.channel.type === Universal.Channel.Type.DIRECT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
同上
MessageEncoder
related changesMessageEncoder
related changes
#18