本文整理匯總了Python中hypershade.usersession.UserSessionManager.checkPermissions方法的典型用法代碼示例。如果您正苦於以下問題:Python UserSessionManager.checkPermissions方法的具體用法?Python UserSessionManager.checkPermissions怎麽用?Python UserSessionManager.checkPermissions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類hypershade.usersession.UserSessionManager
的用法示例。
在下文中一共展示了UserSessionManager.checkPermissions方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: kick
# 需要導入模塊: from hypershade.usersession import UserSessionManager [as 別名]
# 或者: from hypershade.usersession.UserSessionManager import checkPermissions [as 別名]
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)
示例2: loginOther
# 需要導入模塊: from hypershade.usersession import UserSessionManager [as 別名]
# 或者: from hypershade.usersession.UserSessionManager import checkPermissions [as 別名]
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)
示例3: loginOther
# 需要導入模塊: from hypershade.usersession import UserSessionManager [as 別名]
# 或者: from hypershade.usersession.UserSessionManager import checkPermissions [as 別名]
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)
示例4: kick
# 需要導入模塊: from hypershade.usersession import UserSessionManager [as 別名]
# 或者: from hypershade.usersession.UserSessionManager import checkPermissions [as 別名]
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)
示例5: masterMode
# 需要導入模塊: from hypershade.usersession import UserSessionManager [as 別名]
# 或者: from hypershade.usersession.UserSessionManager import checkPermissions [as 別名]
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)
示例6: masterMode
# 需要導入模塊: from hypershade.usersession import UserSessionManager [as 別名]
# 或者: from hypershade.usersession.UserSessionManager import checkPermissions [as 別名]
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)
示例7: checkforCS
# 需要導入模塊: from hypershade.usersession import UserSessionManager [as 別名]
# 或者: from hypershade.usersession.UserSessionManager import checkPermissions [as 別名]
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
示例8: team
# 需要導入模塊: from hypershade.usersession import UserSessionManager [as 別名]
# 或者: from hypershade.usersession.UserSessionManager import checkPermissions [as 別名]
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)
示例9: spectator
# 需要導入模塊: from hypershade.usersession import UserSessionManager [as 別名]
# 或者: from hypershade.usersession.UserSessionManager import checkPermissions [as 別名]
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)
示例10: spectator
# 需要導入模塊: from hypershade.usersession import UserSessionManager [as 別名]
# 或者: from hypershade.usersession.UserSessionManager import checkPermissions [as 別名]
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)
示例11: minsleft
# 需要導入模塊: from hypershade.usersession import UserSessionManager [as 別名]
# 或者: from hypershade.usersession.UserSessionManager import checkPermissions [as 別名]
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...
示例12: wrapper
# 需要導入模塊: from hypershade.usersession import UserSessionManager [as 別名]
# 或者: from hypershade.usersession.UserSessionManager import checkPermissions [as 別名]
def wrapper(self,f,*args):
owner=args[0].owner
UserSessionManager.checkPermissions(owner,self.permissionRequirement)
return f(owner,*args[1:])
示例13: minsleft
# 需要導入模塊: from hypershade.usersession import UserSessionManager [as 別名]
# 或者: from hypershade.usersession.UserSessionManager import checkPermissions [as 別名]
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...