Skip to content

Commit 3ce63bc

Browse files
Added .env option for adding variables
1 parent 6d70f50 commit 3ce63bc

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ A telegram bot, which can forward messages from channel, group or chat to anothe
55
[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy)
66

77
### Configuration
8-
To configure this bot add the environment variables stated below.
8+
To configure this bot add the environment variables stated below. Or add them in [config.env.template](./config.env.template) and change the name to `config.env`.
99
- `API_ID` - Get it by creating an app on [https://my.telegram.org](https://my.telegram.org)
1010
- `API_HASH` - Get it by creating an app on [https://my.telegram.org](https://my.telegram.org)
1111
- `BOT_TOKEN` - Get it by creating a bot on [https://t.me/BotFather](https://t.me/BotFather)

config.env.template

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Change File Name to config.env
2+
3+
API_ID = ""
4+
API_HASH = ""
5+
BOT_TOKEN = ""
6+
TO_CHATS = ""
7+
FROM_CHATS = ""
8+
ADVANCE_CONFIG = ""
9+
TELEGRAM_SESSION = ""

main.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
import os
12
from os import environ
3+
from dotenv import load_dotenv
24
from pyrogram import Client, filters
35

6+
if os.path.exists('config.env'):
7+
load_dotenv('config.env')
8+
49
api_id = int(environ["API_ID"])
510
api_hash = environ["API_HASH"]
611
bot_token = environ["BOT_TOKEN"]

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
pyrogram
22
TgCrypto
3+
python-dotenv>=0.10

0 commit comments

Comments
 (0)