diff --git a/dist/ba_root/mods/chatHandle/chatCMDS/chatcmd.py b/dist/ba_root/mods/chatHandle/chatCMDS/chatcmd.py index e69de29..0be0f4c 100644 --- a/dist/ba_root/mods/chatHandle/chatCMDS/chatcmd.py +++ b/dist/ba_root/mods/chatHandle/chatCMDS/chatcmd.py @@ -0,0 +1,44 @@ +# Released under the MIT License. See LICENSE for details. + +import ba +import _ba +from playersData import pdata +import fun,management +import setting +def public_id(client_id): + rost=_ba.get_game_roster() + for client in rost: + if client['client_id']==client_id: + return client['account_id'] + return None + +def check_permission(pbid,cmnd): + roles=pdata.roles() + for role in roles: + if pbid in role.ids and cmnd in role.commands: + return True + return False + +def cmd_type(cmnd): + if cmnd in fun.cmnds: + return "fun" + if cmnd in management.cmnds: + return "management" + +def cmd(msg,client_id): + cmnd=msg.split(" ")[0].lower() + arg=msg.split(" ")[1:] + pbid=public_id(client_id) + if check_permission(pbid,cmnd): + if cmd_type(cmnd)=="fun": + fun.exec_cmd(cmnd,arg,client_id,pbid) + elif cmd_type(cmnd)=="management": + management.exec_cmd(cmnd,arg,client_id,pbid) + else: + _ba.chatmessage("no access",clients=client_id) + + if setting.brdcast_chatcmd: + return msg + return None + + diff --git a/dist/ba_root/mods/chatHandle/chatCMDS/fun.py b/dist/ba_root/mods/chatHandle/chatCMDS/fun.py index e69de29..6c79754 100644 --- a/dist/ba_root/mods/chatHandle/chatCMDS/fun.py +++ b/dist/ba_root/mods/chatHandle/chatCMDS/fun.py @@ -0,0 +1,23 @@ +# Released under the MIT License. See LICENSE for details. + + +cmnds=["/fly","/freeze"] + + +def exec_cmd(cmnd,arg,client_id,pbid): + if cmnd =="/fly": + fly() + + + +# ============== + +def fly(): + # do something + + +def freeze(): + # do something + +def spaz(): + #do something diff --git a/dist/ba_root/mods/chatHandle/chatCMDS/management.py b/dist/ba_root/mods/chatHandle/chatCMDS/management.py index e69de29..7d8240c 100644 --- a/dist/ba_root/mods/chatHandle/chatCMDS/management.py +++ b/dist/ba_root/mods/chatHandle/chatCMDS/management.py @@ -0,0 +1,22 @@ +# Released under the MIT License. See LICENSE for details. +cmnds=["/add","/kick"] + + +def exec_cmd(cmnd,arg,client_id,pbid): + if cmnd =="/kick": + kick(arg[0]) + + + +# ============== + +def kick(client_id): + _ba.disconnectclient(client_id) + # do something + + +def add(): + # do something + +def end(): + #do something diff --git a/dist/ba_root/mods/chatHandle/chatSpam/chatfilter.py b/dist/ba_root/mods/chatHandle/chatSpam/chatfilter.py new file mode 100644 index 0000000..bf3dea9 --- /dev/null +++ b/dist/ba_root/mods/chatHandle/chatSpam/chatfilter.py @@ -0,0 +1,3 @@ +# Released under the MIT License. See LICENSE for details. +def isAbuse(): + return \ No newline at end of file diff --git a/dist/ba_root/mods/chatHandle/handlechat.py b/dist/ba_root/mods/chatHandle/handlechat.py index 7796c9b..804ced4 100644 --- a/dist/ba_root/mods/chatHandle/handlechat.py +++ b/dist/ba_root/mods/chatHandle/handlechat.py @@ -1,2 +1,24 @@ -import playersData +# Released under the MIT License. See LICENSE for details. +from playersData import pdata +from chatCMDS import chatcmd +from chatFilter import chatfilter +import ba,_ba + +def public_id(client_id): + rost=_ba.get_game_roster() + for client in rost: + if client['client_id']==client_id: + return client['account_id'] + return None + +def filter_chat_message(msg,client_id): + if msg.startswith("/"): + return chatcmd.cmd(msg,client_id) + + if chatfilter.isAbuse(msg): + pdata.warn(public_id(client_id)) + return None + return msg + + diff --git a/dist/ba_root/mods/playersData/pdata.py b/dist/ba_root/mods/playersData/pdata.py new file mode 100644 index 0000000..fb54814 --- /dev/null +++ b/dist/ba_root/mods/playersData/pdata.py @@ -0,0 +1,89 @@ +# Released under the MIT License. See LICENSE for details. +roles={} +data={} + + +def roles(): + global roles + if roles=={}: + f=open("roles.json","r") + dat=json.loads(f.read()) + roles=dat + f.close() + return roles + +def create_role(role): + global roles + _roles=roles() + if role not in _roles: + _roles[role]={ + "tag":role, + "tagcolor":(1,1,1), + "commands":[], + "ids":[] + } + roles=_roles + comit() + return 'created successfully' + + + return 'already exists' + +def add_player_role(role,id): + global roles + _roles=roles() + if role in _roles: + _roles[role].ids.append(id) + roles=_roles + commit() + return 'added to '+role + return "role not exists" + +def add_command_role(role,command): + global roles + _roles=roles() + if role in _roles: + _roles[role].commands.append(command) + roles=_roles + commit() + return 'added '+command+"to "+role + return role+"not exists" + + +def remove_player_role(role,id): + global roles + _roles=roles() + if role in _roles: + _roles[role].ids.remove(id) + roles=_roles + commit() + return "removed" + return "role not exists" + +def remove_command_role(): + global roles + _roles=roles() + if role in _roles: + _roles[role].commands.remove(command) + roles=_roles + commit() + return 'removed '+command+"from "+role + return role+"not exists" + +def change_role_tag(role,tag): + global roles + _roles=roles() + if role in _roles: + _roles[role].tag=tag + roles=_roles + commit() + return "tag changed" + return "role not exists" + + +def commit(): + global roles + f=open("roles.json",'w') + json.dump(roles,f,indent=4) + f.close() + diff --git a/dist/ba_root/mods/playersData/roles.json b/dist/ba_root/mods/playersData/roles.json index e69de29..3903a38 100644 --- a/dist/ba_root/mods/playersData/roles.json +++ b/dist/ba_root/mods/playersData/roles.json @@ -0,0 +1,27 @@ +{ + "owner":{ + "tag":"OWNER", + "tagcolor":(1,1,1), + "commands":["add","kick","remove"], + "ids":["pb-ihugg7g9==","pb-7gt78"] + + }, + "admin":{ + "tag":"ADMIN", + "tagcolor":(1,1,1), + "commands":["kick","end"], + "ids":["pb-ugg","pb-767fyfd"] + }, + "vip":{ + "tag":"VIP", + "tagcolor":(1,1,1), + "commands":[], + "ids":[] + }, + "donor":{ + "tag":"DONOR", + "tagcolor":(2,2,2), + "commands":[], + "ids":[] + } +} \ No newline at end of file diff --git a/dist/ba_root/mods/serverData/__pycache__/__init__.cpython-38.pyc b/dist/ba_root/mods/serverData/__pycache__/__init__.cpython-38.pyc new file mode 100644 index 0000000..c2d8515 Binary files /dev/null and b/dist/ba_root/mods/serverData/__pycache__/__init__.cpython-38.pyc differ diff --git a/dist/ba_root/mods/serverData/__pycache__/serverdata.cpython-38.pyc b/dist/ba_root/mods/serverData/__pycache__/serverdata.cpython-38.pyc new file mode 100644 index 0000000..8862919 Binary files /dev/null and b/dist/ba_root/mods/serverData/__pycache__/serverdata.cpython-38.pyc differ diff --git a/dist/ba_root/mods/serverData/serverdata.py b/dist/ba_root/mods/serverData/serverdata.py new file mode 100644 index 0000000..9b46f9f --- /dev/null +++ b/dist/ba_root/mods/serverData/serverdata.py @@ -0,0 +1 @@ +# Released under the MIT License. See LICENSE for details. \ No newline at end of file diff --git a/dist/ba_root/mods/setting.py b/dist/ba_root/mods/setting.py index e69de29..9b46f9f 100644 --- a/dist/ba_root/mods/setting.py +++ b/dist/ba_root/mods/setting.py @@ -0,0 +1 @@ +# Released under the MIT License. See LICENSE for details. \ No newline at end of file diff --git a/dist/ba_root/mods/stats/rank.py b/dist/ba_root/mods/stats/rank.py index e69de29..9b46f9f 100644 --- a/dist/ba_root/mods/stats/rank.py +++ b/dist/ba_root/mods/stats/rank.py @@ -0,0 +1 @@ +# Released under the MIT License. See LICENSE for details. \ No newline at end of file diff --git a/dist/ba_root/mods/tools/__pycache__/whitelist.cpython-38.pyc b/dist/ba_root/mods/tools/__pycache__/whitelist.cpython-38.pyc new file mode 100644 index 0000000..776e704 Binary files /dev/null and b/dist/ba_root/mods/tools/__pycache__/whitelist.cpython-38.pyc differ diff --git a/dist/ba_root/mods/tools/spamcheck.py b/dist/ba_root/mods/tools/spamcheck.py index e69de29..9b46f9f 100644 --- a/dist/ba_root/mods/tools/spamcheck.py +++ b/dist/ba_root/mods/tools/spamcheck.py @@ -0,0 +1 @@ +# Released under the MIT License. See LICENSE for details. \ No newline at end of file diff --git a/dist/ba_root/mods/tools/textonmap.py b/dist/ba_root/mods/tools/textonmap.py index e69de29..9b46f9f 100644 --- a/dist/ba_root/mods/tools/textonmap.py +++ b/dist/ba_root/mods/tools/textonmap.py @@ -0,0 +1 @@ +# Released under the MIT License. See LICENSE for details. \ No newline at end of file