This repository has been archived by the owner on Jan 10, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 301
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 🎸 增加静态资源获取接口,recvd_api 增加头像url地址
✅ Closes: #198
- Loading branch information
1 parent
e6ea08e
commit b85f7ba
Showing
15 changed files
with
270 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const { downloadFile } = require('../utils/index') | ||
const middleware = require('../middleware') | ||
/** | ||
* 注册login路由和处理上报逻辑 | ||
* @param {Object} param | ||
* @param {import('hono').Hono} param.app | ||
* @param {import('wechaty').Wechaty} param.bot | ||
*/ | ||
module.exports = function registerResourceAgentRoute({ app, bot }) { | ||
app.get( | ||
'/resouces', | ||
middleware.loginCheck, | ||
/** @param {import('hono').Context} c */ | ||
async (c) => { | ||
// 暂时不考虑其他puppet的情况 | ||
const cookie = | ||
// @ts-ignore 私有变量 | ||
bot.__puppet._memory.payload['\rpuppet\nPUPPET-WECHAT4U'].COOKIE | ||
const mediaUrl = c.req.query('media') | ||
const fullResouceUrl = `https://wx2.qq.com${decodeURIComponent( | ||
mediaUrl || '' | ||
)}` | ||
|
||
const { buffer, contentType } = await downloadFile(fullResouceUrl, { | ||
Cookie: Object.entries(cookie).reduce( | ||
(pre, next) => (pre += `${next[0]}=${next[1]};`), | ||
'' | ||
) | ||
}) | ||
if (buffer) { | ||
contentType && c.header('Content-Type', contentType) | ||
return c.body(buffer) | ||
} else { | ||
c.status(404) | ||
return c.json({ success: false, message: '获取资源失败' }) | ||
} | ||
} | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.