Convert DOC or DOCX using a Telegram Bot
If you want to run this bot locally on your machine you only have to install the requirements, edit Secrets.py with your token and run:
python bot.py
Then, go to Telegram and start it with the /start
command.
This code needs:
- LibreOffice
- Linux (Althought can be ported easily to Windows or MacOs)
- Python
You can install the necessary python dependencies by moving to the project directory and running:
pip install -r requirements.txt
I deployed this script in Heroku. For the deployment using Heroku is necessary to create some files:
- Create a file named
Procfile
with the following content:
worker: python Bot.py
- An
Aptfile
with the following content:
libreoffice
libxfixes3
libxinerama-dev
libxinerama1
libxdamage1
libglu1-mesa:i386
- You will need Java for LibreOffice, so create a dummy
pom.xml
like the following:
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.dummy</groupId>
<artifactId>dummy</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
</project>
- Create an app on Heroku, using CLI or Dashboard.
- Add the buildpacks:
heroku/java
https://github.com/heroku/heroku-buildpack-apt.git
heroku/python
- LibreOffice will give you an issue with
libGL.so.1
, so you must run the following command:
ln -s ~/.apt/usr/lib/x86_64-linux-gnu/mesa/libGL.so.1 ~/.apt/usr/lib/x86_64-linux-gnu/
You can make it run by forking and editing https://github.com/heroku/heroku-buildpack-apt.git or adding the following line (at main) to the Bot.py:
subprocess.call("""ln -s ~/.apt/usr/lib/x86_64-linux-gnu/mesa/libGL.so.1 ~/.apt/usr/lib/x86_64-linux-gnu/""", shell=True)
- Now you can finally deploy your app and scale your dyno!
heroku ps:scale worker=1
Feel free to contribute to this repository, but first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.
- Alejandro Fuster - AlejandroFuster
This project is licensed under the MIT License - see the LICENSE file for details