mirror of
https://github.com/syuilo/ai.git
synced 2025-03-25 21:12:56 +00:00
言葉の意味
This commit is contained in:
parent
b6c5258b0f
commit
83068eb8ff
1 changed files with 32 additions and 0 deletions
32
src/modules/dic/index.ts
Normal file
32
src/modules/dic/index.ts
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
import autobind from 'autobind-decorator';
|
||||||
|
import Module from '@/module';
|
||||||
|
import Message from '@/message';
|
||||||
|
|
||||||
|
export default class extends Module {
|
||||||
|
public readonly name = 'dic';
|
||||||
|
|
||||||
|
@autobind
|
||||||
|
public install() {
|
||||||
|
return {
|
||||||
|
mentionHook: this.mentionHook
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@autobind
|
||||||
|
private async mentionHook(msg: Message) {
|
||||||
|
if (msg.text && msg.text.includes('って何')) {
|
||||||
|
// msg.textのうち、「の意味は」の直前で、「@ai」よりも後の物を抽出
|
||||||
|
const dic_prefix = "https://www.weblio.jp/content/";
|
||||||
|
const raw_word = msg.text.split('って何')[0].split('@ai_dev')[1].trim();
|
||||||
|
// スペースがある場合は、半角スペースを除去
|
||||||
|
const word = raw_word.replace(/\s/g, '');
|
||||||
|
const url = dic_prefix + encodeURIComponent(word);
|
||||||
|
msg.reply(`こんな意味っぽい?> [${word}](${url})`, {
|
||||||
|
immediate: true
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue