« /home/rc

.pptx is cringe

20/11/2021

My Elements of Quantum Computing professor gave us .pptx slides.

me: cringe bro
me: ok np, libreoffice --headless --convert-to pdf:writer_pdf_Export slides.pptx to the rescue
always me: no way, I'm too lazy let's write a Telegram bot

the Telegram bot:

from telegram.ext import Filters, MessageHandler, Updater
import subprocess
import os

TELEGRAM_TOKEN = os.environ["TELEGRAM_TOKEN"]

def convert(file):
    cmd = f"libreoffice --headless --convert-to pdf:writer_pdf_Export {file} "
    process = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE)
    output, error = process.communicate()

def d(update, context):
    context.bot.get_file(update.message.document).download()
    with open("/tmp/slides.pptx", 'wb') as f:
        context.bot.get_file(update.message.document).download(out=f)

def main():
    u = Updater(TELEGRAM_TOKEN)
    u.dispatcher.add_handler(MessageHandler(Filters.document, d))
    u.start_polling()
    u.idle()

if __name__ == '__main__':
    main()

telegram api: telegram.error.BadRequest: File is too big
me: oh shit, how big this .pptx can be?

oh that big

Oh, it's that fuckin big!!!