Commit 7d9f1740 authored by nanahira's avatar nanahira

add isOneBotBot

parent 82eef606
...@@ -180,6 +180,14 @@ export default class PicsContainer ...@@ -180,6 +180,14 @@ export default class PicsContainer
return this.fetchPicsWithSources(sources, picTags); return this.fetchPicsWithSources(sources, picTags);
} }
isOneBotBot(bot?: Bot) {
return (
bot &&
(bot.platform === 'onebot' ||
(bot.platform === 'qqguild' && bot['parentBot']?.platform === 'onebot'))
);
}
async getSegment(url: string, bot?: Bot) { async getSegment(url: string, bot?: Bot) {
try { try {
if (this.config.useAssets && this.assets) { if (this.config.useAssets && this.assets) {
...@@ -194,13 +202,9 @@ export default class PicsContainer ...@@ -194,13 +202,9 @@ export default class PicsContainer
} catch (e) { } catch (e) {
this.logger.warn(`Download image ${url} failed: ${e.toString()}`); this.logger.warn(`Download image ${url} failed: ${e.toString()}`);
} }
const isOnebot = const isOneBotBot = this.isOneBotBot(bot);
bot &&
(bot.platform === 'onebot' ||
(bot.platform === 'qqguild' &&
bot['parentBot']?.platform === 'onebot'));
const picData: segment.Data = { const picData: segment.Data = {
[isOnebot ? 'file' : 'url']: url, [isOneBotBot ? 'file' : 'url']: url,
cache: true, cache: true,
}; };
return segment('image', picData); return segment('image', picData);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment