From 8ffad479ffb66293d7c1cd98db9de9c9161b4e3b Mon Sep 17 00:00:00 2001 From: gnatykdm Date: Tue, 1 Jul 2025 17:24:09 +0200 Subject: [PATCH] Bot-Skeleton C:2 --- sql/schema.sql | 32 ++++++++++++++++++++++++++++ telegram_bot_project/bot/commands.py | 31 +++++++++++++++++++++++++-- telegram_bot_project/main.py | 13 ++++++++++- telegram_bot_project/messages.py | 20 +++++++++++++++++ 4 files changed, 93 insertions(+), 3 deletions(-) create mode 100644 sql/schema.sql diff --git a/sql/schema.sql b/sql/schema.sql new file mode 100644 index 0000000..dc4e600 --- /dev/null +++ b/sql/schema.sql @@ -0,0 +1,32 @@ +-- One-Task-bit-Bot DB Scheme -- + +-- ENUM's -- +CREATE TYPE lan AS ENUM ('UKRANIAN', 'ENGLISH'); + +-- TABLE users +CREATE TABLE users ( + id BIGSERIAL PRIMARY KEY, + user_name VARCHAR(255) NOT NULL UNIQUE, + language lan NOT NULL DEFAULT 'ENGLISH', + register_date TIMESTAMP NOT NULL DEFAULT NOW() +); + +-- TABLE tasks +CREATE TABLE tasks ( + id SERIAL PRIMARY KEY, + user_id BIGINT NOT NULL REFERENCES users(id) ON DELETE CASCADE, + task_name VARCHAR(255) NOT NULL, + status BOOLEAN NOT NULL DEFAULT FALSE, + start_time TIMESTAMP, + creation_date TIMESTAMP NOT NULL DEFAULT NOW() +); + +-- TABLE ideas +CREATE TABLE ideas ( + id SERIAL PRIMARY KEY, + user_id BIGINT NOT NULL REFERENCES users(id) ON DELETE CASCADE, + idea_name VARCHAR(255) NOT NULL, + creation_date TIMESTAMP NOT NULL DEFAULT NOW() +); + + diff --git a/telegram_bot_project/bot/commands.py b/telegram_bot_project/bot/commands.py index 93b469f..a3e2bcb 100644 --- a/telegram_bot_project/bot/commands.py +++ b/telegram_bot_project/bot/commands.py @@ -1,7 +1,34 @@ from typing import Any from aiogram.types import Message -async def start_command(message: Message, **kwargs: Any) -> None: - await message.answer("Hello!") +from messages import * +# Start Command Handler +async def start_command(message: Message)-> None: + user_id: int = message.from_user.id + user_name: str = message.from_user.username + + print(f"--[INFO] - User {user_id} ({user_name}) - started the bot") + + await message.answer(START_MSG) + +# Help Command Handler +async def help_command(message: Message) -> None: + + user_id: int = message.from_user.id + user_name: str = message.from_user.username + + print(f"--[INFO] - User {user_id} ({user_name}) - asked for help") + + await message.answer(HELP_MSG) + +# Menu Command Handler +async def menu_command(message: Message) -> None: + + user_id: int = message.from_user.id + user_name: str = message.from_user.username + + print(f"--[INFO] - User {user_id} ({user_name}) - asked for menu") + + await message.answer(MENU_MSG) \ No newline at end of file diff --git a/telegram_bot_project/main.py b/telegram_bot_project/main.py index 9e39d4c..5e02e42 100644 --- a/telegram_bot_project/main.py +++ b/telegram_bot_project/main.py @@ -5,18 +5,29 @@ from aiogram.types import Message from config import TOKEN -from bot.commands import start_command +from bot.commands import * dp: Dispatcher = Dispatcher() +# Commands Handlers @dp.message(Command("start")) async def start(message: Message): await start_command(message) +@dp.message(Command("help")) +async def help(message: Message): + await help_command(message) +@dp.message(Command("menu")) +async def menu(message: Message): + await menu_command(message) + +# Main Function async def main(): bot: Bot = Bot(token=TOKEN) await dp.start_polling(bot) +# Start point if __name__ == "__main__": + print("-- STARTING ROCKY --\n") asyncio.run(main()) \ No newline at end of file diff --git a/telegram_bot_project/messages.py b/telegram_bot_project/messages.py index e69de29..d6e72e9 100644 --- a/telegram_bot_project/messages.py +++ b/telegram_bot_project/messages.py @@ -0,0 +1,20 @@ +START_MSG: str = "πŸ‘‹ Hey there!\nI'm 🦝 Rocky β€” your personal focus assistant.\nReady to configure language?" +START_MSG_AGAIN: str = "πŸ‘‹ Welcome back, legend.\nRocky missed you. Let’s keep crushing it πŸ’₯" + +HELP_MSG: str = "❓ Need help? Just type \n /add to create a task, \n /idea to save an idea, \n /done to complete your task." + +MAKE_TASK_MSG: str = "🧠 What's your next focus task?" +TASK_CREATED_MSG: str = "βœ… Got it! Your task has been created." +TASK_COMPLETED_MSG: str = "🎯 Boom! Task completed. Great job!" +TASK_DELETED_MSG: str = "πŸ—‘οΈ Task removed from your queue." +TASK_UPDATED_MSG: str = "πŸ” Task updated successfully." + +IDEAS_MSG: str = "πŸ’‘ Here are all your brilliant ideas:" +CREATE_IDEA_MSG: str = "πŸ’¬ What's your idea? Type it below:" +IDEA_CREATED_MSG: str = "✨ Idea saved! Never lose a thought again." +DELETE_IDEA_MSG: str = "⚠️ Are you sure you want to delete this idea?" + +ERROR_MSG: str = "⚠️ Oops! Something went wrong. Try again or send /help." + +MENU_MSG = "πŸ“‹ Your Main Menu:\n\nβœ… /add – Create a new task\nπŸ’‘ /idea – Save an idea\n🎯 /myday – View your day\nπŸ”§ /settings – Settings & preferences\n✨ /help – Need guidance?\n\nRocky is here to help you stay focused! 🦝" +