diff --git a/src/index.ts b/src/index.ts index dca5703..cff6315 100644 --- a/src/index.ts +++ b/src/index.ts @@ -34,6 +34,7 @@ import SleepReportModule from './modules/sleep-report'; import NotingModule from './modules/noting'; import PollModule from './modules/poll'; import ReminderModule from './modules/reminder'; +import RecommendMusicModule from './modules/recommend-music'; console.log(' __ ____ _____ ___ '); console.log(' /__\\ (_ _)( _ )/ __)'); @@ -88,6 +89,7 @@ promiseRetry(retry => { new NotingModule(), new PollModule(), new ReminderModule(), + new RecommendMusicModule(), ]); }).catch(e => { log(chalk.red('Failed to fetch the account')); diff --git a/src/modules/recommend-music/index.ts b/src/modules/recommend-music/index.ts new file mode 100644 index 0000000..d9547ff --- /dev/null +++ b/src/modules/recommend-music/index.ts @@ -0,0 +1,30 @@ +import autobind from 'autobind-decorator'; +import Module from '@/module'; +import Message from '@/message'; +import serifs from '@/serifs'; + +const musicUrls = [ + 'https://www.nicovideo.jp/watch/sm31677384' +] + +export default class extends Module { + public readonly name = 'recommendMusic'; + + @autobind + public install() { + return { + mentionHook: this.mentionHook + }; + } + + @autobind + private async mentionHook(msg: Message) { + if (msg.includes(['音楽聞きたい', '曲聞きたい', '音楽聴きたい', '曲聴きたい'])) { + const music = musicUrls[Math.floor(Math.random() * musicUrls.length)]; + msg.reply(serifs.recommendMusic.suggestMusic(music)); + return true; + } else { + return false; + } + } +} diff --git a/src/serifs.ts b/src/serifs.ts index 15ae16e..9c80c5b 100644 --- a/src/serifs.ts +++ b/src/serifs.ts @@ -313,6 +313,13 @@ export default { suggest: emoji => `こんなのはどうですか?→${emoji}`, }, + /** + * 音楽おすすめ + */ + recommendMusic: { + suggestMusic: musicUrl => `こんなのはどうでしょう?${musicUrl}` + }, + /** * 占い */