-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
89 additions
and
18 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 |
---|---|---|
@@ -1,25 +1,31 @@ | ||
# -*- coding: utf-8 -*- | ||
# bot.py | ||
|
||
import asyncio | ||
import logging | ||
|
||
from aiogram import Bot, Dispatcher, types | ||
from aiogram.utils import executor | ||
|
||
from app.config import settings | ||
|
||
from .url_processing import process_url_request | ||
|
||
bot = Bot(token=settings.BOT_TOKEN) | ||
dp = Dispatcher(bot) | ||
logger = logging.getLogger(__name__) | ||
|
||
|
||
async def start(message: types.Message): | ||
await message.reply("Hello! Send me a URL to process!") | ||
|
||
|
||
@dp.message_handler(content_types=types.ContentType.TEXT) | ||
async def handle_message(message: types.Message): | ||
url = message.text.strip() | ||
result = await process_url_request(url) | ||
await message.reply(result) | ||
|
||
|
||
def start_bot(): | ||
dp.register_message_handler(start, commands="start") | ||
executor.start_polling(dp, skip_updates=True) |
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 |
---|---|---|
@@ -1,15 +1,19 @@ | ||
# -*- coding: utf-8 -*- | ||
# config.py | ||
|
||
import os | ||
|
||
from dotenv import load_dotenv | ||
from pydantic_settings import BaseSettings # Updated import | ||
|
||
load_dotenv() | ||
|
||
|
||
class Settings(BaseSettings): | ||
BASE_URL: str = os.getenv("BASE_URL", "") | ||
BOT_TOKEN: str = os.getenv("BOT_TOKEN", "") | ||
CACHE_DIR: str = os.getenv("CACHE_DIR", "/tmp/url-fairy-bot-cache/") | ||
LOG_LEVEL: str = os.getenv("LOG_LEVEL", "INFO").upper() | ||
|
||
|
||
settings = Settings() |
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
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
21 changes: 15 additions & 6 deletions
21
tests/test_url_processing.py → tests/url_processing_test.py
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