Skip to content

Dev#1

Closed
svereshagin wants to merge 54 commits intomainfrom
dev
Closed

Dev#1
svereshagin wants to merge 54 commits intomainfrom
dev

Conversation

@svereshagin
Copy link
Copy Markdown
Owner

@svereshagin svereshagin commented Dec 17, 2025

okay


Note

Introduces an async TeleBot app with i18n-backed registration flow, inline keyboards/commands, and an async SQLAlchemy/Postgres layer, plus CI, Docker, and config updates.

  • Bot (Async + State Machine):
    • Initialize async bot in src/bot_instance.py with state storage and middlewares; new entrypoint src/main.py (polling, init commands, keyboard manager, DB reset).
    • Add handlers in src/app/handlers/handlers.py wiring registration, language change, rules, and menu callbacks.
    • Implement services for registration and rules in src/app/services/* and states in src/app/states.py.
    • Command/keyboard systems: src/configs/commands.py, src/configs/commands.yaml, src/configs/keyboard_manager.py.
  • Internationalization (i18n):
    • Add gettext-based middleware src/middleware/i18n_middleware/* and translator src/app/translator.py.
    • Add locale catalogs src/middleware/locales/{en,ru,fr,it,es}/LC_MESSAGES/messages.po.
  • Database (Async SQLAlchemy):
    • Add async engine/session, base, helpers in src/database/database.py and CRUD in src/database/db_sessions.py.
    • Define User model in src/database/models.py.
  • Config/Settings:
    • New settings in src/configs/config.py (env-based, DB URL, paths); replace old src/config/config.py.
    • Update .env.example (port 5433, ADMIN_IDS) and docker-compose.yml to map 5433:5432 and run python3 -m src.main.
    • pyproject.toml adds deps (aiohttp, asyncpg, alembic, pydantic-settings, babel, aiogram, etc.).
  • Tooling/DevOps:
    • Add Pylint GitHub Action .github/workflows/pylint.yml.
    • Dockerfile installs Poetry deps and gettext; Makefile adds i18n utilities.
    • Docs: update README.md; add example telebot_examples/STATE_EXAMPLE.py.

Written by Cursor Bugbot for commit ff89625. This will update automatically on new commits. Configure here.

svereshagin and others added 30 commits December 3, 2024 09:08
… accordingly to main struct of needed constructs
… accordingly to main struct of needed constructs
…ommand is python3 app.py being in src(root package)
…mming. Docker works. Everything builds fine. Need to complete methods.
…mming. Docker works. Everything builds fine. Need to complete methods.
…mming. Docker works. Everything builds fine. Need to complete methods.
# Conflicts:
#	Dockerfile
#	src/app/handlers.py
# Conflicts:
#	Makefile
#	src/app/handlers.py
handlers managed to be better,
class Translator_Language additional function to handle last stage.

Everything is working
handlers managed to be better,
class Translator_Language additional function to handle last stage.

Everything is working
amadeo and others added 24 commits December 20, 2024 11:46
one_reason.py - for serises wit no long states(line 1 or 2 maximum)
…s working, added language_keyboard(prev was in one_reasons and keyboards.py) added new ACRONYMS and LANGUAGES, that through zip handle language operations. Format works for any language. TODO:

Need to find the way of working with age(got the range() and handle str symbols.

2. Need to make better first msg.
3. Add keyboard for users to work with cmds. Work on module commands.
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

This PR is being reviewed by Cursor Bugbot

Details

You are on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

&& rm -rf $(poetry config cache-dir)/{cache,artifacts}

&& rm -rf $(poetry config cache-dir)/{cache,artifacts} \
apt install gettext
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: Dockerfile command chaining broken causes incorrect behavior

The apt install gettext command is missing the && operator to chain it with the previous command. With the backslash line continuation, apt, install, and gettext become additional arguments to rm -rf, causing it to attempt deleting files/directories with those names instead of installing the gettext package. The line needs && apt install gettext instead of just apt install gettext.

Fix in Cursor Fix in Web


@bot.message_handler(state=RegistrateUser.waiting_for_name)
async def name_get(message: types.Message, state: StateContext):
await handle_name_input(bot, message, state)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: Duplicate function name overwrites first handler definition

Two handler functions are defined with the identical name name_get. In Python, the second definition on line 83-85 overwrites the first one on lines 79-81. This means the handler for RegistrateUser.waiting_for_start state will never be called because its function reference is replaced by the handler for waiting_for_name. One of these functions needs to be renamed.

Fix in Cursor Fix in Web

await bot.send_message(
user_id,
text,
reply_markup= _.languages_keyboard())
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: Missing return causes registration flow for registered users

The handle_start function checks if the user is already registered (is_registered == 1) and handles that case, but there's no return statement after line 40. This causes the code to continue executing lines 47-54, which sends the registration start message and sets the waiting_for_language state. Already-registered users will be incorrectly prompted to register again.

Fix in Cursor Fix in Web


await state.set(RegistrateUser.waiting_for_age)
text = _.translate("REG","prompts.ask_age", user_id=call.from_user.id)
await bot.send_message(call.from_user.id, text)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: Sex selection never saved causing incorrect user data

The handle_sex_selection function receives the user's sex choice in call.data but never saves it to state via state.add_data(sex=call.data). Later in handle_city_input, the code attempts to retrieve this value with data.get("sex") which returns None. The expression 1 if data.get("sex") == "male" else 0 will always evaluate to 0 since None == "male" is False, resulting in all users being recorded as female regardless of their selection.

Fix in Cursor Fix in Web

user_id,
text,
reply_markup=self.any_agree_keyboard(user_id)
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: Wrong translation key in rules agreement keyboard

The send_rules_agreement_keyboard method uses the translation key "choose_sex" on line 96, which is copy-pasted from the sex selection keyboard. This causes the rules agreement prompt to incorrectly display "Choose your sex:" text instead of a rules-related message. The key should likely be "show_rules_question" based on the available BUTTONS keys in the translator.

Fix in Cursor Fix in Web

current_dict: Any = Translated_Language.BUTTONS
try:
for k in keys:
current_dict = current_dict[k]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: Uninitialized variable causes crash on invalid dictionary name

The get_translation method only assigns current_dict when dict_ equals 'REG' or 'BUTT'. If any other value is passed, current_dict remains undefined, and the code will raise an UnboundLocalError when it attempts to iterate with for k in keys: current_dict = current_dict[k]. An else clause or default initialization is needed.

Fix in Cursor Fix in Web

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