Ejemplo n.º 1
0
async def momify(client, message):
    engine = message.Engine
    owo = await edit_or_reply(message, engine.get_string("PROCESSING"))
    img = await convert_to_image(message, client)
    hmm = get_text(message)
    if not hmm:
        await owo.edit(engine.get_string("INPUT_REQ").format("Text"))
        returbn
    if not img:
        await owo.edit(
            engine.get_string("NEEDS_REPLY").format("a valid media first"))
        return
    if not os.path.exists(img):
        await owo.edit(engine.get_string("INVALID_MEDIA"))
        return
    if ";" in hmm:
        stark = hmm.split(";", 1)
        first_txt = stark[0]
        second_txt = stark[1]
        top_text = first_txt
        bottom_text = second_txt
        generate_meme(img, top_text=top_text, bottom_text=bottom_text)
    else:
        top_text = hmm
        bottom_text = ""
        generate_meme(img, top_text=top_text, bottom_text=bottom_text)
    imgpath = "memeimg.webp"
    if message.reply_to_message:
        await client.send_sticker(
            message.chat.id,
            sticker=imgpath,
            reply_to_message_id=message.reply_to_message.message_id,
        )
    else:
        await client.send_sticker(message.chat.id, sticker=imgpath)
    if os.path.exists(imgpath):
        os.remove(imgpath)
    await owo.delete()
Ejemplo n.º 2
0
async def momify(client, message):
    owo = await edit_or_reply(message, "`Making Memes! Look There, OwO`")
    img = await convert_to_image(message, client)
    hmm = get_text(message)
    if not hmm:
        await owo.edit("`Give Text :/`")
        returbn
    if not img:
        await owo.edit("`Reply to a valid media first.`")
        return
    if not os.path.exists(img):
        await owo.edit("`Invalid Media!`")
        return
    if ";" in hmm:
        stark = hmm.split(";", 1)
        first_txt = stark[0]
        second_txt = stark[1]
        top_text = first_txt
        bottom_text = second_txt
        generate_meme(img, top_text=top_text, bottom_text=bottom_text)
    else:
        top_text = hmm
        bottom_text = ""
        generate_meme(img, top_text=top_text, bottom_text=bottom_text)
    imgpath = "memeimg.webp"
    if message.reply_to_message:
        await client.send_sticker(
            message.chat.id,
            sticker=imgpath,
            reply_to_message_id=message.reply_to_message.message_id,
        )
    else:
        await client.send_sticker(message.chat.id, sticker=imgpath)
    if os.path.exists(imgpath):
        os.remove(imgpath)
    await owo.delete()