예제 #1
0
def CSserverAction(caller, cn=None, *strings):
        """ This allows the caller to use an "action" much like the /me command in irc."""
        try:
                string=' '.join(strings)
                cn = int(cn)
                serverNotice("%s %s %s" % (formatCaller(caller), string, formatCaller(("ingame",cn))))
        except ValueError:
                string=' '.join(strings)
                string=cn + ' '+ string
                serverNotice("%s %s" % (formatCaller(caller), string))
	return string
예제 #2
0
def login(caller,*params):
	username=None
	password=None
	
	if UserSessionManager[caller][0]!="notloggedin":
		username=UserSessionManager[caller][0]
		logout(caller)
	
	#extract username and password
	if len(params)==2:
		username=params[0]
		password=params[1]
	elif len(params)==1:
		password=params[0]
	
	#guess username
	if username is None:
		if caller[0]=="irc":
			user=userdatabase.search("irc nick",formatCaller(caller))
		elif caller[0]=="ingame":
			user=userdatabase.search("sauerbraten name",formatCaller(caller))
		else:
			raise ValueError("Could not determine your login name.")
		if user is None:
			raise ValueError("Could not determine your login name. Use \"@login username password\" to specify.")
	else:
		user=userdatabase[username]
	
	#temporarly cache the user instance
	user=dict(user.items())
	
	#authenticate with everything's that's available
	if password is None:
		if caller[0]=="irc":
			#call an ident message, TODO
			pass
		if caller[0]=="ingame":
			#this can only be verified with auth, and that's user initiated
			pass
		else:
			#hostname based
			pass
	else:
		if user["password"]==password:
			succeedLogin(caller,user)
			return
	
	raise PermissionError("Denied to login.")
예제 #3
0
def CSserverNotice(caller, *strings):
	string=' '.join(strings)
	if caller[0]=="system":
		serverNotice(string)
	else:
		serverNotice("Notice from %s: %s" % (formatCaller(caller),string))
	return string
예제 #4
0
파일: notices.py 프로젝트: amstan/hyperserv
def CSserverNotice(caller, *strings):
        """This allows the caller to make a server notice at the top of the screen of all of the players."""
	string=' '.join(strings)
	if caller[0]=="system":
		serverNotice(string)
	else:
		serverNotice("Notice from %s: %s" % (formatCaller(caller),string))
	return string
예제 #5
0
def CSserverNotice(caller, *strings):
	"""Allows the caller to make a server notice for all players in the server to see."""
	string=' '.join(strings)
	if caller[0]=="system":
		serverNotice(string)
	else:
		serverNotice("Notice from %s: %s" % (formatCaller(caller),string))
	return string
예제 #6
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)
예제 #7
0
def login(caller,*params):
        """This allows the caller to login to the server giving them the permission level that is allocated to them by the database."""
	username=None
	password=None
	
	if UserSessionManager[caller][0]!="notloggedin":
		username=UserSessionManager[caller][0]
		logout(caller)
	
	#extract username and password
	if len(params)==2:
		username=params[0]
		password=params[1]
	elif len(params)==1:
		password=params[0]
	
	#guess username
	if username is None:
		if caller[0]=="irc":
			user=userdatabase.search("irc nick",formatCaller(caller))
		elif caller[0]=="ingame":
			user=userdatabase.search("sauerbraten name",formatCaller(caller))
		else:
			raise ValueError("Could not determine your login name.")
		if user is None:
			raise ValueError("Could not determine your login name. Use \"@login username password\" to specify.")
	else:
		user=userdatabase[username]
	
	#temporarly cache the user instance
	userInterface=user
	user=dict(user.items())
	
	#authenticate with everything's that's available
	if password is None:
		if caller[0]=="irc":
			#call an ident message, TODO
			pass
		#check hostname TODO
	else:
		if hashPassword(password) in userInterface["password"]:
			succeedLogin(caller,user)
			return
	
	raise PermissionError("Denied to login.")
예제 #8
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)
예제 #9
0
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
예제 #10
0
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
예제 #11
0
파일: notices.py 프로젝트: amstan/hyperserv
def noticeRelinquishMaster(cn):
	serverNotice("%s relinquished master." % (formatCaller(("ingame",cn)),))
예제 #12
0
파일: notices.py 프로젝트: amstan/hyperserv
def noticeClaimMaster(cn):
	serverNotice("%s claimed main master." % (formatCaller(("ingame",cn)),))
예제 #13
0
파일: notices.py 프로젝트: amstan/hyperserv
def noticeClaimAdmin(cn):
	serverNotice("%s claimed main admin." % (formatCaller(("ingame",cn)),))
예제 #14
0
파일: irc.py 프로젝트: crcollins/hyperserv
def ircpm(caller,cn,msg):
	factory.notice(cn,"<"+formatCaller(caller)+"> "+msg)
예제 #15
0
파일: notices.py 프로젝트: amstan/hyperserv
def noticePlayerDisconnect(cn):
	serverNotice("Disconnected: "+formatCaller(("ingame",cn))+"("+str(cn)+")")
예제 #16
0
파일: irc.py 프로젝트: crcollins/hyperserv
def usercommunicationirc(caller,msg):
	if caller[0]=="irc":
		return
	factory.broadcast("<"+formatCaller(caller)+"> "+msg)
예제 #17
0
파일: notices.py 프로젝트: amstan/hyperserv
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)))
예제 #18
0
파일: notices.py 프로젝트: amstan/hyperserv
def noticePlayerUploadedMap(cn):
	serverNotice("%s has sent the map." % (formatCaller(("ingame",cn)),))
예제 #19
0
파일: notices.py 프로젝트: amstan/hyperserv
def noticePlayerKicked(caller,cn):
	serverNotice("%s got kicked by %s." % (formatCaller(("ingame",cn)),formatCaller(caller)))
예제 #20
0
파일: notices.py 프로젝트: amstan/hyperserv
def noticePlayerEditUnMuted(cn):
	serverNotice("%s is no longer edit muted." % (formatCaller(("ingame",cn)),))
예제 #21
0
파일: notices.py 프로젝트: amstan/hyperserv
def noticeRelinquishAdmin(cn):
	serverNotice("%s relinquished admin." % (formatCaller(("ingame",cn)),))
예제 #22
0
파일: base.py 프로젝트: crcollins/hyperserv
def noticeEditPacket(cn,packettype,*data):
	if config["editpacketnotices"]=="yes":
		serverNotice("Edit Packet from %s: %s %s" % (formatCaller(("ingame",cn)),packettypes[packettype][0],' '.join(map(str,data))))
예제 #23
0
파일: notices.py 프로젝트: amstan/hyperserv
def noticePlayerUnSpectated(cn):
	serverNotice("%s is no longer a spectator." % (formatCaller(("ingame",cn)),))
예제 #24
0
파일: notices.py 프로젝트: amstan/hyperserv
def noticeAuth(cn,name):
	serverNotice("%s authed as '%s'." % (formatCaller(("ingame",cn)),name))
예제 #25
0
파일: notices.py 프로젝트: amstan/hyperserv
def noticePlayerMuted(caller,boolean,target):
	if(boolean==1):
		serverNotice("%s is now muted." % (formatCaller(("ingame",target)),))
	else:
		serverNotice("%s is now unmuted." % (formatCaller(("ingame",target)),))
예제 #26
0
파일: notices.py 프로젝트: amstan/hyperserv
def noticeEditMute(cn):
	caller=("ingame",cn)
	playerCS.executeby(caller,"echo \"%s is edit muted. You can not edit.\"" % (formatCaller(caller)))
예제 #27
0
파일: notices.py 프로젝트: amstan/hyperserv
def noticePlayerKickFailed(caller,cn):
	serverNotice("%s attempted to kick %s but failed since %s is an %s." % (formatCaller(caller),formatCaller(("ingame",cn)),formatCaller(("ingame",cn)),UserSessionManager[("ingame",cn)][1]))
예제 #28
0
파일: notices.py 프로젝트: amstan/hyperserv
def noticeMute(cn):
	caller=("ingame",cn)
	playerCS.executeby(caller,"echo \"%s is muted. You cannot talk.\"" % (formatCaller(caller)))
예제 #29
0
파일: notices.py 프로젝트: amstan/hyperserv
def noticePlayerGetMap(cn):
	serverNotice("%s is getting the map." % (formatCaller(("ingame",cn)),))
예제 #30
0
파일: notices.py 프로젝트: amstan/hyperserv
def noticePlayerTeamChanged(cn):
	caller=("ingame",cn)
	serverNotice("%s changed team." % (formatCaller(caller)))