Skip to content

Commit

Permalink
feat(qq): support msg_seq
Browse files Browse the repository at this point in the history
  • Loading branch information
shigma committed Nov 17, 2023
1 parent d8a790d commit 47e7efc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion adapters/qq/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@satorijs/adapter-qq",
"description": "QQ Adapter for Satorijs",
"version": "4.1.6",
"version": "4.1.8",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
"files": [
Expand Down
5 changes: 4 additions & 1 deletion adapters/qq/src/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,18 @@ export class QQMessageEncoder<C extends Context = Context> extends MessageEncode
async flush() {
if (!this.content.trim() && !this.rows.flat().length) return
this.trimButtons()
let msg_id = this.options?.session?.messageId
let msg_id = this.options?.session?.messageId, msg_seq: number
if (this.options?.session && (Date.now() - this.options?.session?.timestamp) > MSG_TIMEOUT) {
msg_id = null
this.options.session['seq'] ||= 0
msg_seq = ++this.options.session['seq']
}
const data: QQ.SendMessageParams = {
content: this.content,
msg_type: 0,
timestamp: Math.floor(Date.now() / 1000),
msg_id,
msg_seq,
}

if (this.useMarkdown) {
Expand Down
1 change: 1 addition & 0 deletions adapters/qq/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1182,6 +1182,7 @@ export interface SendMessageParams {
message_reference?: object
event_id?: string
msg_id?: string
msg_seq?: number
// @TODO merge?
timestamp: number
}
Expand Down

0 comments on commit 47e7efc

Please sign in to comment.