Userbot for telegram than runs Python code, made with Telethon.
It uses Python3.7 to work.
pip install -U -r requirements.txt
You will also need to have imagemagick
installed in your O.S.
If you get:
pygments.formatters.img.FontNotFound: No usable fonts named: "Bitstream Vera Sans Mono"
You will need to add that font to your O.S. too.
Run it with:
python bot/userbot.py
When you have your userbot running, simply send python code in a message
using the command !!py
, for example:
!!py print("Hello world")
and it would reply to your message with the result of running the code.
You can send the img
parameter to the command if you want to have
a nice syntax highlighted image of the code, example:
!!py img print("Hello world")
and you will get:
The bot creates a raw code.py
file with the code you send to it in
your message, and runs it invoking the Python interpreter, so be careful
with the code you send, don't wipe your system!
- Use
pygments
inside the code to avoid calling it withsubprocess
.