posts devel

This commit is contained in:
2025-08-08 12:21:25 +09:00
parent 927da228c8
commit f1153a0bab
11 changed files with 309 additions and 0 deletions

21
bot/handlers/chats.py Normal file
View File

@@ -0,0 +1,21 @@
# bot/handlers/chats.py
from telegram import Update
from telegram.ext import ContextTypes
async def on_my_chat_member(update: Update, context: ContextTypes.DEFAULT_TYPE):
mcm = update.my_chat_member
if not mcm: return
chat = mcm.chat
# сохранить/обновить TgChat
from posts.models import TgChat
TgChat.objects.update_or_create(
chat_id=chat.id,
defaults=dict(
title=chat.title or "",
username=getattr(chat, "username", "") or "",
type=chat.type,
is_active=(mcm.new_chat_member.status in ("administrator","member"))
)
)