diff --git a/dist/ba_root/mods/chatHandle/chatCMDS/chatcmd.py b/dist/ba_root/mods/chatHandle/chatCMDS/chatcmd.py index 0be0f4c..b7cfd50 100644 --- a/dist/ba_root/mods/chatHandle/chatCMDS/chatcmd.py +++ b/dist/ba_root/mods/chatHandle/chatCMDS/chatcmd.py @@ -1,41 +1,67 @@ # Released under the MIT License. See LICENSE for details. -import ba -import _ba -from playersData import pdata -import fun,management +import ba, _ba 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'] +from playersData import pdata +from . import fun +from . import management, cheats, normal_commands as normal_cmds + + +def client_to_account(client_id): + rost = _ba.get_game_roster() + for i in rost: + if i['client_id'] == client_id: + return i['account_id'] return None -def check_permission(pbid,cmnd): - roles=pdata.roles() + +def check_permission(account_id, command): + roles = pdata.get_roles() for role in roles: - if pbid in role.ids and cmnd in role.commands: + if account_id in roles[role]["ids"] and command in roles[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) +def cmd_type(cmnd): + + if cmnd in normal_cmds.cmnds or cmnd in normal_cmds.cmnd_aliases: + return "normal_cmd" + + if cmnd in management.cmnds or cmnd in management.cmnd_aliases: + return "management" + + if cmnd in fun.cmnds or cmnd in fun.cmnd_aliases: + return "fun" + + if cmnd in cheats.cmnds or cmnd in cheats.cmnd_aliases: + return "cheats" + + +def cmd(msg, client_id): + cmnd = msg.split(" ")[0].lower().split("/")[1] + arg = msg.split(" ")[1:] + acid = "pb-IF48VgWkBFQ" +#client_to_account(client_id) + + if cmd_type(cmnd) == "fun": + if check_permission(acid, cmnd): + fun.exec_cmd(cmnd, arg, client_id, acid) + + elif cmd_type(cmnd) == "management": + if check_permission(acid, cmnd): + management.exec_cmd(cmnd, arg, client_id, acid) + + elif cmd_type(cmnd) == "cheats": + if check_permission(acid, cmnd): + cheats.exec_cmd(cmnd, arg, client_id, acid) + + elif cmd_type(cmnd) == "normal_cmd": + normal_cmds.exec_cmd(cmnd, arg, client_id, acid) + else: - _ba.chatmessage("no access",clients=client_id) + _ba.chatmessage("no access") + if setting.brdcast_chatcmd: return msg diff --git a/dist/ba_root/mods/chatHandle/chatCMDS/fun.py b/dist/ba_root/mods/chatHandle/chatCMDS/fun.py index 6c79754..ff1612f 100644 --- a/dist/ba_root/mods/chatHandle/chatCMDS/fun.py +++ b/dist/ba_root/mods/chatHandle/chatCMDS/fun.py @@ -1,23 +1,177 @@ # Released under the MIT License. See LICENSE for details. -cmnds=["/fly","/freeze"] +from _ba import chatmessage as cmsg, screenmessage as smsg +from .handlers import activity_players, on_command_error, handlemsg, handlemsg_all +import ba, _ba -def exec_cmd(cmnd,arg,client_id,pbid): - if cmnd =="/fly": - fly() +cmnds = ['fly', 'invisible', 'headless', 'creepy', 'celebrate', 'spaz'] + +cmnd_aliases = ['inv', 'hl', 'creep', 'celeb'] + + +def exec_cmd(cmnd, arg, clid, pbid): + + if cmnd in ['fly']: + fly_call(arg) + + elif cmnd in ['inv', 'invisible']: + invi_call(arg) + + elif cmnd in ['hl', 'headless']: + headless_call(arg) + + elif cmnd in ['creepy', 'creep']: + creep_call(arg) + + elif cmnd in ['celebrate', 'celeb']: + celeb_call(arg) + + elif cmnd in ['spaz']: + spaz_call(arg) + + + +def fly_call(arg): + if on_command_error(arg): + return + + elif arg[0] == 'all': + + for players in activity_players(): + if players.actor.node.fly != True: + players.actor.node.fly = True + else: + players.actor.node.fly = False + + else: + try: + player = int(arg[0]) + + if activity_players()[player].actor.node.fly != True: + activity_players()[player].actor.node.fly = True + else: + activity_players()[player].actor.node.fly = False + + except: + return -# ============== -def fly(): - # do something +def invi_call(arg): + if on_command_error(arg): + return + + elif arg[0] == 'all': + for i in activity_players(): + body = i.actor.node + if body.torso_model != None: + body.head_model = None + body.torso_model = None + body.upper_arm_model = None + body.forearm_model = None + body.pelvis_model = None + body.hand_model = None + body.toes_model = None + body.upper_leg_model = None + body.lower_leg_model = None + body.style = 'cyborg' + else: + + player = int(arg[0]) + body = activity_players()[player].actor.node + + if body.torso_model != None: + body.head_model = None + body.torso_model = None + body.upper_arm_model = None + body.forearm_model = None + body.pelvis_model = None + body.hand_model = None + body.toes_model = None + body.upper_leg_model = None + body.lower_leg_model = None + body.style = 'cyborg' -def freeze(): - # do something -def spaz(): - #do something + +def headless_call(arg): + if on_command_error(arg): + return + + elif arg[0] == 'all': + + for players in activity_players(): + node = players.actor.node + + if node.head_model != None: + node.head_model = None + node.style='cyborg' + + else: + try: + player = int(arg[0]) + node = activity_players()[player].actor.node + + if node.head_model != None: + node.head_model = None + node.style='cyborg' + except: + return + + + +def creep_call(arg): + if on_command_error(arg): + return + + elif arg[0] == 'all': + + for players in activity_players(): + node = players.actor.node + + if node.head_model != None: + node.head_model = None + node.handlemessage(ba.PowerupMessage(poweruptype='punch')) + node.handlemessage(ba.PowerupMessage(poweruptype='shield')) + + else: + try: + player = int(arg[0]) + node = activity_players()[player].actor.node + + if node.head_model != None: + node.head_model = None + node.handlemessage(ba.PowerupMessage(poweruptype='punch')) + node.handlemessage(ba.PowerupMessage(poweruptype='shield')) + except: + return + + + +def celeb_call(arg): + if on_command_error(arg): + return + + elif arg[0] == 'all': + handlemsg_all(ba.CelebrateMessage()) + + else: + try: + player = int(arg[0]) + handlemsg(player, ba.CelebrateMessage()) + except: + return + + + + + +def spaz_call(arg): + if on_command_error(arg): + return + + pass diff --git a/dist/ba_root/mods/chatHandle/chatCMDS/management.py b/dist/ba_root/mods/chatHandle/chatCMDS/management.py index 7d8240c..620ca00 100644 --- a/dist/ba_root/mods/chatHandle/chatCMDS/management.py +++ b/dist/ba_root/mods/chatHandle/chatCMDS/management.py @@ -1,22 +1,260 @@ # Released under the MIT License. See LICENSE for details. -cmnds=["/add","/kick"] +from _ba import chatmessage as cmsg, screenmessage as smsg +from .handlers import activity_players, sess_players, on_command_error, handlemsg, handlemsg_all +from playersData import pdata +import ba, _ba, time -def exec_cmd(cmnd,arg,client_id,pbid): - if cmnd =="/kick": +cmnds = ['kick', 'remove', 'end', 'quit', 'mute', 'unmute', 'slowmo', 'nv', 'dv', 'pause', 'cameramode', 'createrole', 'addrole', 'removerole', 'addcommand', 'addcmd', 'removecommand', 'removecmd', 'changetag'] + +cmnd_aliases = ['rm', 'next', 'restart', 'mutechat', 'unmutechat', 'sm', 'slow', 'night', 'day', 'pausegame', 'camera_mode', 'rotate_camera'] + +def exec_cmd(cmnd, arg, client_id, pbid): + if cmnd in ['kick']: kick(arg[0]) + + elif cmnd in ['end', 'next']: + end_call(arg) + + elif cmnd in ['quit', 'restart']: + quit_call(arg) + + elif cmnd in ['mute', 'mutechat']: + mute_call() + + elif cmnd in ['unmute', 'unmutechat']: + un_mute_call() + + elif cmnd in ['remove', 'rm']: + remove_call(arg) + + elif cmnd in ['sm', 'slow', 'slowmo']: + slow_mo_call() + + elif cmnd in ['nv', 'night']: + nv_call(arg) + + elif cmnd in ['dv', 'day']: + dv_call(arg) + + elif cmnd in ['pause', 'pausegame']: + pause_call() + + elif cmnd in ['cameraMode', 'camera_mode', 'rotate_camera']: + rotate_camera_call() + + elif cmnd in ['createrole']: + create_role_call(arg) + + elif cmnd in ['addrole']: + add_role_to_player(arg) + + elif cmnd in ['removerole']: + remove_role_from_player(arg) + + elif cmnd in ['addcommand', 'addcmd']: + add_command_to_role(arg) + + elif cmnd in ['removecommand', 'removecmd']: + remove_command_to_role(arg) + + elif cmnd in ['changetag']: + change_role_tag_call(arg) + -# ============== +# ============= + def kick(client_id): _ba.disconnectclient(client_id) - # do something + + +def remove_call(arg): + + if on_command_error(arg): + return + + elif arg[0] == 'all': + for i in sess_players(): + i.remove_from_game() + + else: + try: + req_player = int(arg[0]) + sess_players()[req_player].remove_from_game() + except: + return def add(): - # do something + pass + + +def end_call(arg): + if arg == [] or arg == ['']: + activity = _ba.get_foreground_host_activity() + activity.end_game() +""" + else: + try: + tmr = int(arg[0]) + time.sleep(tmr) + activity = _ba.get_foreground_host_activity() + activity.end_game() + except: + return +""" + + +def quit_call(arg): + + if arg == [] or arg == ['']: + ba.quit() + + """ + else: + try: + tmr = int(arg[0]) + time.sleep(tmr) + ba.quit() + except: + return + """ + + +def mute_call(): + pass + +def un_mute_call(): + pass + + + +def slow_mo_call(): + + activity = _ba.get_foreground_host_activity() + + if activity.globalsnode.slow_motion != True: + activity.globalsnode.slow_motion = True + + else: + activity.globalsnode.slow_motion = False + + + + + +def nv_call(arg): + + activity = _ba.get_foreground_host_activity() + + if arg == [] or arg == ['']: + + if activity.globalsnode.tint != (0.5, 0.7, 1.0): + activity.globalsnode.tint = (0.5, 0.7, 1.0) + else: + #will fix this soon + pass + + elif arg[0] == 'off': + if activity.globalsnode.tint != (0.5, 0.7, 1.0): + return + else: + pass + + + +def dv_call(arg): + + activity = _ba.get_foreground_host_activity() + + if arg == [] or arg == ['']: + + if activity.globalsnode.tint != (1,1,1): + activity.globalsnode.tint = (1,1,1) + else: + #will fix this soon + pass + + elif arg[0] == 'off': + if activity.globalsnode.tint != (1,1,1): + return + else: + pass + + +def pause_call(): + + activity = _ba.get_foreground_host_activity() + + if activity.globalsnode.paused != True: + activity.globalsnode.paused = True + + else: + activity.globalsnode.paused = False + + +def rotate_camera_call(): + + activity = _ba.get_foreground_host_activity() + + if activity.globalsnode.camera_mode != 'rotate': + activity.globalsnode.camera_mode = 'rotate' + + else: + activity.globalsnode.camera_mode == 'normal' + + + + + +def create_role_call(arg): + pdata.create_role(arg[0]) + + +def add_role_to_player(arg): + id = sess_players()[int(arg[1])].get_account_id() + try: + pdata.add_player_role(arg[0], id) + except: + return + +def remove_role_from_player(arg): + id = sess_players()[int(arg[1])].get_account_id() + try: + pdata.remove_player_role(arg[0], id) + except: + return + + +def change_role_tag_call(arg): + pdata.change_role_tag(arg[0], arg[1]) + + + + + +all_commands = ["changetag","createrole", "addrole", "removerole", "addcommand", "addcmd","removecommand","removecmd","kick","remove","rm","end","next","quit","restart","mute","mutechat","unmute","unmutechat","sm","slow","slowmo","nv","night","dv","day","pause","pausegame","cameraMode","camera_mode","rotate_camera","kill","die","heal","heath","curse","cur","sleep","sp","superpunch","gloves","punch","shield","protect","freeze","ice","unfreeze","thaw","gm","godmode","fly","inv","invisible","hl","headless","creepy","creep","celebrate","celeb","spaz"] + + + +def add_command_to_role(arg): + try: + if arg[1] in all_commands: + pdata.add_command_role(arg[0], arg[1]) + except: + return + + + +def remove_command_to_role(arg): + try: + if arg[1] in all_commands: + pdata.remove_command_role(arg[0], arg[1]) + except: + return + + -def end(): - #do something diff --git a/dist/ba_root/mods/chatHandle/handlechat.py b/dist/ba_root/mods/chatHandle/handlechat.py index e15fbe1..2f6fc5a 100644 --- a/dist/ba_root/mods/chatHandle/handlechat.py +++ b/dist/ba_root/mods/chatHandle/handlechat.py @@ -1,7 +1,7 @@ # Released under the MIT License. See LICENSE for details. from playersData import pdata from chatHandle.chatCMDS import chatcmd -from chatFilter import chatfilter +#from chatFilter import chatfilter import ba,_ba def public_id(client_id): @@ -14,11 +14,13 @@ def public_id(client_id): def filter_chat_message(msg,client_id): if msg.startswith("/"): return chatcmd.cmd(msg,client_id) + return msg +""" if chatfilter.isAbuse(msg): pdata.warn(public_id(client_id)) return None return msg - +""" diff --git a/dist/ba_root/mods/custom_hooks.py b/dist/ba_root/mods/custom_hooks.py index 74ce62e..c3621ff 100644 --- a/dist/ba_root/mods/custom_hooks.py +++ b/dist/ba_root/mods/custom_hooks.py @@ -1,8 +1,10 @@ -def filter_chat_message(msg,client_id): - from chatHandle import handlechat + +def filter_chat_message(msg,client_id): + from chatHandle import handlechat return handlechat.filter_chat_message(msg,client_id) + def on_app_launch(): pass #something diff --git a/dist/ba_root/mods/playersData/pdata.py b/dist/ba_root/mods/playersData/pdata.py index 10ed681..51c5594 100644 --- a/dist/ba_root/mods/playersData/pdata.py +++ b/dist/ba_root/mods/playersData/pdata.py @@ -1,151 +1,164 @@ # Released under the MIT License. See LICENSE for details. -import os,_ba,json -roles={} -data={} -custom={} +import _ba, os, json + + + +roles = {} +data = {} +custom = {} data_path = os.path.join(_ba.env()['python_directory_user'],"playersData" + os.sep) + + + +def commit(data): + global roles + if data == {}: + return + with open(data_path+'roles.json','w') as f: + json.dump(data, f, indent=4) + + def get_roles(): global roles - if roles=={}: - f=open(data_path+"roles.json","r") - dat=json.loads(f.read()) - roles=dat - f.close() + if roles == {}: + with open(data_path+'roles.json', 'r') as f: + roles = json.load(f) return roles + def create_role(role): global roles - _roles=get_roles() + _roles = get_roles() if role not in _roles: - _roles[role]={ + _roles[role] = { "tag":role, - "tagcolor":(1,1,1), + "tagcolor":[1,1,1], "commands":[], "ids":[] - } - roles=_roles - comit() - return 'created successfully' - - - return 'already exists' + } + roles = _roles + commit(_roles) + return + return -def add_player_role(role,id): + +def add_player_role(role, id): global roles - _roles=get_roles() + _roles = get_roles() if role in _roles: - _roles[role].ids.append(id) - roles=_roles - commit() - return 'added to '+role + if id not in _roles[role]["ids"]: + _roles[role]["ids"].append(id) + roles =_roles + commit(_roles) + return "added to "+role return "role not exists" -def add_command_role(role,command): - global roles - _roles=get_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): +def remove_player_role(role, id): global roles - _roles=get_roles() + _roles = get_roles() if role in _roles: - _roles[role].ids.remove(id) - roles=_roles - commit() - return "removed" + _roles[role]["ids"].remove(id) + roles =_roles + commit(_roles) + return "removed from "+role return "role not exists" -def remove_command_role(): - global roles - _roles=get_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): + + +def add_command_role(role, command): global roles - _roles=get_roles() + _roles = get_roles() if role in _roles: - _roles[role].tag=tag - roles=_roles - commit() + if command not in _roles[role]["commands"]: + _roles[role]["commands"].append(command) + roles =_roles + commit(_roles) + return "command added to "+role + return "command not exists" + + +def remove_command_role(role, command): + global roles + _roles = get_roles() + if role in _roles: + if command in _roles[role]["commands"]: + _roles[role]["commands"].remove(command) + roles =_roles + commit(_roles) + return "command added to "+role + return "command not exists" + + +def change_role_tag(role, tag): + global roles + _roles = get_roles() + if role in _roles: + _roles[role]['tag'] = tag + roles = _roles + commit(_roles) return "tag changed" return "role not exists" -def commit(_roles): - global roles - if _roles=={}: - return - f=open(data_path+"roles.json",'w') - json.dump(_roles,f,indent=4) - f.close() - roles=_roles - def get_role(acc_id): global roles - _roles =get_roles() + _roles = get_roles() for role in _roles: if acc_id in role["ids"]: return role + +##### those ups done will clean it in future + + + #======================= CUSTOM EFFECTS/TAGS =============== def get_custom(): global custom if custom=={}: - f=open(data_path+"custom.json","r") - dat=json.loads(f.read()) - custom=dat - f.close() - return custom + with open(data_path+"custom.json","r") as f: + custom = json.loads(f.read()) + return custom - -def set_effect(effect,id): +def set_effect(effect, id): global custom - _custom=get_custom() - _custom['customeffects'][id]=effect - custom=_custom + _custom = get_custom() + _custom['customeffects'][id] = effect + custom = _custom commit_c() -def set_tag(tag,id): +def set_tag(tag, id): global custom - _custom=get_custom() - _custom['customtag'][id]=tag - custom=_custom + _custom = get_custom() + _custom['customtag'][id] = tag + custom = _custom commit_c() + def remove_effect(id): global custom - _custom=get_custom() + _custom = get_custom() _custom['customeffects'].pop(id) - custom=_custom + custom = _custom commit_c() def remove_tag(id): global custom - _custom=get_custom() + _custom = get_custom() _custom['customtag'].pop(id) - custom=_custom + custom = _custom commit_c() def commit_c(): global custom - f=open(data_path+"custom.json",'w') - json.dump(custom,f,indent=4) - f.close() + with open(data_path+"custom.json",'w') as f: + json.dump(custom,f,indent=4) diff --git a/dist/ba_root/mods/playersData/roles.json b/dist/ba_root/mods/playersData/roles.json index d524756..d34f3e4 100644 --- a/dist/ba_root/mods/playersData/roles.json +++ b/dist/ba_root/mods/playersData/roles.json @@ -1,27 +1,121 @@ { - "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":[] - }, - "toppers":{ - "tag":"DONOR", - "tagcolor":(2,2,2), - "commands":[], - "ids":[] - } + "owner": { + "tag": "pranav", + "tagcolor": [ + 1, + 1, + 1 + ], + "commands": [ + "createrole", + "addrole", + "removerole", + "addcommand", + "addcmd", + "removecommand", + "removecmd", + "remove", + "kick", + "rm", + "next", + "quit", + "restart", + "mute", + "mutechat", + "unmute", + "unmutechat", + "sm", + "slow", + "slowmo", + "nv", + "night", + "dv", + "day", + "pause", + "pausegame", + "cameraMode", + "camera_mode", + "rotate_camera", + "kill", + "die", + "heal", + "heath", + "curse", + "cur", + "sleep", + "sp", + "superpunch", + "gloves", + "punch", + "shield", + "protect", + "freeze", + "ice", + "unfreeze", + "thaw", + "gm", + "godmode", + "fly", + "inv", + "invisible", + "hl", + "headless", + "creepy", + "creep", + "celebrate", + "celeb", + "spaz", + "me", + "stats", + "score", + "list", + "l", + "uniqeid", + "id", + "pb-id", + "pb", + "accountid", + "end", + "changetag" + ], + "ids": [ + "pb-IF48VgWkBFQ" + ] + }, + "test69": { + "tag": "test69", + "tagcolor": [ + 1, + 1, + 1 + ], + "commands": [ + "mute" + ], + "ids": [ + "pb-IF4VAk4a" + ] + }, + "test70": { + "tag": "test70", + "tagcolor": [ + 1, + 1, + 1 + ], + "commands": [], + "ids": [ + "pb-IF4VAk4a" + ] + }, + "test71": { + "tag": "test71", + "tagcolor": [ + 1, + 1, + 1 + ], + "commands": [], + "ids": [] + } } \ No newline at end of file