Skip to content

Commit f343e05

Browse files
authored
Merge pull request #2 from gnatykdm/Bot-Skeleton
Bot-Skeleton C:2
2 parents 103ca8b + 8ffad47 commit f343e05

File tree

4 files changed

+93
-3
lines changed

4 files changed

+93
-3
lines changed

sql/schema.sql

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
-- One-Task-bit-Bot DB Scheme --
2+
3+
-- ENUM's --
4+
CREATE TYPE lan AS ENUM ('UKRANIAN', 'ENGLISH');
5+
6+
-- TABLE users
7+
CREATE TABLE users (
8+
id BIGSERIAL PRIMARY KEY,
9+
user_name VARCHAR(255) NOT NULL UNIQUE,
10+
language lan NOT NULL DEFAULT 'ENGLISH',
11+
register_date TIMESTAMP NOT NULL DEFAULT NOW()
12+
);
13+
14+
-- TABLE tasks
15+
CREATE TABLE tasks (
16+
id SERIAL PRIMARY KEY,
17+
user_id BIGINT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
18+
task_name VARCHAR(255) NOT NULL,
19+
status BOOLEAN NOT NULL DEFAULT FALSE,
20+
start_time TIMESTAMP,
21+
creation_date TIMESTAMP NOT NULL DEFAULT NOW()
22+
);
23+
24+
-- TABLE ideas
25+
CREATE TABLE ideas (
26+
id SERIAL PRIMARY KEY,
27+
user_id BIGINT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
28+
idea_name VARCHAR(255) NOT NULL,
29+
creation_date TIMESTAMP NOT NULL DEFAULT NOW()
30+
);
31+
32+
Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,34 @@
11
from typing import Any
22
from aiogram.types import Message
33

4-
async def start_command(message: Message, **kwargs: Any) -> None:
5-
await message.answer("Hello!")
4+
from messages import *
65

6+
# Start Command Handler
7+
async def start_command(message: Message)-> None:
78

9+
user_id: int = message.from_user.id
10+
user_name: str = message.from_user.username
11+
12+
print(f"--[INFO] - User {user_id} ({user_name}) - started the bot")
13+
14+
await message.answer(START_MSG)
15+
16+
# Help Command Handler
17+
async def help_command(message: Message) -> None:
18+
19+
user_id: int = message.from_user.id
20+
user_name: str = message.from_user.username
21+
22+
print(f"--[INFO] - User {user_id} ({user_name}) - asked for help")
23+
24+
await message.answer(HELP_MSG)
25+
26+
# Menu Command Handler
27+
async def menu_command(message: Message) -> None:
28+
29+
user_id: int = message.from_user.id
30+
user_name: str = message.from_user.username
31+
32+
print(f"--[INFO] - User {user_id} ({user_name}) - asked for menu")
33+
34+
await message.answer(MENU_MSG)

telegram_bot_project/main.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,29 @@
55
from aiogram.types import Message
66

77
from config import TOKEN
8-
from bot.commands import start_command
8+
from bot.commands import *
99

1010
dp: Dispatcher = Dispatcher()
1111

12+
# Commands Handlers
1213
@dp.message(Command("start"))
1314
async def start(message: Message):
1415
await start_command(message)
1516

17+
@dp.message(Command("help"))
18+
async def help(message: Message):
19+
await help_command(message)
1620

21+
@dp.message(Command("menu"))
22+
async def menu(message: Message):
23+
await menu_command(message)
24+
25+
# Main Function
1726
async def main():
1827
bot: Bot = Bot(token=TOKEN)
1928
await dp.start_polling(bot)
2029

30+
# Start point
2131
if __name__ == "__main__":
32+
print("-- STARTING ROCKY --\n")
2233
asyncio.run(main())

telegram_bot_project/messages.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
START_MSG: str = "👋 Hey there!\nI'm 🦝 Rocky — your personal focus assistant.\nReady to configure language?"
2+
START_MSG_AGAIN: str = "👋 Welcome back, legend.\nRocky missed you. Let’s keep crushing it 💥"
3+
4+
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."
5+
6+
MAKE_TASK_MSG: str = "🧠 What's your next focus task?"
7+
TASK_CREATED_MSG: str = "✅ Got it! Your task has been created."
8+
TASK_COMPLETED_MSG: str = "🎯 Boom! Task completed. Great job!"
9+
TASK_DELETED_MSG: str = "🗑️ Task removed from your queue."
10+
TASK_UPDATED_MSG: str = "🔁 Task updated successfully."
11+
12+
IDEAS_MSG: str = "💡 Here are all your brilliant ideas:"
13+
CREATE_IDEA_MSG: str = "💬 What's your idea? Type it below:"
14+
IDEA_CREATED_MSG: str = "✨ Idea saved! Never lose a thought again."
15+
DELETE_IDEA_MSG: str = "⚠️ Are you sure you want to delete this idea?"
16+
17+
ERROR_MSG: str = "⚠️ Oops! Something went wrong. Try again or send /help."
18+
19+
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! 🦝"
20+

0 commit comments

Comments
 (0)