Update Main.py

This commit is contained in:
Sarasayed0118 2024-04-07 05:18:18 +05:30 committed by GitHub
parent 1d5596cb28
commit 3d9cbd4e04
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,13 +1,13 @@
# Released under the MIT License. See LICENSE for details.
from .commands import NormalCommands
from .commands import Management
from .commands import Fun
from .commands import Cheats
from .commands import NewCmds
from .commands import CoinCmds
from chatHandle.ChatCommands.commands.Handlers import send
from chatHandle.ChatCommands.commands import NormalCommands as nc
from chatHandle.ChatCommands.commands import CoinCmds as cc
from chatHandle.ChatCommands.commands.Handlers import send, sendall
from .Handlers import clientid_to_accountid
from .Handlers import check_permissions
from chatHandle.chatFilter import ChatFilter
@ -15,12 +15,14 @@ from bastd.actor import popuptext
import ba
import _ba
import ba.internal
import set
import setting
from datetime import datetime
from playersData import pdata
from serverData import serverdata
settings = setting.get_settings_data()
tic = settings["CurrencyType"]["Currency"]
def return_role(accountid):
roles = pdata.get_roles()
@ -72,15 +74,16 @@ def Command(msg, clientid):
reply = '\ue049|| \ue00cCOMMAND ACCEPTED ADMIN\ue00c ||\ue049'
elif role == 'vip':
reply = '\ue049|| \ue00cCOMMAND ACCEPTED VIP\ue00c ||\ue049'
elif role == 'moderator':
elif role in ['moderator', 'mods', 'mod']:
reply = '\ue049|| \ue00cCOMMAND ACCEPTED MODERATOR\ue00c ||\ue049'
elif role == 'leadstaff':
elif role in ['leadstaff', 'lead-staff', 'leads']:
reply = '\ue049|| \ue00cCOMMAND ACCEPTED LEAD-STAFF\ue00c ||\ue049'
elif role == 'staff':
elif role in ['staff', 'cs', 'complaintstaff', 'complaint-staff']:
reply = '\ue049|| \ue00cCOMMAND ACCEPTED STAFF\ue00c ||\ue049'
else:
reply = '\ue043|| PLAYER COMMAND ACCEPTED ||\ue043'
reply = None
if command_type(command) == "Normal":
NormalCommands.ExcelCommand(command, arguments, clientid, accountid, ARGUMENTS)
@ -91,37 +94,81 @@ def Command(msg, clientid):
elif command_type(command) == "Manage":
if check_permissions(accountid, command):
Management.ExcelCommand(command, arguments, clientid, accountid)
_ba.screenmessage(reply, color=(0,1,0), transient=True)
if reply is not None:
_ba.screenmessage(reply, color=(0,1,0), transient=True)
else:
_ba.screenmessage(u"\ue049|| \ue00cCOMMAND NOT FOR KIDS\ue00c ||\ue049", color=(1, 0, 0), transient=True,
if command in set.availablecommands:
cost_of_command = set.availablecommands[command]
have_coins = nc.getcoins(accountid)
if have_coins >= cost_of_command:
Management.ExcelCommand(command, arguments, clientid, accountid)
cc.addcoins(accountid, cost_of_command * -1)
sendall(f"Success! /{command} cost you {tic}{cost_of_command}.")
else:
send(f"You need {tic}{cost_of_command} for that. You have {tic}{have_coins} only.", clientid)
else:
_ba.screenmessage(u"\ue049|| \ue00cCOMMAND NOT FOR KIDS\ue00c ||\ue049", color=(1, 0, 0), transient=True,
clients=[clientid])
elif command_type(command) == "Fun":
if check_permissions(accountid, command):
Fun.ExcelCommand(command, arguments, clientid, accountid)
_ba.screenmessage(reply, color=(0,1,0), transient=True)
if reply is not None:
_ba.screenmessage(reply, color=(0,1,0), transient=True)
else:
_ba.screenmessage(u"\ue049|| \ue00cCOMMAND NOT FOR KIDS\ue00c ||\ue049", color=(1, 0, 0), transient=True,
if command in set.availablecommands:
cost_of_command = set.availablecommands[command]
have_coins = nc.getcoins(accountid)
if have_coins >= cost_of_command:
Fun.ExcelCommand(command, arguments, clientid, accountid)
cc.addcoins(accountid, cost_of_command * -1)
sendall(f"Success! /{command} cost you {tic}{cost_of_command}.")
else:
send(f"You need {tic}{cost_of_command} for that. You have {tic}{have_coins} only.", clientid)
else:
_ba.screenmessage(u"\ue049|| \ue00cCOMMAND NOT FOR KIDS\ue00c ||\ue049", color=(1, 0, 0), transient=True,
clients=[clientid])
elif command_type(command) == "Cheats":
if check_permissions(accountid, command):
Cheats.ExcelCommand(command, arguments, clientid, accountid)
_ba.screenmessage(reply, color=(0,1,0), transient=True)
if reply is not None:
_ba.screenmessage(reply, color=(0,1,0), transient=True)
else:
_ba.screenmessage(u"\ue049|| \ue00cCOMMAND NOT FOR KIDS\ue00c ||\ue049", color=(1, 0, 0), transient=True,
if command in set.availablecommands:
cost_of_command = set.availablecommands[command]
have_coins = nc.getcoins(accountid)
if have_coins >= cost_of_command:
Cheats.ExcelCommand(command, arguments, clientid, accountid)
cc.addcoins(accountid, cost_of_command * -1)
sendall(f"Success! /{command} cost you {tic}{cost_of_command}.")
else:
send(f"You need {tic}{cost_of_command} for that. You have {tic}{have_coins} only.", clientid)
else:
_ba.screenmessage(u"\ue049|| \ue00cCOMMAND NOT FOR KIDS\ue00c ||\ue049", color=(1, 0, 0), transient=True,
clients=[clientid])
elif command_type(command) == "NewCmd":
if check_permissions(accountid, command):
NewCmds.NewCommands(command, arguments, clientid, accountid)
_ba.screenmessage(reply, color=(0,1,0), transient=True)
if reply is not None:
_ba.screenmessage(reply, color=(0,1,0), transient=True)
else:
_ba.screenmessage(u"\ue049|| \ue00cCOMMAND NOT FOR KIDS\ue00c ||\ue049", color=(1, 0, 0), transient=True,
clients=[clientid])
if command in set.availablecommands:
cost_of_command = set.availablecommands[command]
have_coins = nc.getcoins(accountid)
if have_coins >= cost_of_command:
NewCmds.NewCommands(command, arguments, clientid, accountid)
cc.addcoins(accountid, cost_of_command * -1)
sendall(f"Success! /{command} cost you {tic}{cost_of_command}.")
else:
send(f"You need {tic}{cost_of_command} for that. You have {tic}{have_coins} only.", clientid)
else:
_ba.screenmessage(u"\ue049|| \ue00cCOMMAND NOT FOR KIDS\ue00c ||\ue049", color=(1, 0, 0), transient=True,
clients=[clientid])
now = datetime.now()
if accountid in pdata.get_blacklist()["muted-ids"] and now < datetime.strptime(pdata.get_blacklist()["muted-ids"][accountid]["till"], "%Y-%m-%d %H:%M:%S"):
@ -134,7 +181,7 @@ def Command(msg, clientid):
prefixes = settings["CmdChatDisable"]["Commands"]
if any(msg.startswith(f"/{prefix}") for prefix in prefixes) and settings["CmdChatDisable"]["disable"]:
return None
elif msg.startswith("/comp") and not settings["compChatText"]:
elif msg.startswith("/comp") or msg.startswith("/complaint") and not settings["compChatText"]:
return None # Disable the "/comp" command if compChatText setting is False
elif settings["ChatCommands"]["BrodcastCommand"]:
return msg