mirror of
https://gitea.augustin64.fr/piair/MsRewards-Reborn.git
synced 2025-06-25 19:03:56 +02:00
Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
808916ddd3 | |||
c51c463338 | |||
a22d1e6ddb |
3
V5.py
3
V5.py
@ -930,6 +930,9 @@ elif UNBAN:
|
|||||||
elif POINTS_FILE != "":
|
elif POINTS_FILE != "":
|
||||||
save_points_from_file(POINTS_FILE)
|
save_points_from_file(POINTS_FILE)
|
||||||
else:
|
else:
|
||||||
|
if UPDATE_VERSION != "None":
|
||||||
|
if DISCORD_ENABLED_ERROR:
|
||||||
|
webhookFailure.send(f"Updated to {UPDATE_VERSION}")
|
||||||
for cred in Credentials:
|
for cred in Credentials:
|
||||||
_mail = cred[0]
|
_mail = cred[0]
|
||||||
_password = cred[1]
|
_password = cred[1]
|
||||||
|
64
database.py
64
database.py
@ -10,9 +10,16 @@ parser.add_argument(
|
|||||||
help="Choose a file",
|
help="Choose a file",
|
||||||
type=argparse.FileType('r')
|
type=argparse.FileType('r')
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"-m",
|
||||||
|
"--manual",
|
||||||
|
help="add point manually do database",
|
||||||
|
dest="manual",
|
||||||
|
action="store_true"
|
||||||
|
)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
MANUAL = args.manual
|
||||||
|
|
||||||
config_path = "./user_data/config.cfg"
|
config_path = "./user_data/config.cfg"
|
||||||
config = configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
@ -47,26 +54,39 @@ def ban_account(name: str, pts = 0):
|
|||||||
def update_pts(name: str, pts = 0):
|
def update_pts(name: str, pts = 0):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
if not MANUAL :
|
||||||
print("ajouter un compte : 1\nban un compte : 2")
|
print("ajouter un compte : 1\nban un compte : 2")
|
||||||
i = input()
|
i = input()
|
||||||
if i == "1":
|
if i == "1":
|
||||||
if args.file :
|
if args.file :
|
||||||
l =[x.split(",")[0].split("@")[0] for x in args.file.readlines()]
|
l =[x.split(",")[0].split("@")[0] for x in args.file.readlines()]
|
||||||
endroit = input("ou est le bot ? ")
|
endroit = input("ou est le bot ? ")
|
||||||
proprio = input("qui est le proprio ? ")
|
proprio = input("qui est le proprio ? ")
|
||||||
for name in l :
|
for name in l :
|
||||||
|
add_account(name, endroit, proprio)
|
||||||
|
else :
|
||||||
|
name = input("quel est le nom ? ").split("@")[0]
|
||||||
|
endroit = input("ou est le bot ? ")
|
||||||
|
proprio = input("qui est le proprio ? ")
|
||||||
add_account(name, endroit, proprio)
|
add_account(name, endroit, proprio)
|
||||||
else :
|
elif i == '2':
|
||||||
name = input("quel est le nom ? ").split("@")[0]
|
name = input("quel est le compte qui a été ban ? ")
|
||||||
endroit = input("ou est le bot ? ")
|
pts = input("il avait combien de points ? ")
|
||||||
proprio = input("qui est le proprio ? ")
|
ban_account(name, pts)
|
||||||
add_account(name, endroit, proprio)
|
|
||||||
elif i == '2':
|
|
||||||
name = input("quel est le compte qui a été ban ? ")
|
|
||||||
pts = input("il avait combien de points ? ")
|
|
||||||
ban_account(name, pts)
|
|
||||||
|
|
||||||
mydb.commit()
|
mydb.commit()
|
||||||
mycursor.close()
|
mycursor.close()
|
||||||
mydb.close()
|
mydb.close()
|
||||||
|
else :
|
||||||
|
import modules.db as datab
|
||||||
|
config_path = f"{path.abspath(path.dirname(path.dirname( __file__ )))}/MsRewards/user_data/config.cfg"
|
||||||
|
print(config_path)
|
||||||
|
config = configparser.ConfigParser()
|
||||||
|
config.read(config_path)
|
||||||
|
sql_usr = config["SQL"]["usr"]
|
||||||
|
sql_pwd = config["SQL"]["pwd"]
|
||||||
|
sql_host = config["SQL"]["host"]
|
||||||
|
sql_database = config["SQL"]["database"]
|
||||||
|
account_name = input("compte ? ")
|
||||||
|
points = int(input("points ? "))
|
||||||
|
datab.add_to_database(account_name, points, sql_host, sql_usr, sql_pwd, sql_database)
|
9
main.py
9
main.py
@ -154,31 +154,32 @@ def proxy() :
|
|||||||
edit_config_txt("port",port)
|
edit_config_txt("port",port)
|
||||||
|
|
||||||
|
|
||||||
def check_update():
|
def check_update(args):
|
||||||
try :
|
try :
|
||||||
latest = requests.get("https://api.github.com/repos/piair338/MsRewards/releases").json()[0]["tag_name"]
|
latest = requests.get("https://api.github.com/repos/piair338/MsRewards/releases").json()[0]["tag_name"]
|
||||||
latest = parse_version(latest)
|
latest = parse_version(latest)
|
||||||
except Exception as e :
|
except Exception as e :
|
||||||
print(e)
|
print(e)
|
||||||
return ()
|
return (args)
|
||||||
f = open("./version", 'r')
|
f = open("./version", 'r')
|
||||||
txt = f.readlines()[0].replace("\n","")
|
txt = f.readlines()[0].replace("\n","")
|
||||||
f.close()
|
f.close()
|
||||||
cur = parse_version(txt)
|
cur = parse_version(txt)
|
||||||
if not (cur < latest) :
|
if not (cur < latest) :
|
||||||
print("Already up to date.")
|
print("Already up to date.")
|
||||||
|
return(args)
|
||||||
else :
|
else :
|
||||||
print(f"updating to {latest}")
|
print(f"updating to {latest}")
|
||||||
os.system("git reset --hard")
|
os.system("git reset --hard")
|
||||||
os.system("git pull")
|
os.system("git pull")
|
||||||
os.system("python3 -m pip install -r requirements.txt > update.result")
|
os.system("python3 -m pip install -r requirements.txt > update.result")
|
||||||
print(f"updated to {latest}")
|
print(f"updated to {latest}")
|
||||||
|
return(args + f" --version {latest}")
|
||||||
|
|
||||||
LogPath = config["PATH"]["logpath"]
|
LogPath = config["PATH"]["logpath"]
|
||||||
if LogPath == "/your/path/to/loginandpass.csv" :
|
if LogPath == "/your/path/to/loginandpass.csv" :
|
||||||
setup()
|
setup()
|
||||||
else :
|
else :
|
||||||
args = " ".join(sys.argv[1::])
|
args = " ".join(sys.argv[1::])
|
||||||
check_update()
|
args = check_update(args)
|
||||||
os.system("python3 V5.py " + args)
|
os.system("python3 V5.py " + args)
|
||||||
|
@ -81,6 +81,12 @@ parser.add_argument(
|
|||||||
default="None"
|
default="None"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
"--updated",
|
||||||
|
help="display a message on discord to tell that the bot have been updated",
|
||||||
|
dest="update_version",
|
||||||
|
default="None"
|
||||||
|
)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
CUSTOM_START = args.override
|
CUSTOM_START = args.override
|
||||||
@ -93,7 +99,7 @@ if CUSTOM_START :
|
|||||||
VNC_ENABLED = args.vnc != "None"
|
VNC_ENABLED = args.vnc != "None"
|
||||||
VNC_PORT = args.vnc
|
VNC_PORT = args.vnc
|
||||||
POINTS_FILE = args.points_file
|
POINTS_FILE = args.points_file
|
||||||
|
UPDATE_VERSION = args.update_version
|
||||||
# global variables used later in the code
|
# global variables used later in the code
|
||||||
LINUX_HOST = platform == "linux" # if the computer running this program is Linux, it allow more things
|
LINUX_HOST = platform == "linux" # if the computer running this program is Linux, it allow more things
|
||||||
START_TIME = time()
|
START_TIME = time()
|
||||||
|
Reference in New Issue
Block a user