chatcmnd fix

This commit is contained in:
Ayush Saini 2022-06-25 22:19:43 +05:30
parent 38fd457084
commit b97567b8ef

View file

@ -1,4 +1,4 @@
from .Handlers import handlemsg, handlemsg_all,send,chattmsg from .Handlers import handlemsg, handlemsg_all,send
from playersData import pdata from playersData import pdata
# from tools.whitelist import add_to_white_list, add_commit_to_logs # from tools.whitelist import add_to_white_list, add_commit_to_logs
from serverData import serverdata from serverData import serverdata
@ -37,10 +37,10 @@ def ExcelCommand(command, arguments, clientid, accountid):
kikvote(arguments, clientid) kikvote(arguments, clientid)
elif command == 'lm': elif command == 'lm':
last_msgs(arguments) last_msgs(clientid)
elif command == 'gp': elif command == 'gp':
get_profiles(arguments) get_profiles(arguments, clientid)
elif command == 'party': elif command == 'party':
party_toggle(arguments) party_toggle(arguments)
@ -130,7 +130,7 @@ def kick(arguments):
_ba.disconnect_client(int(arguments[0])) _ba.disconnect_client(int(arguments[0]))
return return
def kikvote(arguments, clientid): def kikvote(arguments, clientid):
if arguments == [] or arguments == ['']: if arguments == [] or arguments == [''] or len(arguments) < 2:
return return
elif arguments[0] == 'enable': elif arguments[0] == 'enable':
@ -139,13 +139,11 @@ def kikvote(arguments, clientid):
else: else:
try: try:
cl_id=int(arguments[1]) cl_id=int(arguments[1])
ac_id=""
for ros in _ba.get_game_roster(): for ros in _ba.get_game_roster():
if ros["client_id"]==cl_id: if ros["client_id"]==cl_id:
_thread.start_new_thread(pdata.kikvot,(ros['account_id'],)) if ros["account_id"] in serverdata.clients:
send("Upon server restart, Kick-vote will be enabled for this person", clientid) serverdata.clients[ros["account_id"]]["canStartKickVote"]=True
if ac_id in serverdata.clients: send("Upon server restart, Kick-vote will be enabled for this person", clientid)
serverdata.clients[ac_id]["canStartKickVote"]=True
return return
except: except:
return return
@ -156,31 +154,29 @@ def kikvote(arguments, clientid):
else: else:
try: try:
cl_id=int(arguments[1]) cl_id=int(arguments[1])
ac_id=""
for ros in _ba.get_game_roster(): for ros in _ba.get_game_roster():
if ros["client_id"]==cl_id: if ros["client_id"]==cl_id:
_thread.start_new_thread(pdata.kikvott,(ros['account_id'],)) _ba.disable_kickvote(ros["account_id"])
send("Upon server restart, Kick-vote will be disabled for this person", clientid) send("Kick-vote disabled for this person", clientid)
if ac_id in serverdata.clients: if ros["account_id"] in serverdata.clients:
serverdata.clients[ac_id]["canStartKickVote"]=False serverdata.clients[ros["account_id"]]["canStartKickVote"]=False
return return
except: except:
return return
else: else:
return return
def last_msgs(arguments): def last_msgs(clientid):
if arguments == [] or arguments == ['']: for i in _ba.get_chat_messages():
for i in _ba.get_chat_messages(): send(i,clientid)
chattmsg(i)
def get_profiles(arguments): def get_profiles(arguments,clientid):
try: try:
playerID = int(arguments[0]) playerID = int(arguments[0])
num = 1 num = 1
for i in _ba.get_foreground_host_session().sessionplayers[playerID].inputdevice.get_player_profiles(): for i in _ba.get_foreground_host_session().sessionplayers[playerID].inputdevice.get_player_profiles():
try: try:
chattmsg(f"{num})- {i}") send(f"{num})- {i}",clientid)
num += 1 num += 1
except: except:
pass pass
@ -188,20 +184,18 @@ def get_profiles(arguments):
pass pass
def party_toggle(arguments): def party_toggle(arguments):
if arguments == ['public']: if arguments == ['public']:
_ba.set_public_party_enabled(True) _ba.set_public_party_enabled(True)
_ba.chatmessage("party is public now")
elif arguments == ['private']: elif arguments == ['private']:
_ba.set_public_party_enabled(False) _ba.set_public_party_enabled(False)
chattmsg("Remember, party will be Public upon restart") _ba.chatmessage("party is private now")
else: else:
pass pass
def end(arguments): def end(arguments):
if arguments == [] or arguments == ['']: if arguments == [] or arguments == ['']:
try: try:
with _ba.Context(_ba.get_foreground_host_activity()): with _ba.Context(_ba.get_foreground_host_activity()):
_ba.get_foreground_host_activity().end_game() _ba.get_foreground_host_activity().end_game()