mirror of
https://github.com/hansjone/dsh-im-ops.git
synced 2026-10-09 03:03:24 +08:00
Merge pull request #97 from Diluka/feat/qq-parse-face-tags
feat(qq): parse inbound QQ face/emoji tags into readable text
This commit is contained in:
commit
5ac63dd26b
3 changed files with 52 additions and 47 deletions
84
lib/index.js
84
lib/index.js
File diff suppressed because one or more lines are too long
|
|
@ -1,4 +1,4 @@
|
|||
import { QQBot, typingIndicator } from '@tencent-connect/qqbot-nodejs';
|
||||
import { QQBot, contentSanitizer, typingIndicator } from '@tencent-connect/qqbot-nodejs';
|
||||
|
||||
import {
|
||||
connectionTestTarget,
|
||||
|
|
@ -171,6 +171,10 @@ export class QqRuntime {
|
|||
replyTimeoutMs: this.#replyTimeoutMs,
|
||||
signal: controller.signal,
|
||||
});
|
||||
// QQ delivers emoji/face messages as opaque `<faceType=..,faceId="..",ext="..">`
|
||||
// tags. Parse them into readable text so the Harness sees what the sender
|
||||
// actually meant instead of an unusable markup fragment.
|
||||
bot.use(contentSanitizer({ parseFaceTags: true }));
|
||||
bot.use?.(this.#typingMiddleware({
|
||||
keepAlive: true,
|
||||
predicate: (ctx) => this.#config.ownerUserOpenid === '*'
|
||||
|
|
|
|||
|
|
@ -47,10 +47,11 @@ test('QQ runtime waits for gateway ready, installs typing, and stops its client'
|
|||
const status = await runtime.start();
|
||||
assert.equal(status.ready, true);
|
||||
assert.equal(status.qqConnectionState, 'connected');
|
||||
assert.equal(bot.middlewares[0].name, 'typing-middleware');
|
||||
assert.equal(bot.middlewares[0].options.keepAlive, true);
|
||||
assert.equal(bot.middlewares[0].options.predicate({ message: { senderId: 'owner' } }), true);
|
||||
assert.equal(bot.middlewares[0].options.predicate({ message: { senderId: 'other' } }), false);
|
||||
assert.equal(typeof bot.middlewares[0], 'function'); // contentSanitizer (face-tag parsing)
|
||||
assert.equal(bot.middlewares[1].name, 'typing-middleware');
|
||||
assert.equal(bot.middlewares[1].options.keepAlive, true);
|
||||
assert.equal(bot.middlewares[1].options.predicate({ message: { senderId: 'owner' } }), true);
|
||||
assert.equal(bot.middlewares[1].options.predicate({ message: { senderId: 'other' } }), false);
|
||||
assert.equal(botOptions.markdownSupport, false);
|
||||
botOptions.logger.debug('raw gateway payload');
|
||||
botOptions.logger.info('gateway ready');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue