You are browsing as a guest. Sign up (or log in) to start making projects!

Telegram assistent bot

  • 4 Devlogs
  • 18 Total hours

To learn python, I'm building a simple Telegram Bot designed to track daily health habits. The bot will allow users to quickly track their daily metrics: Sleep duration Physical activity

Open comments for this post

7h 44m 47s logged

Devlog #4: Bot Architecture Cleanup, Persistence & Statistical Charts

Hey everyone! Here’s an update on what I’ve been working on for my project over the past few days.


1. Weekly Activity Charts & Statistics

The biggest new feature is visual weekly statistics! Now users can see a chart/graph of their activity over the course of the week.

  • The Challenge: Storing data per user, per specific activity, and across each day of the week.
  • The Solution: Kept it clean and simple using user_data.
  • Persistence: Added persistent storage so data isn’t lost on restart. Honestly, I was mind-blown by how powerful Python persistence is—enabling this took literally just a couple of lines of code!

2. Refactoring & Modularizing Code

I decided it was time to break up my codebase into multiple modules/files:

  • Separation of Concerns: Initially, my architecture felt a bit messy—files knew too much about each other’s internal logic and were tightly coupled. I refactored the project so that each file and module is more autonomous and encapsulated.
  • Troubleshooting: Splitting the code broke a few things at first, but after a bit of debugging, everything is working smoothly now.

3. User Experience & Input Validation

I made several quality-of-life improvements to make the bot feel much more robust:

  • Daily Log Reminders: Added a daily reminder prompting users to log their data for the day. (Note: Users just need to run /start once to initialize reminders and resets).
  • Strict Input Validation: Added input filters. If a step requires a number, invalid text is rejected; if it asks to pick an activity, custom inputs are blocked.
  • Python vs C++ appreciation: Coming from a C++ background, it constantly amazes me how complex user interactions and data handling can be written in just a few lines of Python!

What’s Next?

  • Writing a solid README.md
  • Submitting the project!
0
0
26
Open comments for this post

3h 56m 45s logged

Devlog #3:

Changes

In this update, I focused on refining the user metrics and implementing the automated weekly reset mechanism.

  • Metric Adjustments: Removed water intake tracking from the list of monitored metrics. Simply put, I personally don’t track my daily water intake, so I decided to streamline the bot’s focus.
  • Automated Weekly Reset: Spent most of my development time implementing a scheduled automated reset system that triggers every Saturday at 12:00 PM.
    • While the underlying logic isn’t overly complex, working through it while learning Python took more time than expected.
  • As shown in the screenshot, where test data entered before 11:31 AM was automatically cleared upon trigger.

Learnings

  • Logging (logger.info): Discovered how extremely valuable logger.info is for debugging scheduled jobs and tracking state transitions. Without proper logging, diagnosing automated execution bugs would have been significantly harder.

Next Steps

  1. End-of-Week Summary Reporting: Implement logic to show results right before the automated reset occurs.
  2. Weekly Analytics & Graphs: Add visual statistics showing daily progress over the past week
0
0
21
Open comments for this post

4h 51m 48s logged

DevLog #2:


Switching Libraries

Initially, I started building this bot using another library. However, I decided to rewrite the codebase using python-telegram-bot

Why? python-telegram-bot is much more practical and scalable for complex, multi-step projects. Since I plan to build bigger features in the future, I figured it was best to learn and adopt a solid framework right now. I spent about an hour migrating my previous logic to PTB, and it was definitely worth it!


New Features

I added core bot commands and integrated custom reply keyboards:

  • /help: Shows available commands.
  • /log: Prompts you to pick an activity via a custom reply keyboard and log your stats.
  • /analytic: Allows you to select an activity and view your current recorded progress.

The trickiest part:

was figuring out how to handle sequential user inputs :

  1. First function: Catches the initial command (e.g., /log).
  2. Second function: Receives the chosen activity (e.g., Sport), asks a follow-up question (e.g., “How long have you been doing this?”)
  3. Third function: Takes the entered number/value and saves it to the selected activity state.

fix-it list:

  1. Custom Prompts per Activity: Currently, selecting “Water” asks “How long have you been doing this?” instead of “How much water did you drink?”. I need to customize questions based on the activity type.
  2. Data Accumulation: Right now, logging a value overwrites context.user_data[activity] instead of adding to it. I will fix this so values accumulate properly over time.
  3. Weekly Reset: I need to implement an automated mechanism to reset tracking data every Saturday.

Since fixing these remaining issues won’t take too much time, I’ll soon be ready to add new features.

So let me know if you got any ideas in the comments below

0
0
10
Open comments for this post

1h 40m 39s logged

DevLog #1: Learning Python Through Practice

This is my first Python project. Instead of just memorizing syntax from tutorials, I decided to learn the language through hands-on practice.

To test this approach, I’m building a simple Telegram Bot designed to track daily health habits.


The Core Concept

The bot will allow users to quickly log their daily metrics:

  • Sleep duration
  • Water intake
  • Physical activity / workouts

It stores this data and, upon clicking a button, generates a weekly summary analysis to track progress.


Current Progress

So far, I have:

  • Created and structured the GitHub repository.
  • Added essential initial files (.gitignore, dependencies, configuration).
  • Developed a basic, functional Telegram bot prototype.

The Experiment

This project isn’t meant to be a full-scale commercial application; it’s a personal challenge:
Can I effectively master Python by building functional, real-world projects from scratch?

0
0
14

Delete project?

Are you sure you want to permanently delete this project? This action cannot be undone.

All devlogs, followers, and associated data will be removed.

Followers

Loading…