Skip to content
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

Merged
merged 4 commits into from
Feb 24, 2024
Merged

refa: MessageEncoder related changes #20

merged 4 commits into from
Feb 24, 2024

Conversation

lgc2333
Copy link
Contributor

@lgc2333 lgc2333 commented Feb 19, 2024

#18

Copy link
Member

@ilharp ilharp left a 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() 方法中做五件事来填充,可以看这里:

satorijs/satori#196 (comment)

直接在当前类里新写 async prepare() {} 即可,Satori 会自动调用

写完以后记得本地测试一下

src/bot/message.ts Show resolved Hide resolved
src/bot/message.ts Outdated Show resolved Hide resolved
src/bot/message.ts Outdated Show resolved Hide resolved
@lgc2333 lgc2333 requested a review from ilharp February 20, 2024 05:09
@lgc2333 lgc2333 changed the title fix: group message sendability when using plugin server-satori refactor: MessageEncoder related changes Feb 20, 2024
? Universal.Channel.Type.DIRECT
: Universal.Channel.Type.TEXT
}
this.session.isDirect = channel.type === Universal.Channel.Type.DIRECT
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个要设吗,core 里面的 isDirect 的 setter 和这个作用一样吧

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不知道,il让这样改的

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个要设吗,core 里面的 isDirect 的 setter 和这个作用一样吧

在哪里

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isDirect 是 accessor,已经设置了 type 的情况下不应该手动设置。

应当仅同步 type 本身。

src/bot/message.ts Show resolved Hide resolved
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
Copy link
Member

@XxLittleCxX XxLittleCxX Feb 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上

@lgc2333 lgc2333 requested a review from ilharp February 21, 2024 18:23
src/bot/message.ts Outdated Show resolved Hide resolved
@lgc2333 lgc2333 requested a review from shigma February 24, 2024 04:08
@shigma shigma merged commit 1d83a8c into koishijs:main Feb 24, 2024
@shigma shigma changed the title refactor: MessageEncoder related changes refa: MessageEncoder related changes Feb 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants