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

[Bug] 🐛 TG 无法发送至指定话题 #25

Open
Harry-zklcdc opened this issue Feb 14, 2024 · 9 comments
Open

[Bug] 🐛 TG 无法发送至指定话题 #25

Harry-zklcdc opened this issue Feb 14, 2024 · 9 comments

Comments

@Harry-zklcdc
Copy link

Harry-zklcdc commented Feb 14, 2024

版本信息

Koishi 4.16.8
@myrtus/koishi-plugin-forward 3.9.1

配置文件

image
image
image

日志文件

2024-02-14 16:56:49 [E] forward Error: Telegram API error 400. Bad Request: chat not found
    at _Internal.<computed> [as sendMessage] (koishi/node_modules/@satorijs/adapter-telegram/lib/index.js:88:17)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async _TelegramMessageEncoder.flush (koishi/node_modules/@satorijs/adapter-telegram/lib/index.js:465:22)
    at async _TelegramMessageEncoder.send (koishi/node_modules/@satorijs/core/lib/index.cjs:571:5)
    at async _TelegramBot.sendMessage (koishi/node_modules/@satorijs/core/lib/index.cjs:336:22)
    at async Proxy.<anonymous> (koishi/node_modules/@myrtus/koishi-plugin-forward/lib/core.js:164:40)

猜测可能下面这行代码导致

const messageIds = await bot.sendMessage(target.channelId, payload, target.guildId)

Koishi 的 bot.sendMessage 方法不支持 guildId 了,文档:https://koishi.chat/zh-CN/api/resources/message.html#bot-getmessage

可能需要特殊判断,使用 telegram 适配器内部方法 internal.sendMessage() 代替

@Harry-zklcdc
Copy link
Author

查看 tg 适配器源码,发现其读取的是 session 的guildId

https://github.com/satorijs/satori/blob/27822a0d4412a824ac46594fa2681a0e2d1109d5/adapters/telegram/src/message.ts#L38-L44

将报告代码修改为

const messageIds = await ctx.broadcast([target.platform+':'+target.channelId], payload)

即可正常工作

@idranme
Copy link
Collaborator

idranme commented Feb 15, 2024

已发布 4.0.1,请在更新后重新填写频道 ID

@Harry-zklcdc
Copy link
Author

依旧还是无法正常运行,能需要修改报告的那一行代码才可以运行

@idranme
Copy link
Collaborator

idranme commented Feb 17, 2024

依旧还是无法正常运行,能需要修改报告的那一行代码才可以运行

截图配置

@Harry-zklcdc
Copy link
Author

constants:
  TgFeed:
    type: full
    platform: telegram
    selfId: '67****'
    channelId: '5'
    name: TG Feed
  TgAsk:
    type: full
    platform: telegram
    selfId: '67****'
    channelId: '4'
    name: TG 求助提问
  TgChat:
    type: full
    platform: telegram
    selfId: '67****'
    channelId: '-10****'
    name: TG 闲聊灌水
  TgFeature:
    type: full
    platform: telegram
    selfId: '67****'
    channelId: '206'
    name: TG 功能需求
  QQFeed:
    type: full
    platform: qqguild
    selfId: '82****'
    channelId: '63****'
    name: QQ Feed
  QQAsk:
    type: full
    platform: qqguild
    selfId: '82****'
    channelId: '63****'
    name: QQ频道 求助提问
  QQChat:
    type: full
    platform: qqguild
    selfId: '82****'
    channelId: '63****'
    name: QQ频道 闲聊灌水
  QQFeature:
    type: full
    platform: qqguild
    selfId: '82****'
    channelId: '63****'
    name: QQ频道 功能需求
rules:
  - targets:
      - QQFeed
    source: TgFeed
  - targets:
      - TgFeed
    source: QQFeed
  - targets:
      - TgAsk
    source: QQAsk
  - targets:
      - QQAsk
    source: TgAsk
  - targets:
      - TgChat
    source: QQChat
  - targets:
      - QQChat
    source: TgChat
  - targets:
      - TgFeature
    source: QQFeature
  - targets:
      - QQFeature
    source: TgFeature

@idranme
Copy link
Collaborator

idranme commented Feb 17, 2024

channelId 不对,请使用 inspect 插件获取

@Harry-zklcdc
Copy link
Author

Harry-zklcdc commented Feb 17, 2024

image

使用 ctx.broadcast 方法吧,bot.sendMessage 在 tg 适配器的实现中,并不是直接读取 guildId 的

参考: https://github.com/satorijs/satori/blob/27822a0d4412a824ac46594fa2681a0e2d1109d5/adapters/telegram/src/message.ts#L38-L44

@idranme
Copy link
Collaborator

idranme commented Feb 17, 2024

image

使用 ctx.broadcast 方法吧,bot.sendMessage 在 tg 适配器的实现中,并不是直接读取 guildId 的

参考: https://github.com/satorijs/satori/blob/27822a0d4412a824ac46594fa2681a0e2d1109d5/adapters/telegram/src/message.ts#L38-L44

4.0.1 没有读取 guildId

@WaveWSBS
Copy link

image

使用 ctx.broadcast 方法吧,bot.sendMessage 在 tg 适配器的实现中,并不是直接读取 guildId 的

参考: https://github.com/satorijs/satori/blob/27822a0d4412a824ac46594fa2681a0e2d1109d5/adapters/telegram/src/message.ts#L38-L44

請問一下您是怎麼修改插件的代碼的,我也遇到了相同的問題(

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

No branches or pull requests

3 participants