Basic bot working.

master
Matt Theissen 3 years ago
parent 14cf5f433a
commit 49dc76063e

@ -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,16 +313,19 @@ 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! ')
while True:

@ -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)