File size: 757 Bytes
cc6f785
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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)