Skip to content

Commit e8644af

Browse files
committed
v1.13.13
### v1.13.13 1. Support for setting file storage path.
1 parent 16c0a51 commit e8644af

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ puppet-xp|wechat|npm install|
102102

103103
## HISTORY
104104

105+
### v1.13.13
106+
107+
1. Support for setting file storage path.
108+
105109
### v1.13.12
106110

107111
1. Fixed the bug where the system crashes upon receiving a message before successful startup

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "wechaty-puppet-xp",
3-
"version": "1.13.12",
3+
"version": "1.13.13",
44
"description": "Puppet XP for Wechaty",
55
"type": "module",
66
"exports": {

src/puppet-xp.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ async function wait (ms:number) {
5757
const userInfo = os.userInfo()
5858
const rootPath = `${userInfo.homedir}\\Documents\\WeChat Files\\`
5959

60-
export type PuppetXpOptions = PUPPET.PuppetOptions
60+
export type PuppetXpOptions = PUPPET.PuppetOptions & {
61+
weChatFilesPath?: string
62+
}
6163

6264
class PuppetXp extends PUPPET.Puppet {
6365

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

7678
private isReady = false
7779

80+
private weChatFilesPath = rootPath
81+
7882
#sidecar?: WeChatSidecar
7983
protected get sidecar (): WeChatSidecar {
8084
return this.#sidecar!
@@ -86,7 +90,9 @@ class PuppetXp extends PUPPET.Puppet {
8690
log.info('options...', JSON.stringify(options))
8791
super(options)
8892
log.verbose('PuppetXp', 'constructor(%s)', JSON.stringify(options))
89-
93+
if (options.weChatFilesPath) {
94+
this.weChatFilesPath = options.weChatFilesPath
95+
}
9096
// FIXME: use LRU cache for message store so that we can reduce memory usage
9197
this.messageStore = {}
9298
this.roomStore = {}
@@ -760,7 +766,7 @@ class PuppetXp extends PUPPET.Puppet {
760766
if (message?.text) {
761767
const picData = JSON.parse(message.text)
762768
const filePath = picData[imageType]
763-
const dataPath = rootPath + filePath // 要解密的文件路径
769+
const dataPath = this.weChatFilesPath + filePath // 要解密的文件路径
764770
// log.info('图片原始文件路径:', dataPath, true)
765771

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

0 commit comments

Comments
 (0)