koishi-plugin-monetary-bourse 3.0.0-alpha.16 → 3.0.0-alpha.17
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/lib/index.js +2 -15
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -33,12 +33,7 @@ var import_koishi2 = require("koishi");
|
|
|
33
33
|
var import_koishi = require("koishi");
|
|
34
34
|
var import_path = require("path");
|
|
35
35
|
var import_fs = require("fs");
|
|
36
|
-
var
|
|
37
|
-
var import_meta = {};
|
|
38
|
-
var templatesDir = (0, import_path.resolve)(
|
|
39
|
-
(0, import_url.fileURLToPath)(new URL(".", import_meta.url)),
|
|
40
|
-
"templates"
|
|
41
|
-
);
|
|
36
|
+
var templatesDir = (0, import_path.resolve)(__dirname, "templates");
|
|
42
37
|
async function renderHoldingImage(ctx, logger2, username, holding, pending, currency) {
|
|
43
38
|
try {
|
|
44
39
|
const templatePath = (0, import_path.resolve)(templatesDir, "holding-card.html");
|
|
@@ -132,14 +127,6 @@ async function renderStockImage(ctx, logger2, data, name2, viewLabel, current, h
|
|
|
132
127
|
}) : [];
|
|
133
128
|
const templatePath = (0, import_path.resolve)(templatesDir, "stock-chart.html");
|
|
134
129
|
let html = await import_fs.promises.readFile(templatePath, "utf-8");
|
|
135
|
-
const g2Path = (0, import_path.resolve)(templatesDir, "g2.min.js");
|
|
136
|
-
let g2Script = "";
|
|
137
|
-
try {
|
|
138
|
-
g2Script = await import_fs.promises.readFile(g2Path, "utf-8");
|
|
139
|
-
g2Script = g2Script.replace(/<\/script>/g, "<\\/script>");
|
|
140
|
-
} catch (err) {
|
|
141
|
-
logger2.warn(`renderStockImage: failed to read local G2 script: ${g2Path}`, err);
|
|
142
|
-
}
|
|
143
130
|
const colorScheme = {
|
|
144
131
|
mainColor: isUp ? "#f23645" : "#089981",
|
|
145
132
|
gradientStart: isUp ? "rgba(242, 54, 69, 0.25)" : "rgba(8, 153, 129, 0.25)",
|
|
@@ -179,7 +166,7 @@ async function renderStockImage(ctx, logger2, data, name2, viewLabel, current, h
|
|
|
179
166
|
"{{TIMES}}": JSON.stringify(data.map((d) => d.time)),
|
|
180
167
|
"{{TIMESTAMPS}}": JSON.stringify(data.map((d) => d.timestamp)),
|
|
181
168
|
"{{KLINE_DATA}}": JSON.stringify(klineData),
|
|
182
|
-
"{{G2_SCRIPT}}":
|
|
169
|
+
"{{G2_SCRIPT}}": ""
|
|
183
170
|
};
|
|
184
171
|
for (const [key, value] of Object.entries(replacements)) {
|
|
185
172
|
html = html.replace(new RegExp(key, "g"), () => value);
|