mirror of
https://github.com/syuilo/ai.git
synced 2025-03-25 21:12:56 +00:00
分ける意味がなかったので合体
This commit is contained in:
parent
1a68e6970f
commit
80a8b68d8c
3 changed files with 9 additions and 50 deletions
|
@ -16,7 +16,6 @@ import TalkModule from './modules/talk';
|
||||||
import BirthdayModule from './modules/birthday';
|
import BirthdayModule from './modules/birthday';
|
||||||
import ReversiModule from './modules/reversi';
|
import ReversiModule from './modules/reversi';
|
||||||
import PingModule from './modules/ping';
|
import PingModule from './modules/ping';
|
||||||
import okngModule from './modules/okng';
|
|
||||||
import EmojiModule from './modules/emoji';
|
import EmojiModule from './modules/emoji';
|
||||||
import EmojiReactModule from './modules/emoji-react';
|
import EmojiReactModule from './modules/emoji-react';
|
||||||
import FortuneModule from './modules/fortune';
|
import FortuneModule from './modules/fortune';
|
||||||
|
@ -70,7 +69,6 @@ promiseRetry(retry => {
|
||||||
// 藍起動
|
// 藍起動
|
||||||
new 藍(account, [
|
new 藍(account, [
|
||||||
new CoreModule(),
|
new CoreModule(),
|
||||||
new okngModule(),
|
|
||||||
new EmojiModule(),
|
new EmojiModule(),
|
||||||
new EmojiReactModule(),
|
new EmojiReactModule(),
|
||||||
new FortuneModule(),
|
new FortuneModule(),
|
||||||
|
|
|
@ -36,6 +36,15 @@ export default class extends Module {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (includes(note.text, ['いい']) && (includes(note.text, ["?"]) || includes(note.text, ["?"]))) {
|
||||||
|
// 50%の確率で":dame:"または":yattare:"を返す
|
||||||
|
if (Math.random() < 0.5) {
|
||||||
|
return react(':dame:', true);
|
||||||
|
} else {
|
||||||
|
return react(':yattare:', true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const customEmojis = note.text.match(/:([^\n:]+?):/g);
|
const customEmojis = note.text.match(/:([^\n:]+?):/g);
|
||||||
if (customEmojis) {
|
if (customEmojis) {
|
||||||
// カスタム絵文字が複数種類ある場合はキャンセル
|
// カスタム絵文字が複数種類ある場合はキャンセル
|
||||||
|
|
|
@ -1,48 +0,0 @@
|
||||||
import autobind from 'autobind-decorator';
|
|
||||||
import { parse } from 'twemoji-parser';
|
|
||||||
const delay = require('timeout-as-promise');
|
|
||||||
|
|
||||||
import { Note } from '@/misskey/note';
|
|
||||||
import Module from '@/module';
|
|
||||||
import Stream from '@/stream';
|
|
||||||
import includes from '@/utils/includes';
|
|
||||||
|
|
||||||
export default class extends Module {
|
|
||||||
public readonly name = 'okng';
|
|
||||||
|
|
||||||
private htl: ReturnType<Stream['useSharedConnection']>;
|
|
||||||
|
|
||||||
@autobind
|
|
||||||
public install() {
|
|
||||||
this.htl = this.ai.connection.useSharedConnection('homeTimeline');
|
|
||||||
this.htl.on('note', this.onNote);
|
|
||||||
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
@autobind
|
|
||||||
private async onNote(note: Note) {
|
|
||||||
if (note.reply != null) return;
|
|
||||||
if (note.text == null) return;
|
|
||||||
if (note.text.includes('@')) return; // (自分または他人問わず)メンションっぽかったらreject
|
|
||||||
|
|
||||||
const react = async (reaction: string, immediate = false) => {
|
|
||||||
if (!immediate) {
|
|
||||||
await delay(1500);
|
|
||||||
}
|
|
||||||
this.ai.api('notes/reactions/create', {
|
|
||||||
noteId: note.id,
|
|
||||||
reaction: reaction
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
if (includes(note.text, ['いい']) && (includes(note.text, ["?"]) || includes(note.text, ["?"]))) {
|
|
||||||
// 50%の確率で":dame:"または":yattare:"を返す
|
|
||||||
if (Math.random() < 0.5) {
|
|
||||||
return react(':dame:');
|
|
||||||
} else {
|
|
||||||
return react(':yattare:');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue