TelegramGuard / modules /admin.py
ilang-ai
v1.0: TelegramGuard - AI-powered group guardian with I-Lang Prompt Spec
cc6f785
raw
history blame contribute delete
757 Bytes
import config
from modules.db import db_exec
async def is_admin(update, context):
try:
chat_id = update.effective_chat.id
user_id = update.effective_user.id
member = await context.bot.get_chat_member(chat_id, user_id)
return member.status in ("administrator", "creator")
except Exception:
return False
def is_bot_admin(user_id):
return config.ADMIN_USER_ID and user_id == config.ADMIN_USER_ID
async def register_group(chat_id, title):
async def _do(db):
await db.execute(
"INSERT INTO groups (chat_id, title) VALUES (?, ?) "
"ON CONFLICT(chat_id) DO UPDATE SET title=?",
(chat_id, title, title)
)
await db.commit()
await db_exec(_do)