mirror of
https://github.com/Redume/Shirino.git
synced 2024-11-24 09:16:22 +03:00
Compare commits
No commits in common. "264fa1e98e713c0e4310968064fa950e3571f7de" and "afb97be824b69648af2ac51db004bbe0f39858f7" have entirely different histories.
264fa1e98e
...
afb97be824
1 changed files with 5 additions and 14 deletions
19
main.py
19
main.py
|
@ -11,7 +11,7 @@ import requests
|
||||||
|
|
||||||
from pydantic import BaseSettings
|
from pydantic import BaseSettings
|
||||||
|
|
||||||
from aiogram import Bot, types # type: ignore
|
from aiogram import Bot # type: ignore
|
||||||
from aiogram.dispatcher import Dispatcher # type: ignore
|
from aiogram.dispatcher import Dispatcher # type: ignore
|
||||||
from aiogram.utils import executor # type: ignore
|
from aiogram.utils import executor # type: ignore
|
||||||
|
|
||||||
|
@ -19,11 +19,10 @@ from aiogram.types import InlineQuery # type: ignore
|
||||||
from aiogram.types import InlineQueryResultArticle
|
from aiogram.types import InlineQueryResultArticle
|
||||||
from aiogram.types import InputTextMessageContent
|
from aiogram.types import InputTextMessageContent
|
||||||
|
|
||||||
|
|
||||||
# Constants
|
# Constants
|
||||||
DDG_URL = 'https://duckduckgo.com/js/spice/currency'
|
DDG_URL = 'https://duckduckgo.com/js/spice/currency'
|
||||||
COINAPI_URL = 'https://rest.coinapi.io/v1/exchangerate'
|
COINAPI_URL = 'https://rest.coinapi.io/v1/exchangerate'
|
||||||
|
|
||||||
|
|
||||||
# ---
|
# ---
|
||||||
|
|
||||||
|
|
||||||
|
@ -124,8 +123,8 @@ class CurrencyConverter:
|
||||||
# Parsing JSON data
|
# Parsing JSON data
|
||||||
data: Dict[str, Any] = json.loads(
|
data: Dict[str, Any] = json.loads(
|
||||||
resp.text
|
resp.text
|
||||||
.replace('ddg_spice_currency(', '')
|
.replace('ddg_spice_currency(', '')
|
||||||
.replace(');', '')
|
.replace(');', '')
|
||||||
)
|
)
|
||||||
|
|
||||||
log.debug(data)
|
log.debug(data)
|
||||||
|
@ -192,6 +191,7 @@ def rotate_token(lst: List[str], active: List[int]) -> None:
|
||||||
|
|
||||||
@dp.inline_handler()
|
@dp.inline_handler()
|
||||||
async def currency(inline_query: InlineQuery) -> None:
|
async def currency(inline_query: InlineQuery) -> None:
|
||||||
|
|
||||||
query = inline_query.query
|
query = inline_query.query
|
||||||
article: List[Optional[InlineQueryResultArticle]] = [None]
|
article: List[Optional[InlineQueryResultArticle]] = [None]
|
||||||
|
|
||||||
|
@ -237,13 +237,4 @@ 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)
|
executor.start_polling(dp, skip_updates=True)
|
||||||
|
|
Loading…
Add table
Reference in a new issue