@whyour/qinglong 0.11.3 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README-en.md +65 -58
- package/README.md +62 -55
- package/package.json +2 -2
- package/sample/config.sample.sh +9 -0
- package/sample/notify.js +260 -0
- package/sample/notify.py +177 -3
- package/shell/otask.sh +8 -6
- package/shell/share.sh +20 -11
- package/shell/task.sh +22 -9
- package/static/build/api/cron.js +1 -2
- package/static/build/api/log.js +1 -1
- package/static/build/api/script.js +4 -3
- package/static/build/config/serverEnv.js +8 -0
- package/static/build/config/util.js +13 -7
- package/static/build/data/notify.js +11 -1
- package/static/build/loaders/server.js +0 -4
- package/static/build/protos/cron.js +14 -2
- package/static/build/schedule/addCron.js +5 -5
- package/static/build/services/cron.js +21 -14
- package/static/build/services/dependence.js +1 -1
- package/static/build/services/notify.js +57 -5
- package/static/build/services/schedule.js +23 -11
- package/static/build/services/script.js +1 -1
- package/static/build/services/subscription.js +5 -1
- package/static/build/services/system.js +3 -1
- package/static/build/shared/pLimit.js +38 -18
- package/static/build/shared/runCron.js +5 -6
- package/static/dist/{7878.91f5096f.async.js → 1988.5291d10f.async.js} +1 -1
- package/static/dist/2260.6c4d0bd0.async.js +1 -0
- package/static/dist/2393.c35a1174.async.js +1 -0
- package/static/dist/{2618.d4ab1f05.async.js → 2618.7a71aedf.async.js} +1 -1
- package/static/dist/{2715.f6d4a9ed.async.js → 2715.292538bc.async.js} +1 -1
- package/static/dist/{29.dd4d8489.async.js → 29.32a92099.async.js} +1 -1
- package/static/dist/3435.2670d41f.async.js +1 -0
- package/static/dist/380.33bc8989.async.js +1 -0
- package/static/dist/3800.f0507af4.async.js +1 -0
- package/static/dist/{4124.27cef0bd.async.js → 4124.b86154ed.async.js} +1 -1
- package/static/dist/4163.1781a549.async.js +1 -0
- package/static/dist/419.e21ea0bd.async.js +1 -0
- package/static/dist/4378.59be202f.async.js +1 -0
- package/static/dist/4424.a840b858.async.js +1 -0
- package/static/dist/4674.1b3db685.async.js +1 -0
- package/static/dist/{4925.9e8a41a2.async.js → 4925.9b770864.async.js} +1 -1
- package/static/dist/5310.4cd7a0c1.async.js +1 -0
- package/static/dist/{5484.8b81227f.async.js → 5484.68655765.async.js} +1 -1
- package/static/dist/5619.db04f386.async.js +1 -0
- package/static/dist/5830.9be47cbb.async.js +1 -0
- package/static/dist/6644.1f11b8fa.async.js +1 -0
- package/static/dist/694.0baa21db.async.js +1 -0
- package/static/dist/6986.6a4ae181.async.js +1 -0
- package/static/dist/{7382.26e7f5a4.async.js → 7346.7096e3b3.async.js} +1 -1
- package/static/dist/{7362.9fde9d80.async.js → 7362.e740709d.async.js} +1 -1
- package/static/dist/7393.341d9643.async.js +1 -0
- package/static/dist/{7708.dc75b315.async.js → 7708.27674f3a.async.js} +1 -1
- package/static/dist/7742.51617038.async.js +1 -0
- package/static/dist/7787.2fcf966f.async.js +1 -0
- package/static/dist/8008.cf4ff203.async.js +1 -0
- package/static/dist/8171.e2986b87.async.js +1 -0
- package/static/dist/8297.0c80e09a.async.js +1 -0
- package/static/dist/833.5add31bf.async.js +1 -0
- package/static/dist/{8432.055570e6.async.js → 8432.d8d0ade6.async.js} +1 -1
- package/static/dist/858.1a385b25.async.js +1 -0
- package/static/dist/8934.55adca8f.async.js +1 -0
- package/static/dist/{9065.8be8d60f.async.js → 9065.a1341834.async.js} +1 -1
- package/static/dist/9206.25353766.async.js +1 -0
- package/static/dist/{9504.248f6493.async.js → 9504.22415050.async.js} +1 -1
- package/static/dist/9525.b2007159.async.js +1 -0
- package/static/dist/9673.ac17e45d.async.js +1 -0
- package/static/dist/index.html +1 -1
- package/static/dist/layouts__index.308c5e5e.chunk.css +1 -0
- package/static/dist/layouts__index.931ce4c3.async.js +1 -0
- package/static/dist/{src__pages__404.e6b13931.async.js → src__pages__404.e1ca45fd.async.js} +1 -1
- package/static/dist/src__pages__config__index.9d83dfb7.async.js +1 -0
- package/static/dist/src__pages__crontab__detail.b91d6518.async.js +1 -0
- package/static/dist/src__pages__crontab__index.04176975.async.js +1 -0
- package/static/dist/src__pages__crontab__index.b622c4d6.chunk.css +1 -0
- package/static/dist/src__pages__crontab__logModal.91357c7c.async.js +1 -0
- package/static/dist/src__pages__crontab__modal.3fa8f075.async.js +1 -0
- package/static/dist/{src__pages__crontab__viewCreateModal.c46df55e.async.js → src__pages__crontab__viewCreateModal.a29322e7.async.js} +1 -1
- package/static/dist/{src__pages__crontab__viewManageModal.67aa809d.async.js → src__pages__crontab__viewManageModal.c026d403.async.js} +1 -1
- package/static/dist/{src__pages__dependence__index.1908bb39.async.js → src__pages__dependence__index.21153c24.async.js} +1 -1
- package/static/dist/src__pages__dependence__logModal.5aada63c.async.js +1 -0
- package/static/dist/src__pages__dependence__modal.96353c88.async.js +1 -0
- package/static/dist/src__pages__diff__index.e644b15f.async.js +1 -0
- package/static/dist/src__pages__env__editNameModal.25c21e59.async.js +1 -0
- package/static/dist/src__pages__env__index.f545d035.async.js +1 -0
- package/static/dist/src__pages__env__modal.4fd6abc2.async.js +1 -0
- package/static/dist/src__pages__error__index.f3ca5563.async.js +1 -0
- package/static/dist/src__pages__initialization__index.727e0f70.async.js +1 -0
- package/static/dist/{src__pages__log__index.4010410c.async.js → src__pages__log__index.ba2c1721.async.js} +1 -1
- package/static/dist/src__pages__login__index.e4257741.async.js +1 -0
- package/static/dist/src__pages__script__editModal.8d7bac2a.async.js +1 -0
- package/static/dist/src__pages__script__editNameModal.ca76e055.async.js +1 -0
- package/static/dist/src__pages__script__index.da31e2c2.async.js +1 -0
- package/static/dist/src__pages__script__renameModal.c166915b.async.js +1 -0
- package/static/dist/src__pages__script__saveModal.7ee07566.async.js +1 -0
- package/static/dist/src__pages__script__setting.020a7629.async.js +1 -0
- package/static/dist/src__pages__setting__about.40dce429.async.js +1 -0
- package/static/dist/src__pages__setting__appModal.efa5bb29.async.js +1 -0
- package/static/dist/src__pages__setting__checkUpdate.42020a45.async.js +1 -0
- package/static/dist/src__pages__setting__index.540c33a4.async.js +1 -0
- package/static/dist/src__pages__setting__loginLog.fe7238b5.async.js +1 -0
- package/static/dist/src__pages__setting__notification.b99a4c64.async.js +1 -0
- package/static/dist/src__pages__setting__other.d20be1c1.async.js +1 -0
- package/static/dist/src__pages__setting__progress.65e2e878.async.js +1 -0
- package/static/dist/src__pages__setting__security.d14993c7.async.js +1 -0
- package/static/dist/src__pages__setting__systemLog.751cc94d.async.js +1 -0
- package/static/dist/src__pages__subscription__index.0f0a7c0a.async.js +1 -0
- package/static/dist/src__pages__subscription__logModal.fce8a9b4.async.js +1 -0
- package/static/dist/src__pages__subscription__modal.61e787ce.async.js +1 -0
- package/static/dist/umi.0397b91d.js +1 -0
- package/version.yaml +17 -10
- package/static/dist/1124.0d983222.async.js +0 -1
- package/static/dist/2260.6b2b0020.async.js +0 -1
- package/static/dist/2393.4404a4fc.async.js +0 -1
- package/static/dist/2536.282cde37.async.js +0 -1
- package/static/dist/3271.e5502cf4.async.js +0 -1
- package/static/dist/3435.4a54080b.async.js +0 -1
- package/static/dist/380.1bd1f124.async.js +0 -1
- package/static/dist/3800.fca63cfc.async.js +0 -1
- package/static/dist/4163.2fc47c9d.async.js +0 -1
- package/static/dist/419.f84c4548.async.js +0 -1
- package/static/dist/4424.73f63db5.async.js +0 -1
- package/static/dist/4674.0196afcf.async.js +0 -1
- package/static/dist/5310.213fe20f.async.js +0 -1
- package/static/dist/6433.d9698b6c.async.js +0 -1
- package/static/dist/6644.fe01612c.async.js +0 -1
- package/static/dist/6805.5446eb5a.async.js +0 -1
- package/static/dist/6986.57a091e1.async.js +0 -1
- package/static/dist/7393.1f1df786.async.js +0 -1
- package/static/dist/7742.863081f5.async.js +0 -1
- package/static/dist/8008.882bf214.async.js +0 -1
- package/static/dist/8037.dd53e9c8.async.js +0 -1
- package/static/dist/8297.c44afb18.async.js +0 -1
- package/static/dist/833.ca85f497.async.js +0 -1
- package/static/dist/858.1899883e.async.js +0 -1
- package/static/dist/9673.5576fcd4.async.js +0 -1
- package/static/dist/9692.e04f774e.async.js +0 -1
- package/static/dist/layouts__index.0909c66d.chunk.css +0 -1
- package/static/dist/layouts__index.ed595716.async.js +0 -1
- package/static/dist/src__pages__config__index.f41a22d4.async.js +0 -1
- package/static/dist/src__pages__crontab__detail.b4fc2995.async.js +0 -1
- package/static/dist/src__pages__crontab__index.6c7b7b2c.chunk.css +0 -1
- package/static/dist/src__pages__crontab__index.776dba58.async.js +0 -1
- package/static/dist/src__pages__crontab__logModal.0fb6d62d.async.js +0 -1
- package/static/dist/src__pages__crontab__modal.0b01490c.async.js +0 -1
- package/static/dist/src__pages__dependence__logModal.8ecc9316.async.js +0 -1
- package/static/dist/src__pages__dependence__modal.9c12e6bb.async.js +0 -1
- package/static/dist/src__pages__diff__index.e23d088b.async.js +0 -1
- package/static/dist/src__pages__env__editNameModal.6f1edde6.async.js +0 -1
- package/static/dist/src__pages__env__index.3b08292e.async.js +0 -1
- package/static/dist/src__pages__env__modal.ca6133e6.async.js +0 -1
- package/static/dist/src__pages__error__index.0b4f4a22.async.js +0 -1
- package/static/dist/src__pages__initialization__index.51ebefcb.async.js +0 -1
- package/static/dist/src__pages__login__index.8667d8d2.async.js +0 -1
- package/static/dist/src__pages__script__editModal.b020a209.async.js +0 -1
- package/static/dist/src__pages__script__editNameModal.9220eb1a.async.js +0 -1
- package/static/dist/src__pages__script__index.6184a17e.async.js +0 -1
- package/static/dist/src__pages__script__renameModal.d6192fed.async.js +0 -1
- package/static/dist/src__pages__script__saveModal.eac5e9e7.async.js +0 -1
- package/static/dist/src__pages__script__setting.b958297b.async.js +0 -1
- package/static/dist/src__pages__setting__about.992010a5.async.js +0 -1
- package/static/dist/src__pages__setting__appModal.7563e7b0.async.js +0 -1
- package/static/dist/src__pages__setting__checkUpdate.9901a906.async.js +0 -1
- package/static/dist/src__pages__setting__index.2aa66013.async.js +0 -1
- package/static/dist/src__pages__setting__loginLog.2f2b0a78.async.js +0 -1
- package/static/dist/src__pages__setting__notification.e8ce9bdc.async.js +0 -1
- package/static/dist/src__pages__setting__other.c6067975.async.js +0 -1
- package/static/dist/src__pages__setting__progress.f58bffae.async.js +0 -1
- package/static/dist/src__pages__setting__security.cae5c68d.async.js +0 -1
- package/static/dist/src__pages__subscription__index.3266194c.async.js +0 -1
- package/static/dist/src__pages__subscription__logModal.a023b07e.async.js +0 -1
- package/static/dist/src__pages__subscription__modal.49a1a657.async.js +0 -1
- package/static/dist/umi.ff82d609.js +0 -1
package/README-en.md
CHANGED
|
@@ -36,6 +36,7 @@ Timed task management platform supporting Python3, JavaScript, Shell, Typescript
|
|
|
36
36
|
- Support cell phone operation
|
|
37
37
|
|
|
38
38
|
## Version
|
|
39
|
+
|
|
39
40
|
### docker
|
|
40
41
|
|
|
41
42
|
The `latest` image is built on `alpine` and the `debian` image is built on `debian-slim`. If you need to use a dependency that is not supported by `alpine`, it is recommended that you use the `debian` image.
|
|
@@ -53,6 +54,66 @@ The npm version supports `debian/ubuntu/centos/alpine` systems and requires `nod
|
|
|
53
54
|
npm i @whyour/qinglong
|
|
54
55
|
```
|
|
55
56
|
|
|
57
|
+
## Built-in commands
|
|
58
|
+
|
|
59
|
+
1. task
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
# Execute in sequence, if a random delay is set, it will be randomly delayed by a certain number of seconds
|
|
63
|
+
task <file_path>
|
|
64
|
+
# Execute in sequence, regardless of whether a random delay is set, all run immediately,
|
|
65
|
+
# and the foreground will output the day, while recorded in the log file
|
|
66
|
+
task <file_path> now
|
|
67
|
+
# Concurrent execution, regardless of whether a random delay is set, are run immediately,
|
|
68
|
+
# the foreground does not generate the day, directly recorded in the log file, and can be specified account execution
|
|
69
|
+
task <file_path> conc <env_name> <account_number>(Optional)
|
|
70
|
+
# Specify the account to execute and run immediately regardless of whether a random delay is set
|
|
71
|
+
task <file_path> desi <env_name> <account_number>
|
|
72
|
+
# Set task timeout
|
|
73
|
+
task -m <max_time> <file_path>
|
|
74
|
+
# Print task log in real time, no need to carry this parameter when creating timed tasks
|
|
75
|
+
task -l <file_path>
|
|
76
|
+
# Use -- to split, -- followed by a parameter that is passed to the script, as in the following example, the script receives the parameter -u whyour -p password
|
|
77
|
+
task <file_path> -- -u whyour -p password
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
1. ql
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
# Update and restart Green Dragon
|
|
84
|
+
ql update
|
|
85
|
+
# Run custom scripts extra.sh
|
|
86
|
+
ql extra
|
|
87
|
+
# Adding a single script file
|
|
88
|
+
ql raw <file_url>
|
|
89
|
+
# Add a specific script for a single repository
|
|
90
|
+
ql repo <repo_url> <whitelist> <blacklist> <dependence> <branch>
|
|
91
|
+
# Delete old logs
|
|
92
|
+
ql rmlog <days>
|
|
93
|
+
# Start bot
|
|
94
|
+
ql bot
|
|
95
|
+
# Detecting the Green Dragon environment and repairing it
|
|
96
|
+
ql check
|
|
97
|
+
# Reset the number of login errors
|
|
98
|
+
ql resetlet
|
|
99
|
+
# Disable two-step login
|
|
100
|
+
ql resettfa
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
1. parameter description
|
|
104
|
+
|
|
105
|
+
- file_url: Script address
|
|
106
|
+
- repo_url: Repository address
|
|
107
|
+
- whitelist: The whitelist when pulling the repository, i.e., the string contained in the path of the script to be pulled
|
|
108
|
+
- blacklist: Blacklisting when pulling repositories, i.e. strings that are not included in the path of the script to be pulled
|
|
109
|
+
- dependence: Pulling the dependencies needed for the repository will be copied directly from the repository to the repository directory under scripts, regardless of the blacklist
|
|
110
|
+
- branch: Pull the branch of the repository
|
|
111
|
+
- days: Number of days of logs to be kept
|
|
112
|
+
- file_path: File path for task execution
|
|
113
|
+
- env_name: The name of the environment variable that needs to be concurrent or specified at the time of task execution
|
|
114
|
+
- account_number: Specify the account number of an environment variable to be executed when the task is executed
|
|
115
|
+
- max_time: Timeout, suffix "s" for seconds (default), "m" for minutes, "h" for hours, "d" for days
|
|
116
|
+
|
|
56
117
|
## Deployment
|
|
57
118
|
|
|
58
119
|
### Docker (Recommended)
|
|
@@ -63,7 +124,7 @@ docker run -dit \
|
|
|
63
124
|
-v $PWD/ql/data:/ql/data \
|
|
64
125
|
# The 5700 after the colon is the default port, if QlPort is set, it needs to be the same as QlPort.
|
|
65
126
|
-p 5700:5700 \
|
|
66
|
-
# Deployment paths are not required
|
|
127
|
+
# Deployment paths are not required, e.g. /test.
|
|
67
128
|
-e QlBaseUrl="/" \
|
|
68
129
|
# Deployment port is not required, when using host mode, you can set the port after service startup, default 5700
|
|
69
130
|
-e QlPort="5700" \
|
|
@@ -95,7 +156,7 @@ podman run -dit \
|
|
|
95
156
|
-v $PWD/ql/data:/ql/data \
|
|
96
157
|
# The 5700 after the colon is the default port, if QlPort is set, it needs to be the same as QlPort.
|
|
97
158
|
-p 5700:5700 \
|
|
98
|
-
# Deployment paths are not required
|
|
159
|
+
# Deployment paths are not required, e.g. /test.
|
|
99
160
|
-e QlBaseUrl="/" \
|
|
100
161
|
# Deployment port is not required, when using host mode, you can set the port after service startup, default 5700
|
|
101
162
|
-e QlPort="5700" \
|
|
@@ -118,60 +179,6 @@ export QL_DATA_DIR=""
|
|
|
118
179
|
qinglong
|
|
119
180
|
```
|
|
120
181
|
|
|
121
|
-
## Use
|
|
122
|
-
|
|
123
|
-
1. built-in commands
|
|
124
|
-
|
|
125
|
-
```bash
|
|
126
|
-
# Update and restart Green Dragon
|
|
127
|
-
ql update
|
|
128
|
-
# Run custom scripts extra.sh
|
|
129
|
-
ql extra
|
|
130
|
-
# Adding a single script file
|
|
131
|
-
ql raw <file_url>
|
|
132
|
-
# Add a specific script for a single repository
|
|
133
|
-
ql repo <repo_url> <whitelist> <blacklist> <dependence> <branch>
|
|
134
|
-
# Delete old logs
|
|
135
|
-
ql rmlog <days>
|
|
136
|
-
# Start bot
|
|
137
|
-
ql bot
|
|
138
|
-
# Detecting the Green Dragon environment and repairing it
|
|
139
|
-
ql check
|
|
140
|
-
# Reset the number of login errors
|
|
141
|
-
ql resetlet
|
|
142
|
-
# Disable two-step login
|
|
143
|
-
ql resettfa
|
|
144
|
-
|
|
145
|
-
# Execute in sequence, if a random delay is set, it will be randomly delayed by a certain number of seconds
|
|
146
|
-
task <file_path>
|
|
147
|
-
# Execute in sequence, regardless of whether a random delay is set, all run immediately,
|
|
148
|
-
# and the foreground will output the day, while recorded in the log file
|
|
149
|
-
task <file_path> now
|
|
150
|
-
# Concurrent execution, regardless of whether a random delay is set, are run immediately,
|
|
151
|
-
# the foreground does not generate the day, directly recorded in the log file, and can be specified account execution
|
|
152
|
-
task <file_path> conc <env_name> <account_number>(Optional)
|
|
153
|
-
# Specify the account to execute and run immediately regardless of whether a random delay is set
|
|
154
|
-
task <file_path> desi <env_name> <account_number>
|
|
155
|
-
# Set task timeout
|
|
156
|
-
task -m <max_time> <file_path>
|
|
157
|
-
# Print task log in real time, no need to carry this parameter when creating timed tasks
|
|
158
|
-
task -l <file_path>
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
2. parameter description
|
|
162
|
-
|
|
163
|
-
* file_url: Script address
|
|
164
|
-
* repo_url: Repository address
|
|
165
|
-
* whitelist: The whitelist when pulling the repository, i.e., the string contained in the path of the script to be pulled
|
|
166
|
-
* blacklist: Blacklisting when pulling repositories, i.e. strings that are not included in the path of the script to be pulled
|
|
167
|
-
* dependence: Pulling the dependencies needed for the repository will be copied directly from the repository to the repository directory under scripts, regardless of the blacklist
|
|
168
|
-
* branch: Pull the branch of the repository
|
|
169
|
-
* days: Number of days of logs to be kept
|
|
170
|
-
* file_path: File path for task execution
|
|
171
|
-
* env_name: The name of the environment variable that needs to be concurrent or specified at the time of task execution
|
|
172
|
-
* account_number: Specify the account number of an environment variable to be executed when the task is executed
|
|
173
|
-
* max_time: Timeout, suffix "s" for seconds (default), "m" for minutes, "h" for hours, "d" for days
|
|
174
|
-
|
|
175
182
|
## Development
|
|
176
183
|
|
|
177
184
|
```bash
|
|
@@ -184,7 +191,7 @@ $ pnpm install
|
|
|
184
191
|
$ pnpm start
|
|
185
192
|
```
|
|
186
193
|
|
|
187
|
-
Open your browser and visit http://127.0.0.1:5700
|
|
194
|
+
Open your browser and visit <http://127.0.0.1:5700>
|
|
188
195
|
|
|
189
196
|
## Links
|
|
190
197
|
|
|
@@ -202,4 +209,4 @@ The Green Dragon, also known as the Canglong, is one of the four elephants and o
|
|
|
202
209
|
|
|
203
210
|
In the Book of the Later Han Dynasty (後漢書-律曆志下), it is written: "The sun is in the sky, a cold and a summer, the four seasons are ready, all things are changed, the regency moves, and the green dragon moves to the star, which is called the year. (The Year of the Star)
|
|
204
211
|
|
|
205
|
-
Among the [twenty-eight Chinese constellations](https://zh.wikipedia.org/wiki/%E4%BA%8C%E5%8D%81%E5%85%AB%E5%AE%BF), the Green Dragon is the generic name for the seven eastern constellations (Horn, Hyper, Diao, Fang, Heart, Tail and Minchi). It is known in Taoism as "Mengzhang" and in different Taoist scriptures as "Dijun", "Shengjian", "Shenjian" and He is also known in different Daoist scriptures as "Dijun", "Shengjun", "Shenjun" and "Ghost Catcher"[1], and is the guardian deity of Daoism, together with the White Tiger Supervisor of Soldiers.
|
|
212
|
+
Among the [twenty-eight Chinese constellations](https://zh.wikipedia.org/wiki/%E4%BA%8C%E5%8D%81%E5%85%AB%E5%AE%BF), the Green Dragon is the generic name for the seven eastern constellations (Horn, Hyper, Diao, Fang, Heart, Tail and Minchi). It is known in Taoism as "Mengzhang" and in different Taoist scriptures as "Dijun", "Shengjian", "Shenjian" and He is also known in different Daoist scriptures as "Dijun", "Shengjun", "Shenjun" and "Ghost Catcher"[1], and is the guardian deity of Daoism, together with the White Tiger Supervisor of Soldiers.
|
package/README.md
CHANGED
|
@@ -38,6 +38,7 @@ Timed task management platform supporting Python3, JavaScript, Shell, Typescript
|
|
|
38
38
|
- 支持手机端操作
|
|
39
39
|
|
|
40
40
|
## 版本
|
|
41
|
+
|
|
41
42
|
### docker
|
|
42
43
|
|
|
43
44
|
`latest` 镜像是基于 `alpine` 构建,`debian` 镜像是基于 `debian-slim` 构建。如果需要使用 `alpine` 不支持的依赖,建议使用 `debian` 镜像
|
|
@@ -55,6 +56,65 @@ npm 版本支持 `debian/ubuntu/centos/alpine` 系统,需要自行安装 `node
|
|
|
55
56
|
npm i @whyour/qinglong
|
|
56
57
|
```
|
|
57
58
|
|
|
59
|
+
## 内置命令
|
|
60
|
+
|
|
61
|
+
1. task
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
# 依次执行,如果设置了随机延迟,将随机延迟一定秒数
|
|
65
|
+
task <file_path>
|
|
66
|
+
# 依次执行,无论是否设置了随机延迟,均立即运行,前台会输出日,同时记录在日志文件中
|
|
67
|
+
task <file_path> now
|
|
68
|
+
# 并发执行,无论是否设置了随机延迟,均立即运行,前台不产生日,直接记录在日志文件中,且可指定账号执行
|
|
69
|
+
task <file_path> conc <env_name> <account_number>(可选的)
|
|
70
|
+
# 指定账号执行,无论是否设置了随机延迟,均立即运行
|
|
71
|
+
task <file_path> desi <env_name> <account_number>
|
|
72
|
+
# 设置任务超时时间
|
|
73
|
+
task -m <max_time> <file_path>
|
|
74
|
+
# 实时打印任务日志,创建定时任务时,不用携带此参数
|
|
75
|
+
task -l <file_path>
|
|
76
|
+
# 使用 -- 分割,-- 后面的参数会传给脚本,下面的例子,脚本就可接收到参数 -u whyour -p password
|
|
77
|
+
task <file_path> -- -u whyour -p password
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
1. ql
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
# 更新并重启青龙
|
|
84
|
+
ql update
|
|
85
|
+
# 运行自定义脚本extra.sh
|
|
86
|
+
ql extra
|
|
87
|
+
# 添加单个脚本文件
|
|
88
|
+
ql raw <file_url>
|
|
89
|
+
# 添加单个仓库的指定脚本
|
|
90
|
+
ql repo <repo_url> <whitelist> <blacklist> <dependence> <branch> <extensions>
|
|
91
|
+
# 删除旧日志
|
|
92
|
+
ql rmlog <days>
|
|
93
|
+
# 启动tg-bot
|
|
94
|
+
ql bot
|
|
95
|
+
# 检测青龙环境并修复
|
|
96
|
+
ql check
|
|
97
|
+
# 重置登录错误次数
|
|
98
|
+
ql resetlet
|
|
99
|
+
# 禁用两步登录
|
|
100
|
+
ql resettfa
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
1. 参数说明
|
|
104
|
+
|
|
105
|
+
- file_url: 脚本地址
|
|
106
|
+
- repo_url: 仓库地址
|
|
107
|
+
- whitelist: 拉取仓库时的白名单,即就是需要拉取的脚本的路径包含的字符串,多个竖线分割
|
|
108
|
+
- blacklist: 拉取仓库时的黑名单,即就是需要拉取的脚本的路径不包含的字符串,多个竖线分割
|
|
109
|
+
- dependence: 拉取仓库需要的依赖文件,会直接从仓库拷贝到scripts下的仓库目录,不受黑名单影响,多个竖线分割
|
|
110
|
+
- extensions: 拉取仓库的文件后缀,多个竖线分割
|
|
111
|
+
- branch: 拉取仓库的分支
|
|
112
|
+
- days: 需要保留的日志的天数
|
|
113
|
+
- file_path: 任务执行时的文件路径
|
|
114
|
+
- env_name: 任务执行时需要并发或者指定时的环境变量名称
|
|
115
|
+
- account_number: 任务执行时指定某个环境变量需要执行的账号序号
|
|
116
|
+
- max_time: 超时时间,后缀"s"代表秒(默认值), "m"代表分, "h"代表小时, "d"代表天
|
|
117
|
+
|
|
58
118
|
## 部署
|
|
59
119
|
|
|
60
120
|
### docker (推荐)
|
|
@@ -65,7 +125,7 @@ docker run -dit \
|
|
|
65
125
|
-v $PWD/ql/data:/ql/data \
|
|
66
126
|
# 冒号后面的 5700 为默认端口,如果设置了 QlPort, 需要跟 QlPort 保持一致
|
|
67
127
|
-p 5700:5700 \
|
|
68
|
-
#
|
|
128
|
+
# 部署路径非必须,比如 /test
|
|
69
129
|
-e QlBaseUrl="/" \
|
|
70
130
|
# 部署端口非必须,当使用 host 模式时,可以设置服务启动后的端口,默认 5700
|
|
71
131
|
-e QlPort="5700" \
|
|
@@ -97,7 +157,7 @@ podman run -dit \
|
|
|
97
157
|
-v $PWD/ql/data:/ql/data \
|
|
98
158
|
# 冒号后面的 5700 为默认端口,如果设置了 QlPort, 需要跟 QlPort 保持一致
|
|
99
159
|
-p 5700:5700 \
|
|
100
|
-
#
|
|
160
|
+
# 部署路径非必须,比如 /test
|
|
101
161
|
-e QlBaseUrl="/" \
|
|
102
162
|
# 部署端口非必须,当使用 host 模式时,可以设置服务启动后的端口,默认 5700
|
|
103
163
|
-e QlPort="5700" \
|
|
@@ -120,59 +180,6 @@ export QL_DATA_DIR=""
|
|
|
120
180
|
qinglong
|
|
121
181
|
```
|
|
122
182
|
|
|
123
|
-
## 使用
|
|
124
|
-
|
|
125
|
-
1. 内置命令
|
|
126
|
-
|
|
127
|
-
```bash
|
|
128
|
-
# 更新并重启青龙
|
|
129
|
-
ql update
|
|
130
|
-
# 运行自定义脚本extra.sh
|
|
131
|
-
ql extra
|
|
132
|
-
# 添加单个脚本文件
|
|
133
|
-
ql raw <file_url>
|
|
134
|
-
# 添加单个仓库的指定脚本
|
|
135
|
-
ql repo <repo_url> <whitelist> <blacklist> <dependence> <branch> <extensions>
|
|
136
|
-
# 删除旧日志
|
|
137
|
-
ql rmlog <days>
|
|
138
|
-
# 启动tg-bot
|
|
139
|
-
ql bot
|
|
140
|
-
# 检测青龙环境并修复
|
|
141
|
-
ql check
|
|
142
|
-
# 重置登录错误次数
|
|
143
|
-
ql resetlet
|
|
144
|
-
# 禁用两步登录
|
|
145
|
-
ql resettfa
|
|
146
|
-
|
|
147
|
-
# 依次执行,如果设置了随机延迟,将随机延迟一定秒数
|
|
148
|
-
task <file_path>
|
|
149
|
-
# 依次执行,无论是否设置了随机延迟,均立即运行,前台会输出日,同时记录在日志文件中
|
|
150
|
-
task <file_path> now
|
|
151
|
-
# 并发执行,无论是否设置了随机延迟,均立即运行,前台不产生日,直接记录在日志文件中,且可指定账号执行
|
|
152
|
-
task <file_path> conc <env_name> <account_number>(可选的)
|
|
153
|
-
# 指定账号执行,无论是否设置了随机延迟,均立即运行
|
|
154
|
-
task <file_path> desi <env_name> <account_number>
|
|
155
|
-
# 设置任务超时时间
|
|
156
|
-
task -m <max_time> <file_path>
|
|
157
|
-
# 实时打印任务日志,创建定时任务时,不用携带此参数
|
|
158
|
-
task -l <file_path>
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
2. 参数说明
|
|
162
|
-
|
|
163
|
-
* file_url: 脚本地址
|
|
164
|
-
* repo_url: 仓库地址
|
|
165
|
-
* whitelist: 拉取仓库时的白名单,即就是需要拉取的脚本的路径包含的字符串,多个竖线分割
|
|
166
|
-
* blacklist: 拉取仓库时的黑名单,即就是需要拉取的脚本的路径不包含的字符串,多个竖线分割
|
|
167
|
-
* dependence: 拉取仓库需要的依赖文件,会直接从仓库拷贝到scripts下的仓库目录,不受黑名单影响,多个竖线分割
|
|
168
|
-
* extensions: 拉取仓库的文件后缀,多个竖线分割
|
|
169
|
-
* branch: 拉取仓库的分支
|
|
170
|
-
* days: 需要保留的日志的天数
|
|
171
|
-
* file_path: 任务执行时的文件路径
|
|
172
|
-
* env_name: 任务执行时需要并发或者指定时的环境变量名称
|
|
173
|
-
* account_number: 任务执行时指定某个环境变量需要执行的账号序号
|
|
174
|
-
* max_time: 超时时间,后缀"s"代表秒(默认值), "m"代表分, "h"代表小时, "d"代表天
|
|
175
|
-
|
|
176
183
|
## 开发
|
|
177
184
|
|
|
178
185
|
```bash
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@whyour/qinglong",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.1",
|
|
4
4
|
"description": "Timed task management platform supporting Python3, JavaScript, Shell, Typescript",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -99,7 +99,7 @@
|
|
|
99
99
|
"nedb": "^1.8.0",
|
|
100
100
|
"node-schedule": "^2.1.0",
|
|
101
101
|
"nodemailer": "^6.7.2",
|
|
102
|
-
"p-
|
|
102
|
+
"p-queue-cjs": "7.3.4",
|
|
103
103
|
"protobufjs": "^7.2.3",
|
|
104
104
|
"pstree.remy": "^1.1.8",
|
|
105
105
|
"reflect-metadata": "^0.1.13",
|
package/sample/config.sample.sh
CHANGED
|
@@ -173,4 +173,13 @@ export SMTP_NAME=""
|
|
|
173
173
|
## PUSHME_KEY (必填)填写PushMe APP上获取的push_key
|
|
174
174
|
export PUSHME_KEY=""
|
|
175
175
|
|
|
176
|
+
## 13. CHRONOCAT
|
|
177
|
+
## CHRONOCAT_URL 推送 http://127.0.0.1:16530
|
|
178
|
+
## CHRONOCAT_TOKEN 填写在CHRONOCAT文件生成的访问密钥
|
|
179
|
+
## CHRONOCAT_QQ 个人:user_id=个人QQ 群则填入group_id=QQ群 多个用英文;隔开同时支持个人和群 如:user_id=xxx;group_id=xxxx;group_id=xxxxx
|
|
180
|
+
## CHRONOCAT相关API https://chronocat.vercel.app/install/docker/official/
|
|
181
|
+
export CHRONOCAT_URL=""
|
|
182
|
+
export CHRONOCAT_QQ="" #
|
|
183
|
+
export CHRONOCAT_TOKEN=""
|
|
184
|
+
|
|
176
185
|
## 其他需要的变量,脚本中需要的变量使用 export 变量名= 声明即可
|
package/sample/notify.js
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
const querystring = require('querystring');
|
|
14
|
+
const got = require('got');
|
|
14
15
|
const $ = new Env();
|
|
15
16
|
const timeout = 15000; //超时时间(单位毫秒)
|
|
16
17
|
// =======================================gotify通知设置区域==============================================
|
|
@@ -150,6 +151,23 @@ let SMTP_NAME = '';
|
|
|
150
151
|
//此处填你的PushMe KEY.
|
|
151
152
|
let PUSHME_KEY = '';
|
|
152
153
|
|
|
154
|
+
// =======================================CHRONOCAT通知设置区域===========================================
|
|
155
|
+
// CHRONOCAT_URL Red协议连接地址 例: http://127.0.0.1:16530
|
|
156
|
+
// CHRONOCAT_TOKEN 填写在CHRONOCAT文件生成的访问密钥
|
|
157
|
+
// CHRONOCAT_QQ 个人:user_id=个人QQ 群则填入group_id=QQ群 多个用英文;隔开同时支持个人和群
|
|
158
|
+
// CHRONOCAT相关API https://chronocat.vercel.app/install/docker/official/
|
|
159
|
+
let CHRONOCAT_URL = ''; // CHRONOCAT Red协议连接地址
|
|
160
|
+
let CHRONOCAT_TOKEN = ''; //CHRONOCAT 生成的访问密钥
|
|
161
|
+
let CHRONOCAT_QQ = ''; // 个人:user_id=个人QQ 群则填入group_id=QQ群 多个用英文;隔开同时支持个人和群 如:user_id=xxx;group_id=xxxx;group_id=xxxxx
|
|
162
|
+
|
|
163
|
+
// =======================================自定义通知设置区域=======================================
|
|
164
|
+
// 自定义通知 接收回调的URL
|
|
165
|
+
let WEBHOOK_URL = '';
|
|
166
|
+
let WEBHOOK_BODY = '';
|
|
167
|
+
let WEBHOOK_HEADERS = '';
|
|
168
|
+
let WEBHOOK_METHOD = '';
|
|
169
|
+
let WEBHOOK_CONTENT_TYPE = '';
|
|
170
|
+
|
|
153
171
|
//==========================云端环境变量的判断与接收=========================
|
|
154
172
|
if (process.env.GOTIFY_URL) {
|
|
155
173
|
GOTIFY_URL = process.env.GOTIFY_URL;
|
|
@@ -306,6 +324,32 @@ if (process.env.SMTP_NAME) {
|
|
|
306
324
|
if (process.env.PUSHME_KEY) {
|
|
307
325
|
PUSHME_KEY = process.env.PUSHME_KEY;
|
|
308
326
|
}
|
|
327
|
+
|
|
328
|
+
if (process.env.CHRONOCAT_URL) {
|
|
329
|
+
CHRONOCAT_URL = process.env.CHRONOCAT_URL;
|
|
330
|
+
}
|
|
331
|
+
if (process.env.CHRONOCAT_QQ) {
|
|
332
|
+
CHRONOCAT_QQ = process.env.CHRONOCAT_QQ;
|
|
333
|
+
}
|
|
334
|
+
if (process.env.CHRONOCAT_TOKEN) {
|
|
335
|
+
CHRONOCAT_TOKEN = process.env.CHRONOCAT_TOKEN;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
if (process.env.WEBHOOK_URL) {
|
|
339
|
+
WEBHOOK_URL = process.env.WEBHOOK_URL;
|
|
340
|
+
}
|
|
341
|
+
if (process.env.WEBHOOK_BODY) {
|
|
342
|
+
WEBHOOK_BODY = process.env.WEBHOOK_BODY;
|
|
343
|
+
}
|
|
344
|
+
if (process.env.WEBHOOK_HEADERS) {
|
|
345
|
+
WEBHOOK_HEADERS = process.env.WEBHOOK_HEADERS;
|
|
346
|
+
}
|
|
347
|
+
if (process.env.WEBHOOK_METHOD) {
|
|
348
|
+
WEBHOOK_METHOD = process.env.WEBHOOK_METHOD;
|
|
349
|
+
}
|
|
350
|
+
if (process.env.WEBHOOK_CONTENT_TYPE) {
|
|
351
|
+
WEBHOOK_CONTENT_TYPE = process.env.WEBHOOK_CONTENT_TYPE;
|
|
352
|
+
}
|
|
309
353
|
//==========================云端环境变量的判断与接收=========================
|
|
310
354
|
|
|
311
355
|
/**
|
|
@@ -355,6 +399,8 @@ async function sendNotify(
|
|
|
355
399
|
fsBotNotify(text, desp), //飞书机器人
|
|
356
400
|
smtpNotify(text, desp), //SMTP 邮件
|
|
357
401
|
PushMeNotify(text, desp, params), //PushMe
|
|
402
|
+
ChronocatNotify(text, desp), // Chronocat
|
|
403
|
+
webhookNotify(text, desp), //自定义通知
|
|
358
404
|
]);
|
|
359
405
|
}
|
|
360
406
|
|
|
@@ -1171,6 +1217,220 @@ function PushMeNotify(text, desp, params = {}) {
|
|
|
1171
1217
|
});
|
|
1172
1218
|
}
|
|
1173
1219
|
|
|
1220
|
+
function ChronocatNotify(title, desp) {
|
|
1221
|
+
return new Promise((resolve) => {
|
|
1222
|
+
if (!CHRONOCAT_TOKEN || !CHRONOCAT_QQ || !CHRONOCAT_URL) {
|
|
1223
|
+
console.log(
|
|
1224
|
+
'CHRONOCAT 服务的 CHRONOCAT_URL 或 CHRONOCAT_QQ 未设置!!\n取消推送',
|
|
1225
|
+
);
|
|
1226
|
+
return;
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
console.log('CHRONOCAT 服务启动');
|
|
1230
|
+
const user_ids = CHRONOCAT_QQ.match(/user_id=(\d+)/g)?.map(
|
|
1231
|
+
(match) => match.split('=')[1],
|
|
1232
|
+
);
|
|
1233
|
+
const group_ids = CHRONOCAT_QQ.match(/group_id=(\d+)/g)?.map(
|
|
1234
|
+
(match) => match.split('=')[1],
|
|
1235
|
+
);
|
|
1236
|
+
|
|
1237
|
+
const url = `${CHRONOCAT_URL}/api/message/send`;
|
|
1238
|
+
const headers = {
|
|
1239
|
+
'Content-Type': 'application/json',
|
|
1240
|
+
Authorization: `Bearer ${CHRONOCAT_TOKEN}`,
|
|
1241
|
+
};
|
|
1242
|
+
|
|
1243
|
+
for (const [chat_type, ids] of [
|
|
1244
|
+
[1, user_ids],
|
|
1245
|
+
[2, group_ids],
|
|
1246
|
+
]) {
|
|
1247
|
+
if (!ids) {
|
|
1248
|
+
continue;
|
|
1249
|
+
}
|
|
1250
|
+
for (const chat_id of ids) {
|
|
1251
|
+
const data = {
|
|
1252
|
+
peer: {
|
|
1253
|
+
chatType: chat_type,
|
|
1254
|
+
peerUin: chat_id,
|
|
1255
|
+
},
|
|
1256
|
+
elements: [
|
|
1257
|
+
{
|
|
1258
|
+
elementType: 1,
|
|
1259
|
+
textElement: {
|
|
1260
|
+
content: `${title}\n\n${desp}`,
|
|
1261
|
+
},
|
|
1262
|
+
},
|
|
1263
|
+
],
|
|
1264
|
+
};
|
|
1265
|
+
const options = {
|
|
1266
|
+
url: url,
|
|
1267
|
+
json: data,
|
|
1268
|
+
headers,
|
|
1269
|
+
timeout,
|
|
1270
|
+
};
|
|
1271
|
+
$.post(options, (err, resp, data) => {
|
|
1272
|
+
try {
|
|
1273
|
+
if (err) {
|
|
1274
|
+
console.log('Chronocat发送QQ通知消息失败!!\n');
|
|
1275
|
+
console.log(err);
|
|
1276
|
+
} else {
|
|
1277
|
+
data = JSON.parse(data);
|
|
1278
|
+
if (chat_type === 1) {
|
|
1279
|
+
console.log(`QQ个人消息:${ids}推送成功!`);
|
|
1280
|
+
} else {
|
|
1281
|
+
console.log(`QQ群消息:${ids}推送成功!`);
|
|
1282
|
+
}
|
|
1283
|
+
}
|
|
1284
|
+
} catch (e) {
|
|
1285
|
+
$.logErr(e, resp);
|
|
1286
|
+
} finally {
|
|
1287
|
+
resolve(data);
|
|
1288
|
+
}
|
|
1289
|
+
});
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
});
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1295
|
+
function webhookNotify(text, desp) {
|
|
1296
|
+
return new Promise((resolve) => {
|
|
1297
|
+
const { formatBody, formatUrl } = formatNotifyContentFun(
|
|
1298
|
+
WEBHOOK_URL,
|
|
1299
|
+
WEBHOOK_BODY,
|
|
1300
|
+
text,
|
|
1301
|
+
desp,
|
|
1302
|
+
);
|
|
1303
|
+
if (!formatUrl && !formatBody) {
|
|
1304
|
+
resolve();
|
|
1305
|
+
return;
|
|
1306
|
+
}
|
|
1307
|
+
const headers = parseHeaders(WEBHOOK_HEADERS);
|
|
1308
|
+
const body = parseBody(formatBody, WEBHOOK_CONTENT_TYPE);
|
|
1309
|
+
const bodyParam = formatBodyFun(WEBHOOK_CONTENT_TYPE, body);
|
|
1310
|
+
const options = {
|
|
1311
|
+
method: WEBHOOK_METHOD,
|
|
1312
|
+
headers,
|
|
1313
|
+
allowGetBody: true,
|
|
1314
|
+
...bodyParam,
|
|
1315
|
+
timeout,
|
|
1316
|
+
retry: 1,
|
|
1317
|
+
};
|
|
1318
|
+
|
|
1319
|
+
if (WEBHOOK_METHOD) {
|
|
1320
|
+
got(formatUrl, options).then((resp) => {
|
|
1321
|
+
try {
|
|
1322
|
+
if (resp.statusCode !== 200) {
|
|
1323
|
+
console.log('自定义发送通知消息失败!!\n');
|
|
1324
|
+
console.log(resp.body);
|
|
1325
|
+
} else {
|
|
1326
|
+
console.log('自定义发送通知消息成功🎉。\n');
|
|
1327
|
+
console.log(resp.body);
|
|
1328
|
+
}
|
|
1329
|
+
} catch (e) {
|
|
1330
|
+
$.logErr(e, resp);
|
|
1331
|
+
} finally {
|
|
1332
|
+
resolve(resp.body);
|
|
1333
|
+
}
|
|
1334
|
+
});
|
|
1335
|
+
} else {
|
|
1336
|
+
resolve();
|
|
1337
|
+
}
|
|
1338
|
+
});
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
function parseHeaders(headers) {
|
|
1342
|
+
if (!headers) return {};
|
|
1343
|
+
|
|
1344
|
+
const parsed = {};
|
|
1345
|
+
let key;
|
|
1346
|
+
let val;
|
|
1347
|
+
let i;
|
|
1348
|
+
|
|
1349
|
+
headers &&
|
|
1350
|
+
headers.split('\n').forEach(function parser(line) {
|
|
1351
|
+
i = line.indexOf(':');
|
|
1352
|
+
key = line.substring(0, i).trim().toLowerCase();
|
|
1353
|
+
val = line.substring(i + 1).trim();
|
|
1354
|
+
|
|
1355
|
+
if (!key) {
|
|
1356
|
+
return;
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1359
|
+
parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
|
|
1360
|
+
});
|
|
1361
|
+
|
|
1362
|
+
return parsed;
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
function parseBody(body, contentType) {
|
|
1366
|
+
if (!body) return '';
|
|
1367
|
+
|
|
1368
|
+
const parsed = {};
|
|
1369
|
+
let key;
|
|
1370
|
+
let val;
|
|
1371
|
+
let i;
|
|
1372
|
+
|
|
1373
|
+
body &&
|
|
1374
|
+
body.split('\n').forEach(function parser(line) {
|
|
1375
|
+
i = line.indexOf(':');
|
|
1376
|
+
key = line.substring(0, i).trim().toLowerCase();
|
|
1377
|
+
val = line.substring(i + 1).trim();
|
|
1378
|
+
|
|
1379
|
+
if (!key || parsed[key]) {
|
|
1380
|
+
return;
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
|
+
try {
|
|
1384
|
+
const jsonValue = JSON.parse(val);
|
|
1385
|
+
parsed[key] = jsonValue;
|
|
1386
|
+
} catch (error) {
|
|
1387
|
+
parsed[key] = val;
|
|
1388
|
+
}
|
|
1389
|
+
});
|
|
1390
|
+
|
|
1391
|
+
switch (contentType) {
|
|
1392
|
+
case 'multipart/form-data':
|
|
1393
|
+
return Object.keys(parsed).reduce((p, c) => {
|
|
1394
|
+
p.append(c, parsed[c]);
|
|
1395
|
+
return p;
|
|
1396
|
+
}, new FormData());
|
|
1397
|
+
case 'application/x-www-form-urlencoded':
|
|
1398
|
+
return Object.keys(parsed).reduce((p, c) => {
|
|
1399
|
+
return p ? `${p}&${c}=${parsed[c]}` : `${c}=${parsed[c]}`;
|
|
1400
|
+
});
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1403
|
+
return parsed;
|
|
1404
|
+
}
|
|
1405
|
+
|
|
1406
|
+
function formatBodyFun(contentType, body) {
|
|
1407
|
+
if (!body) return {};
|
|
1408
|
+
switch (contentType) {
|
|
1409
|
+
case 'application/json':
|
|
1410
|
+
return { json: body };
|
|
1411
|
+
case 'multipart/form-data':
|
|
1412
|
+
return { form: body };
|
|
1413
|
+
case 'application/x-www-form-urlencoded':
|
|
1414
|
+
return { body };
|
|
1415
|
+
}
|
|
1416
|
+
return {};
|
|
1417
|
+
}
|
|
1418
|
+
|
|
1419
|
+
function formatNotifyContentFun(url, body, title, content) {
|
|
1420
|
+
if (!url.includes('$title') && !body.includes('$title')) {
|
|
1421
|
+
return {};
|
|
1422
|
+
}
|
|
1423
|
+
|
|
1424
|
+
return {
|
|
1425
|
+
formatUrl: url
|
|
1426
|
+
.replaceAll('$title', encodeURIComponent(title))
|
|
1427
|
+
.replaceAll('$content', encodeURIComponent(content)),
|
|
1428
|
+
formatBody: body
|
|
1429
|
+
.replaceAll('$title', title)
|
|
1430
|
+
.replaceAll('$content', content),
|
|
1431
|
+
};
|
|
1432
|
+
}
|
|
1433
|
+
|
|
1174
1434
|
module.exports = {
|
|
1175
1435
|
sendNotify,
|
|
1176
1436
|
BARK_PUSH,
|