Example #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
Example #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.")
Example #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
Example #4
0
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
Example #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
Example #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)
Example #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.")
Example #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)
Example #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
Example #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
Example #11
0
def noticeRelinquishMaster(cn):
	serverNotice("%s relinquished master." % (formatCaller(("ingame",cn)),))
Example #12
0
def noticeClaimMaster(cn):
	serverNotice("%s claimed main master." % (formatCaller(("ingame",cn)),))
Example #13
0
def noticeClaimAdmin(cn):
	serverNotice("%s claimed main admin." % (formatCaller(("ingame",cn)),))
Example #14
0
def ircpm(caller,cn,msg):
	factory.notice(cn,"<"+formatCaller(caller)+"> "+msg)
Example #15
0
def noticePlayerDisconnect(cn):
	serverNotice("Disconnected: "+formatCaller(("ingame",cn))+"("+str(cn)+")")
Example #16
0
def usercommunicationirc(caller,msg):
	if caller[0]=="irc":
		return
	factory.broadcast("<"+formatCaller(caller)+"> "+msg)
Example #17
0
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)))
Example #18
0
def noticePlayerUploadedMap(cn):
	serverNotice("%s has sent the map." % (formatCaller(("ingame",cn)),))
Example #19
0
def noticePlayerKicked(caller,cn):
	serverNotice("%s got kicked by %s." % (formatCaller(("ingame",cn)),formatCaller(caller)))
Example #20
0
def noticePlayerEditUnMuted(cn):
	serverNotice("%s is no longer edit muted." % (formatCaller(("ingame",cn)),))
Example #21
0
def noticeRelinquishAdmin(cn):
	serverNotice("%s relinquished admin." % (formatCaller(("ingame",cn)),))
Example #22
0
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))))
Example #23
0
def noticePlayerUnSpectated(cn):
	serverNotice("%s is no longer a spectator." % (formatCaller(("ingame",cn)),))
Example #24
0
def noticeAuth(cn,name):
	serverNotice("%s authed as '%s'." % (formatCaller(("ingame",cn)),name))
Example #25
0
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)),))
Example #26
0
def noticeEditMute(cn):
	caller=("ingame",cn)
	playerCS.executeby(caller,"echo \"%s is edit muted. You can not edit.\"" % (formatCaller(caller)))
Example #27
0
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]))
Example #28
0
def noticeMute(cn):
	caller=("ingame",cn)
	playerCS.executeby(caller,"echo \"%s is muted. You cannot talk.\"" % (formatCaller(caller)))
Example #29
0
def noticePlayerGetMap(cn):
	serverNotice("%s is getting the map." % (formatCaller(("ingame",cn)),))
Example #30
0
def noticePlayerTeamChanged(cn):
	caller=("ingame",cn)
	serverNotice("%s changed team." % (formatCaller(caller)))