-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from krystlepalace/search
New feature - Search
- Loading branch information
Showing
6 changed files
with
83 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from aiogram import Router, F | ||
from aiogram.fsm.context import FSMContext | ||
from aiogram.fsm.state import StatesGroup, State | ||
from aiogram.types import Message | ||
from aiogram.filters import Command, CommandObject | ||
import main | ||
from keyboards.choose_character import search_results | ||
|
||
router = Router() | ||
|
||
|
||
class SearchQuery(StatesGroup): | ||
results = State() | ||
|
||
|
||
@router.message(Command("search")) | ||
async def search_cmd(message: Message, command: CommandObject, state: FSMContext): | ||
query = command.args | ||
result = await main.client.character.search(query) | ||
|
||
await state.set_state(SearchQuery.results) | ||
await state.set_data(result["characters"]) | ||
await message.reply(text=f"Search for '{query}'", | ||
reply_markup=search_results(result["characters"]).as_markup()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters