Skip to content
This repository was archived by the owner on Dec 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 131 additions & 2 deletions Scripts/Bots/runPython_bot/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,132 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

token.txt
__pycache__
*.pyc
venv
21 changes: 21 additions & 0 deletions Scripts/Bots/runPython_bot/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Aahnik Daw

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
11 changes: 0 additions & 11 deletions Scripts/Bots/runPython_bot/Makefile

This file was deleted.

55 changes: 24 additions & 31 deletions Scripts/Bots/runPython_bot/README.md
Original file line number Diff line number Diff line change
@@ -1,71 +1,64 @@
# runPython_bot
# run-py-bot

Run python code from your telegram chat !
Run python code from your telegram chat!

[![GitHub license](https://img.shields.io/github/license/aahnik/lovely-telegram)](https://github.com/aahnik/lovely-telegram/blob/main/LICENSE)
[![GitHub license](https://img.shields.io/github/license/aahnik/lovely-telegram)](https://github.com/aahnik/run-py-bot/blob/main/LICENSE)
[![made-with-python](https://img.shields.io/badge/Made%20with-Python-1f425f.svg)](https://www.python.org/)
[![Maintenance Yes](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://gitHub.com/aahnik/REPO/graphs/commit-activity)

![RunPythonBot](https://user-images.githubusercontent.com/66209958/97750350-9d773d80-1b16-11eb-89a5-7626f5547a10.png)
![RunPythonBot](https://github.com/aahnik/run-py-bot/blob/main/docs/images/runPython_bot.png?raw=true)

<!-- A simple bot that runs python code. Free and Open Source. For more info visit http://bit.ly/runPython -->

## Find on Telegram
## 🕵️ Find on Telegram

You can find this bot on Telegram: click on this [link](https://t.me/@runPython_bot) or search `@runPython_bot` on telegram. The spelling is case sensitive.
You can find this bot on Telegram as [@runPython_bot](https://telegram.me/runPython_bot).

This bot is deployed on [Python Anywhere](https://www.pythonanywhere.com/) free Beginner Account.
You may check whether the bot is alive or not, by clicking on the start command. If the bot responds, it is alive.

## Example Use
## 💬 Example Use

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

> If you are viewing from a smartphone, click on the gif to view full screen ...

![runPython_bot](https://user-images.githubusercontent.com/66209958/97753037-1e383880-1b1b-11eb-863e-bcf82006820b.gif)
![runPython_bot](https://github.com/aahnik/run-py-bot/blob/main/docs/images/runPython_bot_gif.gif?raw=true)

## Deploy
## Deploy

You can easily *deploy this bot* on [Python Anywhere](https://www.pythonanywhere.com/) or your **local machine** by following the below steps:

> Note: While pasting on your machine terminal you should use `Ctrl+Shift+V` but make sure to use `Ctrl+V` to paste in the Python Anywhere bash console from the browser.

Create a free Python Anywhere account and open a Bash Console, which has everything pre-loaded.

If you are planning to deploy on your **own machine**, make sure to have `Python3+`, `pip`, and `make`.
If you are planning to deploy on your **own machine**, make sure to have `Python3+`, `pip`.

The following instructions will work smoothly on *Linux* and *Mac*. If you are on Windows, you may have to make slight modifications. Google is your best friend here.

- Create a `projects` directory and move into it
- Clone this repository and move into it.

mkdir projects && cd projects

- Clone this repository containing the collection of bots

git clone https://github.com/aahnik/lovely-telegram.git

- Delete all other folders except the folder containing this bot

find ./lovely-telegram -mindepth 1 ! -regex '^./lovely-telegram/runPython_bot\(/.*\)?' -delete

- Now move into the directory which contains this README file, you are reading now.

cd lovely-telegram/runPython_bot
git clone https://github.com/aahnik/run-py-bot.git && cd run-py-bot

- Now add the token in the first line of `token.txt`.Run `cat > token.txt` -> Paste the token -> Press `Ctrl+D`

- To install all dependencies. Simply run `make requirements`
- Create a virtual environment and install dependencies.

python3.8 -m venv venv && source venv/bin/activate
python3.8 -m pip install -r requirements.txt

- Activate the bot by running `make start`
- Activate the bot by running `python3.8 start.py`

- You may now close the Python Anywhere bash console window from your browser, but the bot will continue running.

Your bot is now up and running, Enjoy ! 😊

To stop the bot, Press `Ctrl+C`. To restart the bot run `make start`
All the logs will have the timestamp in the time-zone specified in the `start.py` file.

To stop the bot, press `Ctrl+C`. You may update the code running in your server by `git fetch && git pull`.

## Limitations
## 😑 Limitations

Currently, the bot is deployed on a Free Tier account of Python Anywhere.

Expand All @@ -74,11 +67,11 @@ For security and performance reasons, you **cannot** do the following with the b
- import any package
- run the `input()` function
- run the `open()` function
- Execute a piece of code which takes longer than 30 seconds to execute.
- Execute a piece of code which takes longer than *6 seconds* to execute.

You may overcome these limitations by tweaking the code a little bit and running the bot on your own server.
You may overcome these limitations by changing the `config.py` file in the `bot` subdirectory and running the bot on your own server.

## The Shameless Plug
## 🤗 The Shameless Plug

Authored by **Aahnik Daw**.

Expand Down
15 changes: 15 additions & 0 deletions Scripts/Bots/runPython_bot/bot/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'''
Configs for the bot
'''

# expressions which are banned
banned = ['quit', 'input', 'open', 'import', 'exit']

# timeout in seconds
TIMEOUT = 6

timeout_message = f'''😢 Timeout of {TIMEOUT} reached.
I have limited resources.
You may increase the timeout and run this bot on your own server if required.'''

restricted_message = f'☹️ SECURITY ISSUE:\nYou have used a restricted word \n{banned}'
Loading