Beispiel #1
0
def authLogin(caller,authname):
	user=userdatabase.search("auth name",authname)
	if user is not None:
		succeedLogin(caller,dict(user.items()))
	else:
		if(config["authgainmaster"]=="yes"):
			systemCS.executestring("takemaster") #logout all other tiny masters
			setSimpleMaster(caller)
Beispiel #2
0
def succeedLogin(caller,user):
	UserSessionManager[caller]=(user["username"],user["privileges"])
	systemCS.executestring('notice "%s"' % escape("%s has logged in from %s as %s" % (formatCaller(caller), caller[0], user["username"])))
Beispiel #3
0
	def order(self,x):
		order=["server","db","irc","master"]
		for i,string in enumerate(order):
			if x.startswith('cfg "'+string):
				return "%3d%s" % (i,x)
		return x
	def __str__(self):
		return "\n".join(sorted(['cfg "%s" "%s"' % (escape(key), escape(value)) for key, value in self.items()],key=self.order))

config=CSConfig()

@CSCommand("writecfg","admin")
def writecfg(caller):
	"""Prints out all of the .cfg files associated with the server."""
	print "//writecfg by %s.\n%s" % (caller, config)

@CSCommand("cfg","admin")
def cfgEntry(caller,key,*values):
	"""Changes a value in the .cfg."""
	if len(values)>0:
		config[key]=' '.join(values)
	return config[key]

@CSCommand("cfgdel","admin")
def delEntry(caller,key):
	"""Deletes a value from the .cfg. """
	return config.pop(key)

systemCS.executestring(open("../../config.cfg","r").read())
print "Configuration loaded."
Beispiel #4
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))
Beispiel #5
0
def noclients():
	serverNotice("Server is now empty.")
	systemCS.executestring("mastermode %s" % (config["defaultmastermode"]))
Beispiel #6
0
from hypershade.bandatabase import bandatabase

from hypershade.util import formatCaller, ipLongToString

muted_cns=[]

def allow_message(cn,msg):
	if checkforCS(("ingame",cn),msg):
		return False
	if cn in muted_cns:
		triggerServerEvent("talk_blocked",[cn])
		return False
	return True
registerPolicyEventHandler('allow_message', allow_message)

systemCS.executestring("map %s %s" % (config["defaultmap"],config["defaultmode"]))
systemCS.executestring("mastermode %s" % config["defaultmastermode"])

@eventHandler('no_clients')
def noclients():
	serverNotice("Server is now empty.")
	systemCS.executestring("mastermode %s" % (config["defaultmastermode"]))

@eventHandler('player_message')
def PlayerMessage(cn,msg):
	triggerServerEvent("user_communication",[("ingame",cn),msg])

@eventHandler('echo')
def echoingame(caller,msg):
	if caller[0]=="ingame":
		sbserver.playerMessage(caller[1],"\f4%s" % msg)