def simpleMasterRequest(caller): #check for other privileged people privileged=[(session,user) for session,user in UserSessionManager.items() if session[0]=='ingame' and user[1]!=''] if len(privileged)==0: setSimpleMaster(caller) else: playerCS.executeby(caller,"echo PermissionError: There are masters/admins present.") raise PermissionError("There are masters/admins present.")
def logout(caller,everything="no"): """This logs the caller out. If everything="everything" then the caller will be logged out in every case of the UserSessionManager.""" if everything=="everything": username=UserSessionManager[caller][0] for session in UserSessionManager: if UserSessionManager[session][0]==username: playerCS.executeby(session,"logout") else: del UserSessionManager[caller] playerCS.executeby(caller,"echo You have logged out.")
def clientSetMaster(caller,text): caller=("ingame",caller) if UserSessionManager[caller][0]=="notloggedin": #TODO: see http://github.com/SirAlex/hyperserv/issues#issue/23 if(config["serverpublic"]!="1"): simpleMasterRequest(caller) else: playerCS.executeby(caller,"echo PermissionError: You cannot claim master on this server without an account or auth.") raise PermissionError("You cannot claim master on this server without an account or auth.") else: checkforCS(caller,"@master")
def CSserverPM(caller, cn=None, *strings): """This allows the caller to pm another player. Note that this does not currently work for irc communications.""" try: string=' '.join(strings) cn = int(cn) reciver = ("ingame", cn) string1 = "PM from %s:" %formatCaller(caller) newstring = color(3, string1) newstring1 = color(7, string) playerCS.executeby(reciver,"echo \"%s %s\"" % (newstring, newstring1)) except ValueError: playerCS.executeby(caller,"echo \"PM does not work for irc yet\"") return string
def CSserverPM(caller, cn, *what): """Allows players to pm other players.""" string=' '.join(map(str,what)) try: cn = int(cn) reciver = ("ingame", cn) if caller[0] == "ingame": namecn = " ("+str(caller[1])+"): " else: namecn = "" string1 = formatCaller(caller) + namecn newstring = color(3, string1+string) playerCS.executeby(reciver,"echo \"%s\"" %newstring) except ValueError: triggerServerEvent("pm",[caller,cn,string]) return string
def noticeVoteMap(caller,mode,name): if caller[1] in muted_cns: playerCS.executeby(caller,"echo \"You are muted so you are not allowed to vote.\"") else: serverNotice("%s votes to play on %s (%s)." % (formatCaller(caller),name,modeName(mode)))
def noticeMute(cn): caller=("ingame",cn) playerCS.executeby(caller,"echo \"%s is muted. You cannot talk.\"" % (formatCaller(caller)))
def noticeEditMute(cn): caller=("ingame",cn) playerCS.executeby(caller,"echo \"%s is edit muted. You can not edit.\"" % (formatCaller(caller)))
def setSimpleMaster(caller): """sets the caller a simple master, just like /setmaster 1 does it on a vanilla server""" UserSessionManager[caller]=("notloggedin","master") playerCS.executeby(caller,"master")
def clientMapVote(caller,mapname,mode): caller=("ingame",caller) try: playerCS.executeby(caller,"map %s %s" % (mapname,mode)) except PermissionError: triggerServerEvent("vote_map",[caller,mode,mapname])
def takeMaster(caller): """This command takes master from the person that currently has it.""" masters=[session for session,user in UserSessionManager.items() if session[0]=='ingame' and user[1]=='master'] for master in masters: playerCS.executeby(master,"relinquish; logout")
def logout(caller): del UserSessionManager[caller] playerCS.executeby(caller,"echo You have logged out.")