示例#1
0
async def lydia_disable_enable(event):
    if event.fwd_from:
        return
    if Var.LYDIA_API_KEY is None:
        await event.edit("Please add required `LYDIA_API_KEY` env var")
        return
    if event.reply_to_msg_id is not None:
        input_str = event.pattern_match.group(1)
        reply_msg = await event.get_reply_message()
        user_id = reply_msg.from_id
        chat_id = event.chat_id
        await event.edit("Processing...")
        if input_str == "en":
            # Create a new chat session (Like a conversation)
            session = lydia.create_session()
            logger.info(session)
            # logger.info("Session ID: {0}".format(session.id))
            # logger.info("Session Available: {0}".format(str(session.available)))
            # logger.info("Session Language: {0}".format(str(session.language)))
            # logger.info("Session Expires: {0}".format(str(session.expires)))
            logger.info(add_s(user_id, chat_id, session.id, session.expires))
            await event.edit(f"Hello")
        elif input_str == "re":
            logger.info(remove_s(user_id, chat_id))
            await event.edit(f"[__signal lost__](tg://user?id={user_id})")
        elif input_str == "li":
            lsts = get_all_s()
            if len(lsts) > 0:
                output_str = "AI enabled users:\n\n"
                for lydia_ai in lsts:
                    output_str += f"[User](tg://user?id={lydia_ai.user_id}) in chat `{lydia_ai.chat_id}`\n"
            else:
                output_str = "No Lydia AI enabled users / chats. Start by replying `.enai` to any user in any chat!"
            if len(output_str) > Config.MAX_MESSAGE_SIZE_LIMIT:
                with io.BytesIO(str.encode(output_str)) as out_file:
                    out_file.name = "lydia_ai.text"
                    await event.client.send_file(
                        event.chat_id,
                        out_file,
                        force_document=True,
                        allow_cache=False,
                        caption="Lydia AI enabled users",
                        reply_to=event,
                    )
            else:
                await event.edit(output_str)
        else:
            await event.edit(
                "Reply To User Message to Add / Delete them from Lydia Auto-Chat."
            )
    else:
        await event.edit(
            "Reply To A User's Message to Add / Delete them from Lydia Auto-Chat."
        )
示例#2
0
async def lydia_disable_enable(event):
    if event.fwd_from:
        return
    if Var.LYDIA_API_KEY is None:
        await event.edit("Lütfen gerekli `LYDIA_API_KEY` ekleyin")
        return
    if event.reply_to_msg_id is not None:
        input_str = event.pattern_match.group(1)
        reply_msg = await event.get_reply_message()
        user_id = reply_msg.from_id
        chat_id = event.chat_id
        await event.edit("İşleniyor...")
        if input_str == "tr":
            # Create a new chat session (Like a conversation)
            session = lydia.create_session()
            logger.info(session)
            # logger.info("Session ID: {0}".format(session.id))
            # logger.info("Session Available: {0}".format(str(session.available)))
            # logger.info("Session Language: {0}".format(str(session.language)))
            # logger.info("Session Expires: {0}".format(str(session.expires)))
            logger.info(add_s(user_id, chat_id, session.id, session.expires))
            await event.edit(f"Selam")
        elif input_str == "re":
            logger.info(remove_s(user_id, chat_id))
            await event.edit(f"[__Kayıp sinyal__](tg://user?id={user_id})")
        elif input_str == "li":
            lsts = get_all_s()
            if len(lsts) > 0:
                output_str = "AI etkin kullanıcılar:\n\n"
                for lydia_ai in lsts:
                    output_str += f"[User](tg://user?id={lydia_ai.user_id}) konuşmada `{lydia_ai.chat_id}`\n"
            else:
                output_str = "Lydia AI etkin kullanıcı / sohbet yok. Herhangi bir sohbette herhangi bir kullanıcıya `.enai` yazarak başlayın!"
            if len(output_str) > Config.MAX_MESSAGE_SIZE_LIMIT:
                with io.BytesIO(str.encode(output_str)) as out_file:
                    out_file.name = "lydia_ai.text"
                    await event.client.send_file(
                        event.chat_id,
                        out_file,
                        force_document=True,
                        allow_cache=False,
                        caption="Lydia AI özellikli kullanıcılar",
                        reply_to=event
                    )
            else:
                await event.edit(output_str)
        else:
            await event.edit("Lydia Otomatik Sohbetinden Eklemek / Silmek için Kullanıcı Mesajını Yanıtlayın.")
    else:
        await event.edit("Lydia Otomatik Sohbetinden Eklemek / Silmek İçin Bir Kullanıcının Mesajını Yanıtlayın.")
示例#3
0
async def lydia_disable_enable(event):
    if event.fwd_from:
        return
    if Config.LYDIA_API_KEY is None:
        await edit_delete(event, "`Please add required LYDIA_API_KEY env var`",
                          10)
        return
    catevent = await edit_or_reply(event, "`.....`")
    input_str = event.pattern_match.group(1)
    if event.reply_to_msg_id is not None:
        reply_msg = await event.get_reply_message()
        user_id = reply_msg.sender_id
        chat_id = event.chat_id
        if input_str == "en":
            # Create a new chat session (Like a conversation)
            session = lydia.create_session()
            if BOTLOG:
                await event.client.send_message(
                    BOTLOG_CHATID,
                    f"**Session ID: **`{session.id}`\
                                   \n**Session Available: **`{str(session.available)}`\
                                   \n**Session Language: **`{str(session.language)}`\
                                   \n**Session Expires : **`{datetime.fromtimestamp(session.expires).strftime('%Y-%m-%d %H:%M:%S')}`\
                    ",
                )
            add_s(user_id, chat_id, session.id, session.expires)
            await catevent.edit(f"Hello")
        elif input_str == "re":
            remove_s(user_id, chat_id)
            await catevent.edit(f"__[signal lost](tg://user?id={user_id})__")
        else:
            lsts = get_all_s()
            if len(lsts) > 0:
                output_str = "AI enabled users:\n\n"
                for lydia_ai in lsts:
                    output_str += f"[User](tg://user?id={lydia_ai.user_id}) in chat `{lydia_ai.chat_id}`\n"
            else:
                output_str = "No Lydia AI enabled users / chats. Start by replying `.enai` to any user in any chat!"
            if len(output_str) > Config.MAX_MESSAGE_SIZE_LIMIT:
                with io.BytesIO(str.encode(output_str)) as out_file:
                    out_file.name = "lydia_ai.text"
                    await event.client.send_file(
                        event.chat_id,
                        out_file,
                        force_document=True,
                        allow_cache=False,
                        caption="Lydia AI enabled users",
                        reply_to=event,
                    )
            else:
                await catevent.edit(output_str)
    else:
        if input_str == "li":
            lsts = get_all_s()
            if len(lsts) > 0:
                output_str = "AI enabled users:\n\n"
                for lydia_ai in lsts:
                    output_str += f"[User](tg://user?id={lydia_ai.user_id}) in chat `{lydia_ai.chat_id}`\n"
            else:
                output_str = "No Lydia AI enabled users / chats. Start by replying `.enai` to any user in any chat!"
            if len(output_str) > Config.MAX_MESSAGE_SIZE_LIMIT:
                with io.BytesIO(str.encode(output_str)) as out_file:
                    out_file.name = "lydia_ai.text"
                    await event.client.send_file(
                        event.chat_id,
                        out_file,
                        force_document=True,
                        allow_cache=False,
                        caption="Lydia AI enabled users",
                        reply_to=event,
                    )
            else:
                await catevent.edit(output_str)
        else:
            await edit_delete(
                catevent,
                "`Reply To A User's Message to Add / Remove them from Lydia Auto-Chat.`",
                5,
            )