当前位置: 首页>>代码示例>>Python>>正文


Python usersession.UserSessionManager类代码示例

本文整理汇总了Python中hypershade.usersession.UserSessionManager的典型用法代码示例。如果您正苦于以下问题:Python UserSessionManager类的具体用法?Python UserSessionManager怎么用?Python UserSessionManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了UserSessionManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: kick

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)
开发者ID:Pat61,项目名称:hyperserv,代码行数:8,代码来源:servercommands.py

示例2: loginOther

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)
开发者ID:crcollins,项目名称:hyperserv,代码行数:10,代码来源:usercommands.py

示例3: loginOther

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)
开发者ID:amstan,项目名称:hyperserv,代码行数:10,代码来源:usercommands.py

示例4: kick

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)
开发者ID:crcollins,项目名称:hyperserv,代码行数:12,代码来源:servercommands.py

示例5: masterMode

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)
开发者ID:Pat61,项目名称:hyperserv,代码行数:14,代码来源:servercommands.py

示例6: masterMode

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)
开发者ID:crcollins,项目名称:hyperserv,代码行数:14,代码来源:servercommands.py

示例7: checkforCS

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
开发者ID:deathstar,项目名称:hyperserv,代码行数:17,代码来源:cubescript.py

示例8: simpleMasterRequest

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.")
开发者ID:Pat61,项目名称:hyperserv,代码行数:9,代码来源:clientcommands.py

示例9: team

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)
开发者ID:Pat61,项目名称:hyperserv,代码行数:19,代码来源:servercommands.py

示例10: spectator

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)
开发者ID:crcollins,项目名称:hyperserv,代码行数:22,代码来源:servercommands.py

示例11: spectator

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)
开发者ID:Pat61,项目名称:hyperserv,代码行数:22,代码来源:servercommands.py

示例12: who

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
开发者ID:Pat61,项目名称:hyperserv,代码行数:14,代码来源:servercommands.py

示例13: takeMaster

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")
开发者ID:amstan,项目名称:hyperserv,代码行数:5,代码来源:usercommands.py

示例14: playerconnect

def playerconnect(cn):
	UserSessionManager.create(("ingame",cn))
	if cn in muted_cns:
		muted_cns.remove(cn)
开发者ID:Pat61,项目名称:hyperserv,代码行数:4,代码来源:ingame.py

示例15: playerdisconnect

def playerdisconnect(cn):
	UserSessionManager.destroy(("ingame",cn))
	if cn in muted_cns:
		muted_cns.remove(cn)
开发者ID:Pat61,项目名称:hyperserv,代码行数:4,代码来源:ingame.py


注:本文中的hypershade.usersession.UserSessionManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。