Implement group duty pinning and user phone management

- Added functionality to pin duty messages in group chats, including scheduling updates and handling bot add/remove events.
- Introduced a new `GroupDutyPin` model to store pinned message details and a `phone` field in the `User` model for user contact information.
- Implemented commands for users to set or clear their phone numbers in private chats.
- Enhanced the repository with functions to manage group duty pins and user phone data.
- Updated handlers to register new commands and manage duty pin updates effectively.
This commit is contained in:
2026-02-18 01:00:31 +03:00
parent 5237262dea
commit 50347038e9
9 changed files with 495 additions and 7 deletions

11
main.py
View File

@@ -9,7 +9,7 @@ import urllib.request
import config
from telegram.ext import ApplicationBuilder
from handlers import register_handlers
from handlers import group_duty_pin, register_handlers
logging.basicConfig(
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
@@ -63,7 +63,12 @@ def _run_uvicorn(web_app, port: int) -> None:
def main() -> None:
# Menu button (Календарь) and inline Calendar button are disabled; users open the app by link if needed.
# _set_default_menu_button_webapp()
app = ApplicationBuilder().token(config.BOT_TOKEN).build()
app = (
ApplicationBuilder()
.token(config.BOT_TOKEN)
.post_init(group_duty_pin.restore_group_pin_jobs)
.build()
)
register_handlers(app)
from api.app import app as web_app
@@ -76,7 +81,7 @@ def main() -> None:
t.start()
logger.info("Bot starting (polling)... HTTP API on port %s", config.HTTP_PORT)
app.run_polling(allowed_updates=["message"])
app.run_polling(allowed_updates=["message", "my_chat_member"])
if __name__ == "__main__":