From c9fd58d949a735ccf5d6e26c5fc43120852299ff Mon Sep 17 00:00:00 2001 From: Redume Date: Mon, 12 Jun 2023 23:08:55 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=BC=D0=BC=D0=B0=D0=BD=D0=B4=D1=83=20`/start`=20?= =?UTF-8?q?=D0=B2=20=D0=BA=D0=BE=D1=82=D0=BE=D1=80=D0=BE=D0=B9=20=D0=BF?= =?UTF-8?q?=D0=B8=D1=88=D0=B5=D1=82=D1=81=D1=8F=20=D1=87=D1=82=D0=BE=20?= =?UTF-8?q?=D0=BC=D0=BE=D0=B6=D0=B5=D1=82=20=D0=B1=D0=BE=D1=82=20=D0=B8=20?= =?UTF-8?q?=D0=BA=D0=B0=D0=BA=20=D0=B5=D0=B3=D0=BE=20=D0=B8=D1=81=D0=BF?= =?UTF-8?q?=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index b432045..8150770 100644 --- a/main.py +++ b/main.py @@ -11,7 +11,7 @@ import requests from pydantic import BaseSettings -from aiogram import Bot # type: ignore +from aiogram import Bot, types # type: ignore from aiogram.dispatcher import Dispatcher # type: ignore from aiogram.utils import executor # type: ignore @@ -19,10 +19,11 @@ from aiogram.types import InlineQuery # type: ignore from aiogram.types import InlineQueryResultArticle from aiogram.types import InputTextMessageContent - # Constants DDG_URL = 'https://duckduckgo.com/js/spice/currency' COINAPI_URL = 'https://rest.coinapi.io/v1/exchangerate' + + # --- @@ -123,8 +124,8 @@ class CurrencyConverter: # Parsing JSON data data: Dict[str, Any] = json.loads( resp.text - .replace('ddg_spice_currency(', '') - .replace(');', '') + .replace('ddg_spice_currency(', '') + .replace(');', '') ) log.debug(data) @@ -191,7 +192,6 @@ def rotate_token(lst: List[str], active: List[int]) -> None: @dp.inline_handler() async def currency(inline_query: InlineQuery) -> None: - query = inline_query.query article: List[Optional[InlineQueryResultArticle]] = [None] @@ -237,4 +237,13 @@ async def currency(inline_query: InlineQuery) -> None: ) +@dp.message_handler(commands=['start']) +async def start(message: types.Message): + await message.answer("Hi! Bot can show the exchange rate of crypto and fiat currency. " + "The bot is used through the inline commands " + "`@shirino_bot 12 usd rub` or `@shirino_bot usd rub`" + "\n\nThe bot is open source on [Github](https://github.com/redume/shirino)", + parse_mode="markdown") + + executor.start_polling(dp, skip_updates=True)