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

fix: group message sendability when using plugin server-satori #18

Closed
wants to merge 4 commits into from
Closed

Conversation

lgc2333
Copy link
Contributor

@lgc2333 lgc2333 commented Feb 19, 2024

No description provided.

@lgc2333 lgc2333 changed the title fix: message sendability when only provide channelId fix: group message sendability when only provide channelId Feb 19, 2024
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.channel.type 替代,session.channel.type 会在 Satori 协议中传输而 isDirect 不会

可能还需要 import { Channel } from 'koishi',Apply Suggestion 以后在本地测试一下吧

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.channelId.startsWith('private:')
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
session.messageId = this.channelId.startsWith('private:')
session.messageId = this.session.channel.type === Channel.Type.DIRECT

Copy link
Contributor Author

@lgc2333 lgc2333 Feb 19, 2024

Choose a reason for hiding this comment

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

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

是我的koishi版本问题吗

Copy link
Member

Choose a reason for hiding this comment

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

你点进去左面的 this.session.channel.type 看下是什么类型,用相同的类型就行

Copy link
Contributor Author

Choose a reason for hiding this comment

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

类型“Observed”上不存在属性“type”。

Copy link
Member

Choose a reason for hiding this comment

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

确实可能是 Koishi 的版本低了,尝试升级下你的 Koishi 版本(也可以新开一个开发环境

Copy link
Contributor Author

Choose a reason for hiding this comment

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

我的Koishi版本是4.17.0-beta.3

Copy link
Member

@shigma shigma Feb 19, 2024

Choose a reason for hiding this comment

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

session.event.channel

Copy link
Contributor Author

Choose a reason for hiding this comment

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

出问题
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

image
image

: this.guildId
? '' + await this.bot.internal.sendGroupMsg(this.guildId, this.children)
: '' + await this.bot.internal.sendPrivateMsg(this.channelId.slice(8), this.children)
: this.channelId.startsWith('private:')
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
: this.channelId.startsWith('private:')
: this.session.channel.type === Channel.Type.DIRECT

@lgc2333 lgc2333 changed the title fix: group message sendability when only provide channelId fix: group message sendability when using plugin server-satori Feb 19, 2024
@lgc2333
Copy link
Contributor Author

lgc2333 commented Feb 19, 2024

close due to #20

@lgc2333 lgc2333 closed this Feb 19, 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.

3 participants