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

feat: adapt https://github.com/satorijs/satori/pull/196 #8

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions src/bot/message.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Context, h, MessageEncoder, pick, Universal } from 'koishi'
import { Channel, Context, h, MessageEncoder, pick, Universal } from 'koishi'
import { BaseBot } from './base'
import { CQCode } from './cqcode'

Expand All @@ -18,12 +18,21 @@
stack: State[] = [new State('message')]
children: CQCode[] = []

override async prepare(): Promise<void> {
super.prepare()

this.session.isDirect = this.channelId.startsWith('private:')
this.session.channel.type = this.session.isDirect ? Channel.Type.DIRECT : Channel.Type.TEXT

Check failure on line 25 in src/bot/message.ts

View workflow job for this annotation

GitHub Actions / build

Property 'type' does not exist on type 'Observed<never>'.

Check failure on line 25 in src/bot/message.ts

View workflow job for this annotation

GitHub Actions / build

Property 'Type' does not exist on type 'typeof Channel'.

Check failure on line 25 in src/bot/message.ts

View workflow job for this annotation

GitHub Actions / build

Property 'Type' does not exist on type 'typeof Channel'.

Check failure on line 25 in src/bot/message.ts

View workflow job for this annotation

GitHub Actions / build

Property 'type' does not exist on type 'Observed<never>'.

Check failure on line 25 in src/bot/message.ts

View workflow job for this annotation

GitHub Actions / build

Property 'Type' does not exist on type 'typeof Channel'.

Check failure on line 25 in src/bot/message.ts

View workflow job for this annotation

GitHub Actions / build

Property 'Type' does not exist on type 'typeof Channel'.
this.session.subtype = this.session.isDirect ? 'private' : 'group'
if (!this.session.isDirect) this.guildId = this.channelId
}

async forward() {
if (!this.stack[0].children.length) return
const session = this.bot.session()
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.isDirect
? '' + await this.bot.internal.sendPrivateForwardMsg(this.channelId.slice(8), this.stack[0].children)
: '' + await this.bot.internal.sendGroupForwardMsg(this.guildId, this.stack[0].children)
session.userId = this.bot.selfId
session.channelId = this.session.channelId
session.guildId = this.session.guildId
Expand Down Expand Up @@ -81,9 +90,9 @@
const session = this.bot.session()
session.messageId = this.bot.parent
? '' + await this.bot.internal.sendGuildChannelMsg(this.guildId, this.channelId, this.children)
: this.guildId
? '' + await this.bot.internal.sendGroupMsg(this.guildId, this.children)
: '' + await this.bot.internal.sendPrivateMsg(this.channelId.slice(8), this.children)
: this.session.isDirect
? '' + await this.bot.internal.sendPrivateMsg(this.channelId.slice(8), this.children)
: '' + await this.bot.internal.sendGroupMsg(this.guildId, this.children)
session.userId = this.bot.selfId
session.channelId = this.session.channelId
session.guildId = this.session.guildId
Expand Down
Loading