Use a config file for credentials
This commit is contained in:
parent
7fd51b127d
commit
90c018165f
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
config.py
|
17
install
Executable file
17
install
Executable file
@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Functions
|
||||||
|
mkconfig(){
|
||||||
|
echo "Please get your credentials from https://my.telegram.org."
|
||||||
|
read -p "App API ID (api_id): " api_id
|
||||||
|
read -p "App API hash (api_hash): " api_hash
|
||||||
|
echo "api_id = $api_id" >> config.py
|
||||||
|
echo "api_hash = '$api_hash'" >> config.py
|
||||||
|
}
|
||||||
|
|
||||||
|
# Preliminary sanity checks
|
||||||
|
[ ! -f ubot.py ] && echo "ubot.py not found, quitting." && exit 1
|
||||||
|
[ $0 != ./install ] && echo "Not launched from current directory." && exit 1
|
||||||
|
[ ! -f config.py ] && mkconfig
|
||||||
|
|
||||||
|
return 0
|
4
ubot.py
4
ubot.py
@ -1,10 +1,8 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
import os
|
import os
|
||||||
from telethon import TelegramClient, events
|
from telethon import TelegramClient, events
|
||||||
|
from config import *
|
||||||
|
|
||||||
# Use your own values from my.telegram.org
|
|
||||||
api_id = os.environ['api_id']
|
|
||||||
api_hash = os.environ['api_hash']
|
|
||||||
client = TelegramClient('ubot', api_id, api_hash)
|
client = TelegramClient('ubot', api_id, api_hash)
|
||||||
|
|
||||||
@client.on(events.NewMessage)
|
@client.on(events.NewMessage)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user