diff --git a/ddbank.py b/ddbank.py index 6ce450a..c25545d 100755 --- a/ddbank.py +++ b/ddbank.py @@ -1,6 +1,8 @@ #!/usr/bin/env python3 import sqlite3 import os +import subprocess +import sys clear = lambda: os.system('clear') @@ -132,8 +134,6 @@ def manBankin(a): userBalance(a) elif userIn == "9": manageBankmenu(a) - elif userIn == "8": - mainFunc() else: print('*** Option not understood. Please try again.') @@ -187,6 +187,9 @@ def addUser(a): print(f"You are managing the {bankNam} bank. ") print() +def startBot(a): + subprocess.Popen([sys.executable, 'ddbot.py'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + def manageBankmenu(a): bankNam = a.split(".")[0] print() @@ -198,6 +201,7 @@ def manageBankmenu(a): 2. Delete a user. 3. List users. 4. Banking Menu. + 5. Start Bot. 9. Go Back. """) menuOption = input("Bank: Choose from the menu: ").lower() @@ -209,6 +213,8 @@ def manageBankmenu(a): listuser(a) elif menuOption == '4': manBankin(a) + elif menuOption == '5': + startBot(a) elif menuOption == '9': mainFunc() else: diff --git a/ddbot.py b/ddbot.py index b38900b..1a8a3a2 100755 --- a/ddbot.py +++ b/ddbot.py @@ -5,16 +5,19 @@ import subprocess import sys sys.path.append("ddbot_config") import ddbot_config as i +arg1 = (sys.argv)[1] +print(arg1) +#bot = telebot.TeleBot("5003942445:AAFnmFx0tJ32vpNrULYkkvcbglHDarQKKo8") -ddusr = "sqlite3 bank1.db.sqlite 'select balance from balance1 where id = '1';'" +#ddusr = "sqlite3 bank1.db.sqlite 'select balance from balance1 where id = '1';'" +ddusr = "sqlite3 {arg1} 'select balance from balance1 where id = '1';'" ddamt = str(subprocess.check_output(ddusr, shell=True))[2:-3] bot = telebot.TeleBot(i.botToken) -idusr = "sqlite3 bank1.db.sqlite 'select balance from balance1 where id = '1';'" -ddamt = str(subprocess.check_output(ddusr, shell=True))[2:-3] -bot = telebot.TeleBot("5003942445:AAFnmFx0tJ32vpNrULYkkvcbglHDarQKKo8") +#idusr = "sqlite3 bank1.db.sqlite 'select balance from balance1 where id = '1';'" +#ddamt = str(subprocess.check_output(ddusr, shell=True))[2:-3] @bot.message_handler(commands=['ddbank']) def send_ddbank(message):