|
@@ -1,25 +1,15 @@
|
|
"use strict";
|
|
"use strict";
|
|
-var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
|
|
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
|
|
- return new (P || (P = Promise))(function (resolve, reject) {
|
|
|
|
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
|
|
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
|
|
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
|
|
- step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
|
|
- });
|
|
|
|
-};
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const axios_1 = require("axios");
|
|
const axios_1 = require("axios");
|
|
const CallableInstance = require("callable-instance");
|
|
const CallableInstance = require("callable-instance");
|
|
const fs_1 = require("fs");
|
|
const fs_1 = require("fs");
|
|
const html_entities_1 = require("html-entities");
|
|
const html_entities_1 = require("html-entities");
|
|
-const message_1 = require("mirai-ts/dist/message");
|
|
|
|
const pngjs_1 = require("pngjs");
|
|
const pngjs_1 = require("pngjs");
|
|
const puppeteer = require("puppeteer");
|
|
const puppeteer = require("puppeteer");
|
|
const loggers_1 = require("./loggers");
|
|
const loggers_1 = require("./loggers");
|
|
-const writeOutTo = (path, data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
|
- yield new Promise(resolve => data.pipe(fs_1.createWriteStream(path)).on('close', resolve));
|
|
|
|
- return path;
|
|
|
|
|
|
+const mirai_1 = require("./mirai");
|
|
|
|
+const writeOutTo = (path, data) => new Promise(resolve => {
|
|
|
|
+ data.pipe(fs_1.createWriteStream(path)).on('close', () => resolve(path));
|
|
});
|
|
});
|
|
const xmlEntities = new html_entities_1.XmlEntities();
|
|
const xmlEntities = new html_entities_1.XmlEntities();
|
|
const typeInZH = {
|
|
const typeInZH = {
|
|
@@ -206,7 +196,7 @@ class Webshot extends CallableInstance {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
if (this.mode > 0)
|
|
if (this.mode > 0)
|
|
- messageChain.push(message_1.default.Plain(author + xmlEntities.decode(text)));
|
|
|
|
|
|
+ messageChain.push(mirai_1.MiraiMessage.Plain(author + xmlEntities.decode(text)));
|
|
});
|
|
});
|
|
// invoke webshot
|
|
// invoke webshot
|
|
if (this.mode === 0) {
|
|
if (this.mode === 0) {
|
|
@@ -214,16 +204,16 @@ class Webshot extends CallableInstance {
|
|
promise = promise.then(() => this.renderWebshot(url, 1920, webshotDelay))
|
|
promise = promise.then(() => this.renderWebshot(url, 1920, webshotDelay))
|
|
.then(webshotFilePath => {
|
|
.then(webshotFilePath => {
|
|
if (webshotFilePath)
|
|
if (webshotFilePath)
|
|
- messageChain.push(message_1.default.Image('', '', baseName(webshotFilePath)));
|
|
|
|
|
|
+ messageChain.push(mirai_1.MiraiMessage.Image('', '', baseName(webshotFilePath)));
|
|
});
|
|
});
|
|
// fetch extra images
|
|
// fetch extra images
|
|
}
|
|
}
|
|
else if (1 - this.mode % 2) {
|
|
else if (1 - this.mode % 2) {
|
|
if (originTwi.extended_entities) {
|
|
if (originTwi.extended_entities) {
|
|
- promise = promise.then(() => originTwi.extended_entities.media.forEach(media => {
|
|
|
|
- this.fetchImage(media.media_url_https, `${twi.user.screen_name}-${twi.id_str}--`)
|
|
|
|
- .then(path => messageChain.push(message_1.default.Image('', '', baseName(path))));
|
|
|
|
- }));
|
|
|
|
|
|
+ originTwi.extended_entities.media.forEach(media => promise = promise.then(() => this.fetchImage(media.media_url_https, `${twi.user.screen_name}-${twi.id_str}--`)
|
|
|
|
+ .then(path => {
|
|
|
|
+ messageChain.push(mirai_1.MiraiMessage.Image('', '', baseName(path)));
|
|
|
|
+ })));
|
|
}
|
|
}
|
|
// append URLs, if any
|
|
// append URLs, if any
|
|
}
|
|
}
|
|
@@ -234,7 +224,7 @@ class Webshot extends CallableInstance {
|
|
.filter(urlObj => urlObj.indices[0] < originTwi.display_text_range[1])
|
|
.filter(urlObj => urlObj.indices[0] < originTwi.display_text_range[1])
|
|
.map(urlObj => urlObj.expanded_url);
|
|
.map(urlObj => urlObj.expanded_url);
|
|
if (urls.length) {
|
|
if (urls.length) {
|
|
- messageChain.push(message_1.default.Plain(urls.join('\n')));
|
|
|
|
|
|
+ messageChain.push(mirai_1.MiraiMessage.Plain(urls.join('\n')));
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|