posts devel
This commit is contained in:
21
bot/handlers/chats.py
Normal file
21
bot/handlers/chats.py
Normal 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"))
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user