|
1 | 1 | import genSongInfoButtons from '../utils/genSongInfoButtons'; |
2 | 2 | import { Song } from '@clansty/maibot-types/src'; |
3 | 3 | import LyricsHelper from '../utils/LyricsHelper'; |
4 | | -import { BotTypes, BundledMessageBase, MessageButtonSwitchInline, MessageButtonUrl, SendMessageAction } from '@clansty/maibot-firm'; |
| 4 | +import { BotTypes, BundledMessageBase, MessageButtonSwitchInline, MessageButtonUrl, MessageEventBase, SendMessageAction } from '@clansty/maibot-firm'; |
5 | 5 | import { BuilderEnv } from '../botBuilder'; |
6 | 6 | import { MESSAGE_TEMPLATE } from '../MessageTemplate'; |
7 | 7 |
|
@@ -120,8 +120,7 @@ export default <T extends BotTypes>({ bot, env, getContext, musicToFile }: Build |
120 | 120 | return true; |
121 | 121 | }); |
122 | 122 |
|
123 | | - bot.registerCommand(['search', 'maimai', 's'], async (event) => { |
124 | | - const kw = event.params.join(' ').trim(); |
| 123 | + const handleSearch = async (event: MessageEventBase<T>, kw: string) => { |
125 | 124 | if (!kw) { |
126 | 125 | await event.reply() |
127 | 126 | .setText('请输入要搜索的歌曲名') |
@@ -154,5 +153,13 @@ export default <T extends BotTypes>({ bot, env, getContext, musicToFile }: Build |
154 | 153 | const song = results[0]; |
155 | 154 | await sendSong(event.reply(), song); |
156 | 155 | return true; |
| 156 | + }; |
| 157 | + |
| 158 | + bot.registerCommand(['search', 'maimai', 's'], async (event) => { |
| 159 | + return handleSearch(event, event.params.join(' ').trim()); |
| 160 | + }); |
| 161 | + |
| 162 | + bot.registerKeyword([/(.+)是什么歌$/, /^[\w\/]*查歌(.+)/], async (event) => { |
| 163 | + return handleSearch(event, event.match[1].trim()); |
157 | 164 | }); |
158 | 165 | } |
0 commit comments