Update index.ts

This commit is contained in:
syuilo 2019-05-13 11:15:09 +09:00
parent cd46ed7eff
commit 47010b476e
No known key found for this signature in database
GPG key ID: BDC4C49D06AB9D69

View file

@ -3,6 +3,7 @@ import Module from '../../module';
import serifs from '../../serifs'; import serifs from '../../serifs';
import Message from '../../message'; import Message from '../../message';
import { renderChart } from './render-chart'; import { renderChart } from './render-chart';
import { items } from '../fortune/vocabulary';
export default class extends Module { export default class extends Module {
public readonly name = 'chart'; public readonly name = 'chart';
@ -90,6 +91,32 @@ export default class extends Module {
data: data.local.diffs.renote data: data.local.diffs.renote
}] }]
}; };
} else {
const suffixes = ['の売り上げ', 'の消費', 'の生産'];
const limit = 30;
const diffRange = 150;
const datasetCount = 1 + Math.floor(Math.random() * 3);
let datasets = [];
for (let d = 0; d < datasetCount; d++) {
let values = [Math.random() * 1000];
for (let i = 1; i < limit; i++) {
const prev = values[i - 1];
values.push(prev + ((Math.random() * (diffRange * 2)) - diffRange));
}
datasets.push({
data: values
});
}
chart = {
title: items[Math.floor(Math.random() * items.length)] + suffixes[Math.floor(Math.random() * suffixes.length)],
datasets: datasets
};
} }
this.log('Chart rendering...'); this.log('Chart rendering...');
@ -112,8 +139,9 @@ export default class extends Module {
this.log('Chart requested'); this.log('Chart requested');
} }
let type = 'userNotes'; let type = 'random';
if (msg.includes(['フォロワー'])) type = 'followers'; if (msg.includes(['フォロワー'])) type = 'followers';
if (msg.includes(['投稿'])) type = 'userNotes';
const file = await this.genChart(type, { const file = await this.genChart(type, {
user: msg.user user: msg.user