mirror of
https://github.com/syuilo/ai.git
synced 2025-03-25 21:12:56 +00:00
採用していたAPIが使えなくなっていたので別のものに移行
This commit is contained in:
parent
cf2195f318
commit
1a98e5708b
1 changed files with 6 additions and 8 deletions
|
@ -21,12 +21,10 @@ export default class extends Module {
|
||||||
if (msg.text && (msg.text.match(/(cat|Cat|ねこ|ネコ|にゃ[〜|ー]*ん)/g))) {
|
if (msg.text && (msg.text.match(/(cat|Cat|ねこ|ネコ|にゃ[〜|ー]*ん)/g))) {
|
||||||
const message = "にゃ~ん!";
|
const message = "にゃ~ん!";
|
||||||
|
|
||||||
setTimeout(async () => {
|
const file = await this.getCatImage();
|
||||||
const file = await this.getCatImage();
|
this.log(file);
|
||||||
this.log(file);
|
this.log('Replying...');
|
||||||
this.log('Replying...');
|
msg.reply(message, { file });
|
||||||
msg.reply(message, { file });
|
|
||||||
}, 500);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
reaction: ':blobcatmeltnomblobcatmelt:'
|
reaction: ':blobcatmeltnomblobcatmelt:'
|
||||||
|
@ -40,10 +38,10 @@ export default class extends Module {
|
||||||
private async getCatImage(): Promise<any> {
|
private async getCatImage(): Promise<any> {
|
||||||
// https://aws.random.cat/meowにGETリクエストを送る
|
// https://aws.random.cat/meowにGETリクエストを送る
|
||||||
// fileに画像URLが返ってくる
|
// fileに画像URLが返ってくる
|
||||||
const res = await fetch('https://aws.random.cat/meow');
|
const res = await fetch('https://api.thecatapi.com/v1/images/search');
|
||||||
const json = await res.json();
|
const json = await res.json();
|
||||||
console.table(json);
|
console.table(json);
|
||||||
const fileUri = json.file;
|
const fileUri = json[0].url;
|
||||||
// 拡張子を取り除く
|
// 拡張子を取り除く
|
||||||
const fileName = fileUri.split('/').pop().split('.')[0];
|
const fileName = fileUri.split('/').pop().split('.')[0];
|
||||||
const rawFile = await fetch(fileUri);
|
const rawFile = await fetch(fileUri);
|
||||||
|
|
Loading…
Reference in a new issue