forward icon indicating copy to clipboard operation
forward copied to clipboard

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

Open Harry-zklcdc opened this issue 1 year ago • 9 comments

版本信息

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)

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

https://github.com/bot-myrtus/forward/blob/39823e0e186b03fd8822b0fc7097294ee7d4e868/src/core.ts#L183

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

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

Harry-zklcdc avatar Feb 14 '24 09:02 Harry-zklcdc

查看 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)

即可正常工作

Harry-zklcdc avatar Feb 14 '24 16:02 Harry-zklcdc

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

idranme avatar Feb 15 '24 16:02 idranme

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

Harry-zklcdc avatar Feb 16 '24 20:02 Harry-zklcdc

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

截图配置

idranme avatar Feb 17 '24 01:02 idranme

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

Harry-zklcdc avatar Feb 17 '24 11:02 Harry-zklcdc

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

idranme avatar Feb 17 '24 12:02 idranme

image

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

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

Harry-zklcdc avatar Feb 17 '24 12:02 Harry-zklcdc

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

idranme avatar Feb 17 '24 15:02 idranme

image

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

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

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

WaveWSBS avatar Oct 14 '24 13:10 WaveWSBS