some fixes when creating config
This commit is contained in:
parent
4e6101b5fc
commit
ddc70356d2
1 changed files with 6 additions and 3 deletions
9
ubot.py
9
ubot.py
|
@ -47,19 +47,20 @@ if is_termux:
|
||||||
# Название сессии
|
# Название сессии
|
||||||
sessdb = 'tl-ub'
|
sessdb = 'tl-ub'
|
||||||
default_config_file_path = 'config.json'
|
default_config_file_path = 'config.json'
|
||||||
|
treat_as_true = ('true', '1', 't', 'y', 'yes', 'yeah', 'yup', 'certainly', 'uh-huh')
|
||||||
if is_termux:
|
if is_termux:
|
||||||
default_directory = '/sdcard/ub4tg'
|
default_directory = '/sdcard/ub4tg'
|
||||||
os.system(f'mkdir -p {default_directory}')
|
os.system(f'mkdir -p {default_directory}')
|
||||||
default_config_file_path = f'{default_directory}/config.json'
|
default_config_file_path = f'{default_directory}/config.json'
|
||||||
if not os.path.exists(default_config_file_path):
|
if not os.path.exists(default_config_file_path):
|
||||||
logger.info('config not found, first launch setup...')
|
logger.info('config not found, first launch setup...')
|
||||||
api_id = input('enter api_id from https://my.telegram.org/ : ')
|
api_id = int(input('enter api_id from https://my.telegram.org/ : '))
|
||||||
api_hash = input('enter api_hash from https://my.telegram.org/ : ')
|
api_hash = input('enter api_hash from https://my.telegram.org/ : ')
|
||||||
timezone = input('enter timezone, format is Country/City: ')
|
timezone = input('enter timezone, format is Country/City: ')
|
||||||
db_pymysql = False
|
db_pymysql = False
|
||||||
db_sqlite3 = True
|
db_sqlite3 = True
|
||||||
a_h = input('enable automatic use medkit? [true/false]: ')
|
a_h = input('enable automatic use medkit? [y/n]: ').lower() in treat_as_true
|
||||||
a_404_patient = input('enable automatic bioeb if victim not found or expired? It will be trigger on "Жертва не найдена" [true/false]: ')
|
a_404_patient = input('enable automatic bioeb if victim not found or expired? It will be trigger on "Жертва не найдена" [y/n]: ').lower() in treat_as_true
|
||||||
new_config = {'api_id': api_id,
|
new_config = {'api_id': api_id,
|
||||||
'api_hash': api_hash,
|
'api_hash': api_hash,
|
||||||
'timezone': timezone,
|
'timezone': timezone,
|
||||||
|
@ -159,6 +160,7 @@ async def main():
|
||||||
con.commit()
|
con.commit()
|
||||||
|
|
||||||
if db_sqlite3:
|
if db_sqlite3:
|
||||||
|
logger.debug('sqlite3 database connecting...')
|
||||||
if is_termux:
|
if is_termux:
|
||||||
conn = sqlite3.connect(f"{default_directory}/{my_id}.sqlite")
|
conn = sqlite3.connect(f"{default_directory}/{my_id}.sqlite")
|
||||||
else:
|
else:
|
||||||
|
@ -188,6 +190,7 @@ async def main():
|
||||||
reason VARCHAR
|
reason VARCHAR
|
||||||
)''')
|
)''')
|
||||||
conn.commit()
|
conn.commit()
|
||||||
|
logger.debug('sqlite3 database initialized')
|
||||||
|
|
||||||
####################################################################
|
####################################################################
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue