Skip to content

Commit

Permalink
feat: support proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
vanutp committed Dec 5, 2023
1 parent d9910d7 commit cd6bc90
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 1 deletion.
19 changes: 19 additions & 0 deletions guide/docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,22 @@ Instructions are coming.
Config, session, and modules are stored in `~/.config/tgpy` directory (unless you’re using Docker.)
You can change this path via `TGPY_DATA` environment variable.
## Using proxy
If you require proxy to connect to Telegram, do the following:
1. Launch TGPy and provide api_id and api_hash, then quit.
2. Open `config.yml` file (see Data storage above) and add your proxy settings here:
```yaml
core:
api_hash: ...
api_id: ...
proxy:
proxy_type: socks5
addr: ...
port: ...
username: ...
password: ...
```
3. Run TGPy normally
35 changes: 34 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ rich = "^12.5.1"
appdirs = "^1.4.4"
telethon-v1-24 = "^1.24.12"
cryptg-anyos = "^0.4.1"
python-socks = {extras = ["asyncio"], version = "^2.4.3"}

[tool.poetry.dev-dependencies]
python-semantic-release = "^7.31.2"
Expand Down
1 change: 1 addition & 0 deletions tgpy/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def create_client():
system_version=platform.platform(),
lang_code='en',
system_lang_code='en-US',
proxy=config.get('core.proxy', None),
)
client.parse_mode = 'html'
return client
Expand Down

0 comments on commit cd6bc90

Please sign in to comment.