Separate credentials from code

This commit is contained in:
lzzy12 2019-09-17 16:27:06 +05:30
parent 5da3f5139e
commit 44fff43553
3 changed files with 17 additions and 1 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*config.env

11
bot.py
View File

@ -2,11 +2,20 @@ from telegram.ext import Updater,CommandHandler,run_async
import ariaTools
import logging
import gdriveTools
import ConfigParser
config = ConfigParser.ConfigParser()
config.read('config.env')
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level=logging.INFO)
if (getConfig('_____REMOVE_THIS_LINE_____')):
logging.ERROR('The README.md file there to be read! Exiting now!')
def getConfig(var: str):
return config.get('BOT', var)
@run_async
def start(update, context):
@ -29,7 +38,7 @@ def mirror(update,context):
def main():
BOT_TOKEN = "976868081:AAEO--j0dqomyy0ZOYD0sSIGim4UHTYQg5E"
BOT_TOKEN = getConfig('BOT_TOKEN')
updater = Updater(token=BOT_TOKEN, use_context=True)
start_handler = CommandHandler('start', start)

6
config_sample.env Normal file
View File

@ -0,0 +1,6 @@
#Remove this line before deploying
_____REMOVE_THIS_LINE_____=True
[BOT]
# ENTER BOT TOKEN( Get it from https://my.telegram.org)
BOT_TOKEN=""