예제 #1
0
async def store_members(c: Alita, m: Message):
    sm = await m.reply_text(f"Updating Members...")

    lv = 0  # lv = local variable

    async for member in m.chat.iter_members():

        try:
            userdb.update_user(member.user.id, member.user.username, m.chat.id,
                               m.chat.title)
            lv += 1
        except:
            pass

    await sm.edit_text(f"Stored {lv} members")
    return
예제 #2
0
파일: dev.py 프로젝트: hyper-ub/Alita_Robot
async def store_members(c: Alita, m: Message):
    sm = await m.reply_text("Updating Members...")

    lv = 0  # lv = local variable

    try:
        async for member in m.chat.iter_members():
            try:
                userdb.update_user(member.user.id, member.user.username,
                                   m.chat.id, m.chat.title)
                lv += 1
            except Exception:
                pass
    except Exception:
        await c.send_message(chat_id=MESSAGE_DUMP,
                             text="Error while storing members!")
        return
    await sm.edit_text(f"Stored {lv} members")
    return
예제 #3
0
async def initial_works(c: Alita, m: Message):
    if m.migrate_to_chat_id or m.migrate_from_chat_id:
        if m.migrate_to_chat_id:
            old_chat = m.chat.id
            new_chat = m.migrate_to_chat_id
        elif m.migrate_from_chat_id:
            old_chat = m.migrate_from_chat_id
            new_chat = m.chat.id

        try:
            await migrate_chat(old_chat, new_chat)
        except Exception as ef:
            LOGGER.error(ef)
            return
    else:
        userdb.update_user(m.from_user.id, m.from_user.username, m.chat.id,
                           m.chat.title)
        if m.reply_to_message:
            userdb.update_user(
                m.reply_to_message.from_user.id,
                m.reply_to_message.from_user.username,
                m.chat.id,
                m.chat.title,
            )
        if m.forward_from:
            userdb.update_user(m.forward_from.id, m.forward_from.username)
    return
예제 #4
0
async def initial_works(_, m: Message):
    try:
        if m.migrate_to_chat_id or m.migrate_from_chat_id:
            if m.migrate_to_chat_id:
                old_chat = m.chat.id
                new_chat = m.migrate_to_chat_id
            elif m.migrate_from_chat_id:
                old_chat = m.migrate_from_chat_id
                new_chat = m.chat.id

            try:
                await migrate_chat(old_chat, new_chat)
            except RPCError as ef:
                LOGGER.error(ef)
                return
        else:
            userdb.update_user(
                m.from_user.id,
                m.from_user.username,
                m.chat.id,
                m.chat.title,
            )
            if m.reply_to_message:
                userdb.update_user(
                    m.reply_to_message.from_user.id,
                    m.reply_to_message.from_user.username,
                    m.chat.id,
                    m.chat.title,
                )
            if m.forward_from:
                userdb.update_user(m.forward_from.id, m.forward_from.username)
    except AttributeError:
        pass  # Skip attribute errors!
    return
예제 #5
0
파일: dev.py 프로젝트: Disegual/Alita_Robot
async def store_members(c: Alita, m: Message):
    sm = await m.reply_text("Updating Members...")

    lv = 0  # lv = local variable

    try:
        async for member in m.chat.iter_members():
            try:
                userdb.update_user(
                    member.user.id,
                    member.user.username,
                    m.chat.id,
                    m.chat.title,
                )
                lv += 1
            except BaseException:
                pass
        await sm.edit_text(f"Stored {lv} members in Database!")
    except BaseException as ef:
        await c.send_message(
            chat_id=MESSAGE_DUMP,
            text=f"Error while storing members! Error: <code>{ef}</code>",
        )
    return