DEV Community

Cover image for Start chatting with Python on Telegram
Aahnik Daw
Aahnik Daw

Posted on

Start chatting with Python on Telegram

I made a bot that speaks Python. Don't believe it? Check it out on Telegram @runPython_bot.

This bot basically runs your Python code or evaluates a valid pythonic expression and returns the result.

For example, you say 'yo'*5 and the bot replies yoyoyoyoyo. Cool, isn't it?

Take a look at this gif.

gif

This bot has been built using python-telegram-bot the popular wrapper for Telegram's Bot API.

Check out the source code of this bot on GitHub. Stars ⭐ and Contributions 🔥 are most welcome.

GitHub logo aahnik / run-py-bot

A telegram bot that runs python code. Evaluate pythonic expressions on the go, right from your chat.

thumbnail

run-py-bot

Run python code from your telegram chat

GitHub license made-with-python telegram-chat badge-youtube

UPDATE I am no longer running this bot on my server. Please deploy your own instance to use.

Featured in 😍

  1. Tweet by Dev Community
  2. Tweet by The Python Dev
  3. Dor Moshe's Newsletter
  4. My YouTube Video Chatting with Python

Example Use 🔀

You may use pythonic expressions to easily calculate any complex problem. Or you may test your algorithms on the go.

demo

How to run 🤖

You can easily run your own instance of the bot.

You can run on any OS (windows/mac/linux). For better reliability, you may deploy to a VPS like Digital Ocean Droplet. You can even run on Android, using the Termux app.

Open your terminal and follow the instructions to run the bot.

Note: Use python 3.8

  • Make sure you have git, python and pip.

    # the following commands should not produce error
    git --version
    python
    Enter fullscreen mode Exit fullscreen mode

I don't want to write much. Explore the bot yourself.

And definitely try to make it do some hard work by giving it some long calculations or maybe try infinite loops.

You may access Python's docs through the bot by running the help() function.

For example: try giving help(str.upper).

If you are giving an expression to the bot like 4 <= 5 please use the /e command, like /e 4 <= 5.

Don't forget to rate this bot on BotsArchive

image

Why waiting? Try out the bot.

Share the bot in your telegram groups and channels.

And if you have any questions, you may ask in the comments below, or create an issue in the GitHub repo of this project.

Top comments (2)

Collapse
 
rulikkk profile image
Rustem Mustafin

Great work!

I think /e should be default mode, like repl

Collapse
 
aahnik profile image
Aahnik Daw

Would implement that soon. If you are on GitHub, contributions are welcome