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

Handling breaking changes in oicq v2.x #22

Open
anaivebird opened this issue Oct 19, 2021 · 3 comments
Open

Handling breaking changes in oicq v2.x #22

anaivebird opened this issue Oct 19, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@anaivebird
Copy link
Collaborator

These code should be changed to be compatible with oicq v2.x(will be released soon)

私聊消息事件中,删除了sender和user_id字段,添加了from_id和to_id字段。如果来自群还会有group_id字段。
群消息的sender字段中,不再提供sex age area。
群消息的seqid字段更名为seq。

According to https://github.com/takayama-lily/oicq/projects/3#card-70996148, this code here should
use rawPayload.from_id instead of rawPayload.sender.user_id.

fromId: String(rawPayload.sender.user_id),

This field will be missed for group message.

gender : genderStringToType[_rawPayload.sex]!,

@anaivebird
Copy link
Collaborator Author

need to handle rejection after node.js 16

API返回格式变更:
旧:返回的数据放在data字段中
新:直接返回数据(或throw)
※所以可能会抛出 Promise Rejection ,调用者需要自己捕捉(当然也可以不关心)
※之前data字段为null的api返回 Promise 表示是否成功
※注意:如果你使用Node.js16以上,不处理Rejection会导致程序挂掉,建议至少设定一个全局监听器:

https://github.com/takayama-lily/oicq/projects/3#card-67539296

process.on('unhandledRejection',()=>{
  //什么都不做
})

@anaivebird
Copy link
Collaborator Author

anaivebird commented Oct 19, 2021

message_id标记为废弃,原因是由于从服务端获得的消息时间时常会有秒数偏差,导致明明是同一条生成的消息id却不同。
建议使用seq+rand的形式更精确的管理消息。
https://github.com/takayama-lily/oicq/projects/3#card-71004439

We used to get the message_id get from oicq, but now need to manage message id ourself.

@huan huan pinned this issue Oct 19, 2021
@huan
Copy link
Member

huan commented Oct 19, 2021

※所以可能会抛出 Promise Rejection ,调用者需要自己捕捉(当然也可以不关心)

What we should do for dealing with the Promise Rejection is using puppet.emit('error', e):

try {
  await oicqClient.dataApi()
} catch (e) {
  puppetOicq.emit('error', e)
}

We should not register any process events in our Puppet implementation code because we should keep all environments to be as clean as possible.

@huan huan added the enhancement New feature or request label Oct 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants