From afa5772631041e084e32918568cb7a951967bcee Mon Sep 17 00:00:00 2001 From: Michael De Roover Date: Mon, 15 Mar 2021 00:55:20 +0100 Subject: [PATCH] Use environment variables for credentials --- readme.md | 4 ++++ ubot.py | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 6b494e6..234f184 100644 --- a/readme.md +++ b/readme.md @@ -4,6 +4,10 @@ This project contains the source code of my ([@ghnou](https://t.me/ghnou)'s) use In terms of functionality it will be not too dissimilar from Konata ([bot](https://t.me/konatasanbot), [source](https://git.ghnou.su/ghnou/konata)). Currently it is still a work in progress. +#### Credentials + +Visit [my.telegram.org](https://my.telegram.org/apps) to get your API ID and API hash values. These should then be passed into the system as environment variables `api_id` and `api_hash` respectively. A good place to put these would be the system's `/etc/environment` file. + #### License This project is released as "All rights reserved". You are allowed to study the code as inspiration to make your own userbot, but you are not allowed to copy it verbatim. diff --git a/ubot.py b/ubot.py index 70fcc17..6d66768 100644 --- a/ubot.py +++ b/ubot.py @@ -1,10 +1,11 @@ +import os from telethon import TelegramClient, events from telethon.tl.custom import Dialog from telethon.tl.types import Channel, User, Chat # Use your own values from my.telegram.org -api_id = 1234567 -api_hash = '1234567890abcdef' +api_id = os.environ['api_id'] +api_hash = os.environ['api_hash'] client = TelegramClient('ubot', api_id, api_hash) @client.on(events.NewMessage)