Skip to content

Commit

Permalink
v1.13.13
Browse files Browse the repository at this point in the history
### v1.13.13

1. Support for setting file storage path.
  • Loading branch information
atorber committed Apr 10, 2024
1 parent 16c0a51 commit e8644af
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ puppet-xp|wechat|npm install|

## HISTORY

### v1.13.13

1. Support for setting file storage path.

### v1.13.12

1. Fixed the bug where the system crashes upon receiving a message before successful startup
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wechaty-puppet-xp",
"version": "1.13.12",
"version": "1.13.13",
"description": "Puppet XP for Wechaty",
"type": "module",
"exports": {
Expand Down
14 changes: 10 additions & 4 deletions src/puppet-xp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ async function wait (ms:number) {
const userInfo = os.userInfo()
const rootPath = `${userInfo.homedir}\\Documents\\WeChat Files\\`

export type PuppetXpOptions = PUPPET.PuppetOptions
export type PuppetXpOptions = PUPPET.PuppetOptions & {
weChatFilesPath?: string
}

class PuppetXp extends PUPPET.Puppet {

Expand All @@ -75,6 +77,8 @@ class PuppetXp extends PUPPET.Puppet {

private isReady = false

private weChatFilesPath = rootPath

#sidecar?: WeChatSidecar
protected get sidecar (): WeChatSidecar {
return this.#sidecar!
Expand All @@ -86,7 +90,9 @@ class PuppetXp extends PUPPET.Puppet {
log.info('options...', JSON.stringify(options))
super(options)
log.verbose('PuppetXp', 'constructor(%s)', JSON.stringify(options))

if (options.weChatFilesPath) {
this.weChatFilesPath = options.weChatFilesPath
}
// FIXME: use LRU cache for message store so that we can reduce memory usage
this.messageStore = {}
this.roomStore = {}
Expand Down Expand Up @@ -760,7 +766,7 @@ class PuppetXp extends PUPPET.Puppet {
if (message?.text) {
const picData = JSON.parse(message.text)
const filePath = picData[imageType]
const dataPath = rootPath + filePath // 要解密的文件路径
const dataPath = this.weChatFilesPath + filePath // 要解密的文件路径
// log.info('图片原始文件路径:', dataPath, true)

// 检测图片原始文件是否存在,如果存在则继续,如果不存在则每隔0.5秒后检测一次,直到10s后还不存在则继续
Expand Down Expand Up @@ -838,7 +844,7 @@ class PuppetXp extends PUPPET.Puppet {
}
fileName = '\\' + messageJson.msg.appmsg[0].title[0]
const filePath = `${this.selfInfo.id}\\FileStorage\\File\\${year}-${month}`
dataPath = rootPath + filePath + fileName // 要解密的文件路径
dataPath = this.weChatFilesPath + filePath + fileName // 要解密的文件路径
// log.info(dataPath)
return FileBox.fromFile(
dataPath,
Expand Down

0 comments on commit e8644af

Please sign in to comment.