Add search variants
This commit is contained in:
@@ -3,6 +3,9 @@ from aiogram import Router, F
|
||||
from aiogram.types import InlineQuery
|
||||
|
||||
from bot.results.deezer import get_deezer_search_results
|
||||
from bot.results.soundcloud import get_soundcloud_search_results
|
||||
from bot.results.youtube import get_youtube_search_results
|
||||
from bot.results.spotify import get_spotify_search_results
|
||||
|
||||
from bot.modules.settings import UserSettings
|
||||
|
||||
@@ -12,7 +15,12 @@ router = Router()
|
||||
@router.inline_query(F.query != '')
|
||||
async def default_inline_query(inline_query: InlineQuery, settings: UserSettings):
|
||||
await inline_query.answer(
|
||||
await get_deezer_search_results(inline_query.query, settings),
|
||||
await {
|
||||
'd': get_deezer_search_results,
|
||||
'c': get_soundcloud_search_results,
|
||||
'y': get_youtube_search_results,
|
||||
's': get_spotify_search_results
|
||||
}[settings['default_search_provider'].value](inline_query.query, settings),
|
||||
cache_time=0,
|
||||
is_personal=True
|
||||
)
|
||||
|
||||
@@ -40,6 +40,16 @@ settings_strings: dict[str, Setting] = {
|
||||
'yes': 'Only exact matches',
|
||||
'no': 'Fuzzy matches also'
|
||||
},
|
||||
),
|
||||
'default_search_provider': Setting(
|
||||
name='Default search provider',
|
||||
description='Which service to use when searching without service filter',
|
||||
choices={
|
||||
'd': 'Deezer',
|
||||
'c': 'SoundCloud',
|
||||
'y': 'YouTube',
|
||||
's': 'Spotify'
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ readme = "README.md"
|
||||
python = "^3.11"
|
||||
aiogram = "^3.1.1"
|
||||
rich = "^13.6.0"
|
||||
py-deezer = "^1.1.4.post1"
|
||||
shazamio = { path = "lib/ShazamIO" }
|
||||
sqlitedict = "^2.1.0"
|
||||
spotipy = "^2.23.0"
|
||||
@@ -21,6 +20,7 @@ aiohttp = "^3.8.6"
|
||||
nest-asyncio = "^1.5.8"
|
||||
icecream = "^2.1.3"
|
||||
m3u8 = "^3.6.0"
|
||||
cryptography = "^41.0.7"
|
||||
|
||||
|
||||
[build-system]
|
||||
|
||||
Reference in New Issue
Block a user