Skip to content
This repository has been archived by the owner on Jun 10, 2023. It is now read-only.

Commit

Permalink
Merge branch 'rewrite' of https://github.com/RealistikDash/GDPyS into…
Browse files Browse the repository at this point in the history
… rewrite
  • Loading branch information
RealistikDash committed Oct 23, 2020
2 parents 75fa082 + c73bf23 commit a7ba792
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 7 deletions.
6 changes: 5 additions & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
"default_priv": 30,
"cache_level_strs": True,
"lang": "en",
"gdpysbot_enabled": "true",
"gdpysbot_enabled": True,
"cheatless": {
"enabled": True,
"minimum_attempts_extreme_demon": 100,
},
}

user_config = {}
Expand Down
9 changes: 4 additions & 5 deletions helpers/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

client = gdpys.client


class GDPySBot(gdpys.Plugin):
def __init__(self):
super().__init__()

# @client.command()
# async def command(): # wtf do I do here
# pass
def send_message(self, accountid: int, subject: str, body: str):
pass # send message

gdpysbot = GDPySBot()

def setup():
return GDPySBot
return gdpysbot
53 changes: 53 additions & 0 deletions helpers/cheatless.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
from helpers.userhelper import user_helper
from helpers.levelhelper import level_helper
from config import user_config
from helpers.bot import gdpysbot

def CheatlessScoreCheck(score: dict) -> bool:
"""Runs a score validity verification."""
# score example
{
"accountid" : 1,
"levelid" : 222,
"percentage" : 100,
"attempts" : 10,
"coins" : 0
}
if user_config["cheatless"]["enabled"]:
if score["percentage"] > 100:
cheatless_ban(score["AccountID"], "invalid level score submission")
return False
elif score["percentage"] == 100:
print(f"Running score check on a score on the level {score['levelid']}")
level_data = level_helper.get_level_obj(score["levelid"])

if level_data == None:
cheatless_ban(score["AccountID"], "invalid level score submission")
return False

if score["coins"] > level_data[4]:
cheatless_ban(score["AccountID"], "unachievable coin count")
return False

if level_data[1] == 10 and level_data[2] == 6 and score["attempts"] < user_config["cheatless"]["minimum_attempts_extreme_demon"]:
cheatless_ban(score["AccountID"], "too quick demon completion")
return False

if score["attempts"] < 0 or score["coins"] > 3 or score["coins"] < 0:
cheatless_ban(score["accountid"], "invalid level score data")
return False

else:
if score["coins"] > 0:
cheatless_ban(score["AccountID"], "coins on uncompleted level")
return False

return True

def cheatless_ban(accountid: int, offence: str):
"""Initiates and official CheatlessAC ban!"""
print(f"User {accountid} has been banned by CheatlessAC for {offence}.") # TODO: add lang
gdpysbot.send_message(accountid, "[CheatlessAC] You have been banned!",
f"You have been by the Cheatless AntiCheat! The reason for your ban is {offence}. Please contact the staff team for more info."
)
#user_helper.ban_user(accountid, offence) # this function does not exist yet
11 changes: 10 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,14 @@ def start_plugins():
"." + plugin, "plugins"
).setup()()
).start()


def start_gdpysbot():
print("Starting GDPySBot")
Thread(
target=lambda: importlib.import_module(
".bot", "helpers"
).setup()
).start()

async def init(loop):
"""Initialises the app and MySQL connection and all the other systems."""
Expand All @@ -173,6 +180,8 @@ def main(debug=False):
logging_level = logging.DEBUG if user_config["debug"] else logging.INFO
if debug:
logging_level = logging.DEBUG
if user_config["gdpysbot_enabled"]:
start_gdpysbot()
logging.basicConfig(level=logging_level)
lang.load_langs(user_config["lang"])
start_plugins()
Expand Down

0 comments on commit a7ba792

Please sign in to comment.