Skip to content
Permalink
Browse files
Added automatic library installation
  • Loading branch information
hollan84 committed May 3, 2020
1 parent d032b0e commit 4e190f553e9ff930a5d69babdcb71cd6728d010d
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 6 deletions.
BIN +0 Bytes (100%) __pycache__/bot.cpython-36.pyc
Binary file not shown.
Binary file not shown.
BIN +36 Bytes (100%) __pycache__/setup.cpython-36.pyc
Binary file not shown.
@@ -0,0 +1,5 @@
def configure():



configure()
@@ -0,0 +1,23 @@
def checkLibraries():

import getpass
import os

try:
os.system("pip3 -V")
except:
os.system("sudo apt install python3-pip")
try:
import discord
except:
try:
os.system("python3 -m pip install -U discord.py")
except:
os.system("py3 -m pip install -U discord.py")
try:
import mcstatus
except:
os.system("pip3 install mcstatus")
os.system("pip3 install status")

checkLibraries()
5 run.py
@@ -1,11 +1,16 @@
def run():

import librarySetup
librarySetup.checkLibraries()

import setup
import bot
import online
import os


if not os.path.isfile('.env'):
setup.environment()

os.system("python3 bot.py")
run()
@@ -1,24 +1,24 @@
def environment():
import os.path

'''Checks to see if there is an environment file'''
if os.path.isfile('.env'):
'''Prevents overwriting of the environment file'''
if os.path.isfile('.env'): #Checks to see if there is an environment file
overwrite = input("Would you like to overwrite your current credentials? (y/n)")
overwrite = overwrite.lower()
overwrite = overwrite.lower() #Makes the input string lowercase
if overwrite == "y" or overwrite == "yes":
print("Creating new credientials... \n")
else:
return
return #Exit function

'''Gets information'''
token = input("Input your bot token here > ")
serverIP = input("Input your server URL/IP here > ")
port = input("Input your bot port here (If you don't know it, leave blank) > ")
if port == "":
port = "25565"
port = "25565" #Default Minecraft server port

'''Concantinate into a string'''
data = "TOKEN={}\nSERVER={}\nPORT={}".format(token,serverIP,port)
data = "TOKEN={}\nSERVER={}\nPORT={}".format(token,serverIP,port) #Sets the format of the data

'''Write data to the .env file'''
creds = open(".env", "w")
@@ -35,6 +35,7 @@ def environment():
return
else:
tryAgain = ("Error writing data. \n Try again? (y/n) > ")
tryAgain = tryAgain.lower() #Makes the input string lowercase
if tryAgain == "y" or tryAgain == "yes":
environment()
else:

0 comments on commit 4e190f5

Please sign in to comment.