feat(qzone): send_qzone_msg — publish a text 说说 via web API
First Qzone WRITE path. publishQzoneMsg POSTs a form-urlencoded body to taotao.qzone.qq.com's emotion_cgi_publish_v6 (proxied through h5.qzone), g_tk in the query, on the bot's own space. Returns the server-assigned tid (the handle for later delete/comment/like) + post time. - Throws on transport failure, non-zero Qzone code (content rejected / rate-limited), or a success body with no tid — never reports a publish as succeeded without the feed id. Rejects empty content pre-flight. - 带图 (image) publishing is a later slice (needs the upload CGI first). - Action carries a风控/限流 caveat: publishing is an active action and high frequency is rate-limited by Qzone, same as sending messages. - core: QzoneApi.publish; onebot: send_qzone_msg action; regen catalog. - tests: form-body/url/headers lock, empty-content preflight, non-zero code throw, missing-tid throw, and bridge self-space threading.
This commit is contained in:
6 files changed
+204
-2
No files matched your search
@@ -48,4 +48,14 @@ describe('apis/qzone', () => {
|
||||
expect(getCookies).toHaveBeenCalledWith('qzone.qq.com');
|
||||
expect(feedsSpy).toHaveBeenCalledWith({ p_skey: 'PSK' }, '10001', 3, 20);
|
||||
});
|
||||
|
||||
it('publish posts to the bot\'s own space with the given content', async () => {
|
||||
const getCookies = vi.fn(async () => ({ p_skey: 'PSK' }));
|
||||
const bridge = mockBridge({ apis: { ...mockApiHub(), web: { getCookies } } as never });
|
||||
const pubSpy = vi.spyOn(qzoneWeb, 'publishQzoneMsg').mockResolvedValue({ tid: 'T', time: 1 });
|
||||
const out = await new QzoneApi(bridge as never).publish('hello');
|
||||
expect(getCookies).toHaveBeenCalledWith('qzone.qq.com');
|
||||
expect(pubSpy).toHaveBeenCalledWith({ p_skey: 'PSK' }, '10001', 'hello');
|
||||
expect(out).toEqual({ tid: 'T', time: 1 });
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user