Skip to content

Conversation

gnatykdm
Copy link
Owner

@gnatykdm gnatykdm commented Aug 3, 2025

No description provided.

@gnatykdm gnatykdm requested a review from Copilot August 3, 2025 09:12
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements an automatic messaging system for a Telegram bot that sends personalized morning and evening messages to users based on their configured wake and sleep times.

  • Adds scheduler functionality to send automated messages at user-defined times
  • Implements job management for individual users when they update their wake/sleep times
  • Creates message templates and delivery functions for morning and evening routines

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
telegram_bot_project/service/user.py Adds method to retrieve all users with their wake/sleep times for scheduling
telegram_bot_project/service/myday.py Implements batch creation of daily stats for all users
telegram_bot_project/messages.py Adds message templates and functions for morning/evening automated messages
telegram_bot_project/main.py Integrates scheduler initialization and daily stats job setup
telegram_bot_project/bot/scheduler.py Core scheduler implementation for managing automated user messages
telegram_bot_project/bot/handlers.py Updates wake/sleep time handlers to register scheduler jobs
telegram_bot_project/bot/commands.py Minor import reorganization

# Command Handlers
@dp.message(Command("start"))
async def start(message: Message):
global USER_ID
Copy link
Preview

Copilot AI Aug 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The global variable USER_ID is declared but never defined or used in this function. This will cause a NameError if accessed elsewhere.

Suggested change
global USER_ID

Copilot uses AI. Check for mistakes.

}

# Buttons
BUTTON_SETTINGS = "⚙️ Settings"
Copy link
Preview

Copilot AI Aug 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The BUTTON_SETTINGS variable is being redefined. The original definition on line 222 is being moved, but this creates inconsistency in the code structure. Consider maintaining the original order or using a single definition.

Copilot uses AI. Check for mistakes.

from apscheduler.triggers.cron import CronTrigger
from messages import *

from messages import send_morning_message, send_evening_message
Copy link
Preview

Copilot AI Aug 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This import is redundant since line 6 already imports everything from messages with 'from messages import *'. Remove this duplicate import.

Suggested change
from messages import send_morning_message, send_evening_message

Copilot uses AI. Check for mistakes.

scheduler: AsyncIOScheduler = initialize_scheduler()
scheduler.add_job(
MyDayService.create_stats_for_all_users,
'cron',
Copy link
Preview

Copilot AI Aug 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The string 'cron' should be passed as a keyword argument 'trigger' for better code readability and to match the explicit style used elsewhere in the codebase.

Suggested change
'cron',
trigger='cron',

Copilot uses AI. Check for mistakes.

Comment on lines +299 to +304

print(f"[INFO] - Sending morning routine to user with id, {user_id}")
if not morning_routine:
await bot.send_message(
user_id,
MESSAGES[language]['SEND_MORNING_MSG'].format("👤") + '\n' + MESSAGES[language]['NO_MORNING_ROUTINE']
Copy link
Preview

Copilot AI Aug 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hardcoded "👤" emoji should be replaced with a more meaningful placeholder or the actual username, as suggested by the message template parameter structure.

Suggested change
print(f"[INFO] - Sending morning routine to user with id, {user_id}")
if not morning_routine:
await bot.send_message(
user_id,
MESSAGES[language]['SEND_MORNING_MSG'].format("👤") + '\n' + MESSAGES[language]['NO_MORNING_ROUTINE']
username = await UserService.get_username(user_id) or "Friend"
print(f"[INFO] - Sending morning routine to user with id, {user_id}")
if not morning_routine:
await bot.send_message(
user_id,
MESSAGES[language]['SEND_MORNING_MSG'].format(username) + '\n' + MESSAGES[language]['NO_MORNING_ROUTINE']

Copilot uses AI. Check for mistakes.

Comment on lines +325 to +327
await bot.send_message(
user_id,
MESSAGES[language]['SEND_EVENING_MSG'].format("👤")
Copy link
Preview

Copilot AI Aug 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the morning message, the hardcoded "👤" emoji should be replaced with a more meaningful placeholder or the actual username.

Suggested change
await bot.send_message(
user_id,
MESSAGES[language]['SEND_EVENING_MSG'].format("👤")
username = await UserService.get_username(user_id) or "User"
await bot.send_message(
user_id,
MESSAGES[language]['SEND_EVENING_MSG'].format(username)

Copilot uses AI. Check for mistakes.

@gnatykdm gnatykdm merged commit bc8ea1a into master Aug 3, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant