From 49dc76063e0e4f4b3dcf36d67cb0ba29d42c8317 Mon Sep 17 00:00:00 2001 From: Matt Theissen Date: Fri, 26 Aug 2022 02:23:31 -0500 Subject: [PATCH] Basic bot working. --- ddbank.py | 11 +++++++---- ddbot.py | 13 +++---------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/ddbank.py b/ddbank.py index c25545d..ef7dffb 100755 --- a/ddbank.py +++ b/ddbank.py @@ -188,7 +188,7 @@ def addUser(a): print() def startBot(a): - subprocess.Popen([sys.executable, 'ddbot.py'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + subprocess.Popen([sys.executable, "ddbot.py"], shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) def manageBankmenu(a): bankNam = a.split(".")[0] @@ -313,15 +313,18 @@ def delBank(): print() def telBot(): - f = open("ddbot_config.py","r") + os.system("touch config_ddbot.py") + f = open("config_ddbot.py","r") print(f.read()) f.close() botToken = input("Insert bot token: ( Leave blank to remain unchanged ) ") + listBank() if botToken != "": - f = open("ddbot_config.py", "w") + botBank = input("Which bank shall the bot use? ( Incorrect bank name will result in the bot not working. ) ") + f = open('config_ddbot.py', 'w') f.write(f"botToken = \"{botToken}\"") + f.write(f"\nbotBank = \"{botBank}\"") f.close() - def mainFunc(): print('Welcome to the Kniod D&D Banking Software! ') diff --git a/ddbot.py b/ddbot.py index 1a8a3a2..99a71f5 100755 --- a/ddbot.py +++ b/ddbot.py @@ -4,21 +4,14 @@ import telebot 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") +import config_ddbot as i -#ddusr = "sqlite3 bank1.db.sqlite 'select balance from balance1 where id = '1';'" -ddusr = "sqlite3 {arg1} 'select balance from balance1 where id = '1';'" +bank = i.botBank +ddusr = "sqlite3 " + bank + ".db.sqlite " + "'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.message_handler(commands=['ddbank']) def send_ddbank(message): bot.reply_to(message, ddamt)