-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/dev' into dev
# Conflicts: # tgpy/_core/eval_message.py
- Loading branch information
Showing
55 changed files
with
2,413 additions
and
1,008 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
**/__pycache__/ | ||
venv/ | ||
guide/site | ||
.idea/ | ||
/.github/ | ||
/data/ | ||
/guide/site | ||
/guide/.cache | ||
flake.lock | ||
flake.nix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
name: Bug report | ||
about: Create a report to help us improve | ||
title: '' | ||
labels: '' | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Describe the bug** | ||
A clear and concise description of what the bug is. | ||
|
||
**To Reproduce** | ||
Steps to reproduce the behavior: | ||
1. Go to '...' | ||
2. Click on '....' | ||
3. Scroll down to '....' | ||
4. See error | ||
|
||
**Expected behavior** | ||
A clear and concise description of what you expected to happen. | ||
|
||
**Screenshots** | ||
If applicable, add screenshots to help explain your problem. | ||
|
||
**Desktop (please complete the following information):** | ||
- OS: [e.g. iOS] | ||
- Browser [e.g. chrome, safari] | ||
- Version [e.g. 22] | ||
|
||
**Smartphone (please complete the following information):** | ||
- Device: [e.g. iPhone6] | ||
- OS: [e.g. iOS8.1] | ||
- Browser [e.g. stock browser, safari] | ||
- Version [e.g. 22] | ||
|
||
**Additional context** | ||
Add any other context about the problem here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
name: Feature request | ||
about: Suggest an idea for this project | ||
title: '' | ||
labels: '' | ||
assignees: '' | ||
|
||
--- | ||
|
||
**Is your feature request related to a problem? Please describe.** | ||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] | ||
|
||
**Describe the solution you'd like** | ||
A clear and concise description of what you want to happen. | ||
|
||
**Describe alternatives you've considered** | ||
A clear and concise description of any alternative solutions or features you've considered. | ||
|
||
**Additional context** | ||
Add any other context or screenshots about the feature request here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,4 @@ data/ | |
config.yaml | ||
|
||
guide/site | ||
guide/.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,84 +1,89 @@ | ||
<div align="center" style="width: 50%"> | ||
|
||
<h3> | ||
<a href="https://tgpy.tmat.me"> | ||
<img alt="TGPy Logo" src="guide/docs/assets/TGPy.png" width=280> | ||
</a> | ||
|
||
Runs Python code snippets<br>within your Telegram messages | ||
</h3> | ||
|
||
<h6></h6> | ||
|
||
# TGPy | ||
|
||
**Runs Python code snippets within your Telegram messages** | ||
|
||
[![PyPI - Downloads](https://img.shields.io/pypi/dm/tgpy?style=flat-square)](https://pypi.org/project/tgpy/) | ||
[![PyPI](https://img.shields.io/pypi/v/tgpy?style=flat-square&color=9B59B6)](https://pypi.org/project/tgpy/) | ||
[![Docker Image Version (latest semver)](https://img.shields.io/docker/v/tgpy/tgpy?style=flat-square&label=docker&sort=semver&color=9B59B6)](https://hub.docker.com/r/tgpy/tgpy) | ||
[![Open issues](https://img.shields.io/github/issues-raw/tm-a-t/TGPy?style=flat-square)](https://github.com/tm-a-t/TGPy/issues) | ||
[![Docs](https://img.shields.io/website?style=flat-square&label=docs&url=https%3A%2F%2Ftgpy.tmat.me)](https://tgpy.tmat.me/) | ||
|
||
</div> | ||
|
||
<br> | ||
|
||
Here are a few examples of how people use TGPy: | ||
|
||
🧮 Run Python as an in-chat calculator | ||
Guide: https://tgpy.tmat.me/guide | ||
|
||
🔍 Search for song lyrics within a chat | ||
Recipes: https://tgpy.tmat.me/recipes | ||
|
||
🧹 Delete multiple messages with a command | ||
Discussion: https://t.me/tgpy_flood | ||
|
||
📊 Find out the most active members in a chat | ||
<br> | ||
|
||
✏️ Instantly convert TeX to Unicode in messages:<br>For example, `x = \alpha^7` becomes `x = α⁷` | ||
https://user-images.githubusercontent.com/38432588/181266550-c4640ff1-71f2-4868-ab83-6ea3690c01b6.mp4 | ||
|
||
## About | ||
<br> | ||
|
||
TGPy allows you to easily write and execute code snippets directly within your Telegram messages. Combine Telegram features with the full power of Python: Integrate with libraries and APIs. Create functions and TGPy modules to reuse code in the future. Set up code transformers and hooks to create custom commands and tweak Python syntax. | ||
|
||
TGPy uses Telegram API through the [Telethon](https://github.com/LonamiWebs/Telethon) library. | ||
<!-- --8<-- [start:body] --> | ||
<!-- Starting from here, the content is shared between the readme file and the docs homepage --> | ||
|
||
## Quick Start | ||
|
||
Python 3.10+ required. Install TGPy and connect it to your Telegram account: | ||
Python 3.10+ required. Install using pipx: | ||
|
||
```shell | ||
> pip install tgpy | ||
> tgpy | ||
pipx install tgpy | ||
tgpy | ||
``` | ||
|
||
You’re ready now. Send Python code to any chat, and it will run. Change your message to change the result. [Read more on installation](http://tgpy.tmat.me/installation/) | ||
or Docker: | ||
|
||
## Learn | ||
```shell | ||
docker pull tgpy/tgpy | ||
docker run -it --rm -v /tgpy_data:/data tgpy/tgpy | ||
``` | ||
|
||
[🙂 Basics Guide](https://tgpy.tmat.me/basics/code/) | ||
Then follow instructions to connect your Telegram account. | ||
|
||
[😎 Extensibility Guide](https://tgpy.tmat.me/extensibility/context/) | ||
More on installation: [https://tgpy.tmat.me/installation](https://tgpy.tmat.me/installation) | ||
|
||
[📗 Reference](https://tgpy.tmat.me/reference/builtins/) | ||
Next, learn TGPy basics: [https://tgpy.tmat.me/basics](https://tgpy.tmat.me/basics) | ||
|
||
[💬 Russian-Speaking Chat](https://t.me/tgpy_flood) | ||
## Use Cases | ||
|
||
Here are a few examples of how people use TGPy: | ||
|
||
## Demo | ||
🧮 Run Python as an in-chat calculator | ||
|
||
https://user-images.githubusercontent.com/38432588/181266550-c4640ff1-71f2-4868-ab83-6ea3690c01b6.mp4 | ||
🔍 Search for song lyrics within a chat | ||
|
||
<br> | ||
🧹 Delete multiple messages with a command | ||
|
||
![A message processed with TGPy](guide/docs/assets/example.png) | ||
_Finding out the number of premium users in a chat_ | ||
📊 Find out the most active members in a chat | ||
|
||
## Inspiration | ||
✏️ Instantly convert TeX to Unicode in messages:<br>For example, `x = \alpha^7` becomes `x = α⁷` | ||
|
||
## About | ||
|
||
TGPy is inspired by [FTG](https://gitlab.com/friendly-telegram/friendly-telegram) and similar userbots. However, the key concept is different: TGPy is totally based on usage of code in Telegram rather than plugging extra modules. It was designed for running single-use scripts and reusing code flexibly. You can think of TGPy as a userbot for programmers. | ||
TGPy allows you to easily write and execute code snippets directly within your Telegram messages. Combine Telegram | ||
features with the full power of Python: Integrate with libraries and APIs. Create functions and TGPy modules to reuse | ||
code in the future. Set up code transformers and hooks to create custom commands and tweak Python syntax. | ||
|
||
## Credits | ||
TGPy uses Telegram API through the [Telethon](https://github.com/LonamiWebs/Telethon) library. | ||
|
||
TGPy is built on [Telethon](https://github.com/LonamiWebs/Telethon), a Python library to interact with Telegram API. | ||
## Inspiration and Credits | ||
|
||
TGPy is inspired by [FTG](https://gitlab.com/friendly-telegram/friendly-telegram) and similar userbots. However, the key | ||
concept is different: TGPy is totally based on usage of code in Telegram rather than plugging extra modules. It was | ||
designed for running single-use scripts and reusing code flexibly. You can think of TGPy as **a userbot for programmers | ||
**. | ||
|
||
We built TGPy with [Telethon](https://github.com/LonamiWebs/Telethon), a Python library to interact with Telegram API. | ||
Basic code transformation (such as auto-return of values) is based on [meval](https://github.com/penn5/meval). | ||
|
||
TGPy Docs use [Material for MKDocs](https://squidfunk.github.io/mkdocs-material/) with custom CSS. | ||
|
||
## License | ||
|
||
This project is licensed under the terms of the MIT license. | ||
|
||
<!-- --8<-- [end:body] --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import logging | ||
from subprocess import Popen | ||
|
||
from tgpy.api.config import config | ||
|
||
logging.basicConfig( | ||
format='[%(asctime)s] [%(name)s] [%(levelname)s] %(message)s', | ||
datefmt='%Y-%m-%d %H:%M:%S', | ||
level=logging.INFO, | ||
) | ||
logger = logging.getLogger('install_mods') | ||
|
||
|
||
def main(): | ||
config.load() | ||
command_groups: dict = config.get('docker.setup_commands', {}) | ||
command_groups['_core'] = 'apt-get update' | ||
for name, commands in sorted(command_groups.items()): | ||
if isinstance(commands, str): | ||
commands = [commands] | ||
logger.info(f"Running setup command group '{name}'") | ||
for command in commands: | ||
logger.info(f"Running setup command '{command}'") | ||
p = Popen(command, shell=True) | ||
p.wait() | ||
if p.returncode != 0: | ||
logger.info("Running setup command failed") | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
if [ ! -f container_setup_completed ]; then | ||
PYTHONPATH=. python /app/docker/install_mods.py | ||
touch container_setup_completed | ||
fi | ||
|
||
exec python -m tgpy |
Oops, something went wrong.