Example #1
0
def kick(caller,cn):
        """This allows the caller to kick another player; however, this will not override players with higher permission. Meaning, a master level permission can not kick someone with admin or trusted permission. To prevent the player from rejoining the server, they will also be banned for the default 60 minutes."""
	cn=int(cn)
	UserSessionManager.checkPermissions(caller,UserSessionManager[("ingame",cn)][1]) #check if the other person is more privileged
	
	ban(caller,sbserver.playerName(cn),"kicked by %s" % formatCaller(caller))
	triggerServerEvent("player_kicked",[caller,cn])
	return sbserver.playerKick(cn)
Example #2
0
def loginOther(caller,where,who,username=None):
	"""Logs in another player. This does not allow someone to login someone with higher permissions."""
	if where=="ingame":
		who=int(who)
	if username is None:
		username=UserSessionManager[caller][0]
	else:
		UserSessionManager.checkPermissions(caller,"admin")
	aswho=dict(userdatabase[username].items())
	succeedLogin((where,who),aswho)
Example #3
0
def loginOther(caller,where,who,username=None):
        """This allows a player to use their permissions to login another player, but just like with kicking they can not login someone of higher permissions than themselves."""
	if where=="ingame":
		who=int(who)
	if username is None:
		username=UserSessionManager[caller][0]
	else:
		UserSessionManager.checkPermissions(caller,"admin")
	aswho=dict(userdatabase[username].items())
	succeedLogin((where,who),aswho)
Example #4
0
def kick(caller,cn):
	"""Kicks another player; however, this command does not work on players with higher permission. Kicking a player also gives them a 60 minute ban."""
	cn=int(cn)
	try:
		UserSessionManager.checkPermissions(caller,UserSessionManager[("ingame",cn)][1]) #check if the other person is more privileged
	except PermissionError:
		triggerServerEvent("player_kick_failed",[caller,cn])
		raise
	
	ban(caller,sbserver.playerName(cn),"kicked by %s" % formatCaller(caller))
	triggerServerEvent("player_kicked",[caller,cn])
	return sbserver.playerKick(cn)
Example #5
0
def masterMode(caller,name=None):
        """This changes the mastermode in the same way that /mastermode does without the need to have claimed master or admin."""
	if name==None:
		return sbserver.masterMode()
	mastermode=mastermodeNumber(name)
	
	if config["serverpublic"]=="1":
		if mastermode>=2:
			UserSessionManager.checkPermissions(caller,"trusted")
	if config["serverpublic"]=="2":
		if mastermode>=3:
			UserSessionManager.checkPermissions(caller,"trusted")
	
	return sbserver.setMasterMode(mastermode)
Example #6
0
def masterMode(caller,name=None):
	"""Changes the mastermode of the server."""
	if name==None:
		return sbserver.masterMode()
	mastermode=mastermodeNumber(name)
	
	if config["serverpublic"]=="1":
		if mastermode>=2:
			UserSessionManager.checkPermissions(caller,"trusted")
	if config["serverpublic"]=="2":
		if mastermode>=3:
			UserSessionManager.checkPermissions(caller,"trusted")
	
	return sbserver.setMasterMode(mastermode)
Example #7
0
def checkforCS(caller,string):
	if string[0] in ['#','@']:
		string=string[1:]
		try:
			try:
				UserSessionManager.checkPermissions(caller,"trusted")
			except PermissionError:
				checkUntrustedCode(CSParser(string).parse())
			playerCS.executeby(caller,string)
		except:
			exctype,exctext,exctraceback=sys.exc_info()
			errormsg="%s: %s" % (exctype.__name__, exctext)
			playerCS.executeby(caller,"echo \"%s\"" % escape(errormsg))
			raise
		return 1
	else:
		return 0
Example #8
0
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.")
Example #9
0
def team(caller,*args):
        """This allows players to switch teams just like with /team."""
	if(len(args)==1):
		if(caller[0]=="ingame"):
			cn=caller[1]
		else:
			raise ServerError("You are not ingame. Please specify cn.")
	elif(len(args)==2):
		cn=args[0]
	else:
		raise TypeError("team takes either 1 or 2 arguments.")
	cn=int(cn)
	
	teamname=args[-1]
	
	if cn!=caller[1]:
		UserSessionManager.checkPermissions(caller,"master")
	
	sbserver.setTeam(cn,teamname)
Example #10
0
def spectator(caller,boolean=None,cn=None):
	"""Sets spectator for the given cn. If the cn is left off it applies to the caller."""
	#empty args
	if boolean is None:
		boolean=1
	boolean=int(boolean)
	
	if cn is None:
		if(caller[0]=="ingame"):
			cn=caller[1]
		else:
			raise ServerError("You are not ingame. Please specify cn.")
	cn=int(cn)
	
	#check if it's a self call
	if caller[1]==cn:
		if boolean==0 and sbserver.masterMode()>=2:
			UserSessionManager.checkPermissions(caller,"master")
		spectatorHelpler(boolean,cn)
	else:
		UserSessionManager.checkPermissions(caller,"master")
		spectatorHelpler(boolean,cn)
Example #11
0
def spectator(caller,boolean=None,cn=None):
        """If there are no arguments other than #spectator then the caller will be set to spectator. The first argument is a boolen that says what state of spectating the player will be (0 for not not a spectator and 1 for spectator), anything other than 0 will result in an them being a spectator. The cn is the client number of the player that the caller want spectated. If left off it will apply to the caller."""
	#empty args
	if boolean is None:
		boolean=1
	boolean=int(boolean)
	
	if cn is None:
		if(caller[0]=="ingame"):
			cn=caller[1]
		else:
			raise ServerError("You are not ingame. Please specify cn.")
	cn=int(cn)
	
	#check if it's a self call
	if caller[1]==cn:
		if boolean==0 and sbserver.masterMode()>=2:
			UserSessionManager.checkPermissions(caller,"master")
		spectatorHelpler(boolean,cn)
	else:
		UserSessionManager.checkPermissions(caller,"master")
		spectatorHelpler(boolean,cn)
Example #12
0
def who(caller,where="ingame"):
        """This gives info on all the people logged in to the server. It tells their name, client number and IP address. Use this in conjuction with #echo. Ex: #echo (who)"""
	def cndetails(cn):
		return sbserver.playerName(cn)+" (cn"+str(cn)+"/"+ipLongToString(sbserver.playerIpLong(cn))+")"
	
	clientlist=[session[1] for session in UserSessionManager.keys() if session[0] == where]
	
	if where=="ingame":
		clientlist='; '.join(map(cndetails,clientlist))
	
	if clientlist!="" or clientlist!=[]:
		return str(clientlist)
	else:
		return "No clients for %s." % where
Example #13
0
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")
Example #14
0
def playerconnect(cn):
	UserSessionManager.create(("ingame",cn))
	if cn in muted_cns:
		muted_cns.remove(cn)
Example #15
0
def playerdisconnect(cn):
	UserSessionManager.destroy(("ingame",cn))
	if cn in muted_cns:
		muted_cns.remove(cn)
Example #16
0
def minsleft(caller,time=None):
        """This sets the amount of time remianing on the map. This can only be used when the mapmode is not Coopedit"""
	if time is not None:
		UserSessionManager.checkPermissions(caller,"trusted")
		sbserver.setMinsRemaining(int(time))
	return sbserver.minutesRemaining()/60 #todo, fix the api, it shouldn't return seconds...
Example #17
0
def voteMap(caller,mode,name):
	otherplayers=[(session,user) for session,user in UserSessionManager.items() if session[0]=='ingame' and session!=caller]
	if len(otherplayers)==0:
		systemCS.executestring("map %s %s" % (name,mode))
Example #18
0
	def userKicked(self, kickee, channel, kicker, message):
		UserSessionManager.destroy(("irc",kickee))
Example #19
0
	def userRenamed(self, oldname, newname):
		UserSessionManager.rename(("irc",oldname),("irc",newname))
Example #20
0
	def userLeft(self, user, channel):
		UserSessionManager.destroy(("irc",user))
Example #21
0
	def userQuit(self, user, quitMessage):
		UserSessionManager.destroy(("irc",user))
Example #22
0
	def userJoined(self, user, channel):
		UserSessionManager.create(("irc",user))
Example #23
0
	def wrapper(self,f,*args):
		owner=args[0].owner
		UserSessionManager.checkPermissions(owner,self.permissionRequirement)
		return f(owner,*args[1:])
Example #24
0
def minsleft(caller,time=None):
	"""Sets the amount of time remianing on the map. This can also be used in conjuction with #echo. Ex: #echo (minsleft)"""
	if time is not None:
		UserSessionManager.checkPermissions(caller,"trusted")
		sbserver.setMinsRemaining(int(time))
	return sbserver.minutesRemaining()/60 #todo, fix the api, it shouldn't return seconds...
Example #25
0
def playerconnect(cn):
	UserSessionManager.create(("ingame",cn))
Example #26
0
def playerdisconnect(cn):
	UserSessionManager.destroy(("ingame",cn))