Пример #1
0
def onCommand(cn, command):
	'''@description Translate text using Google translator
	   @usage text src_lang dest_lang
	   @public'''
	if count_player_requests(cn) < player_fd_limit:
		cmd_list = command.split()
		length = len(cmd_list)
		query = None
		lang1 = from_lang
		lang2 = to_lang
		if length == 0:
			sbserver.playerMessage(cn, red(fault_message))
		elif length == 1:
			query = cmd_list[0]
		elif length == 2:
			sbserver.playerMessage(cn, red(fault_message))
		elif length > 2:
			if is_lang(cmd_list[length-2],langslist) and is_lang(cmd_list[length-1],langslist):
				query = "%20".join(cmd_list[:length-2])
				lang1 = cmd_list[length-2]
				lang2 = cmd_list[length-1]
			else:
				sbserver.playerMessage(cn, red(fault_message))
		if query:
			sd = SocketDispatch(host, port, header, url, pattern, cn)
			sd.write(query, lang1, lang2)
			add_request(cn, sd)
	else:
		sbserver.playerMessage(cn, red("Please wait for your translations to be handled before submitting new ones"))
Пример #2
0
def warnNickReserved(cn, count, sessid):
	try:
		p = player(cn)
	except ValueError:
		return
	try:
		nickacct = p.warn_nickacct
		if nickacct.nick != sbserver.playerName(cn) or sessid != sbserver.playerSessionId(cn):
			p.warning_for_login = False
			return
	except (AttributeError, ValueError):
		p.warning_for_login = False
		return
	if isLoggedIn(cn):
		user = loggedInAs(cn)
		if nickacct.user_id != user.id:
			ban(cn, 0, 'Use of reserved name', -1)
		p.warning_for_login = False
		return
	if count > 4:
		ban(cn, 0, 'Use of reserved name', -1)
		p.warning_for_login = False
		return
	remaining = 25-(count*5)
	sbserver.playerMessage(cn, warning('Your name is reserved. You have ' + red('%i') + ' seconds to login or be kicked.') % remaining)
	addTimer(5000, warnNickReserved, (cn, count+1, sessid))
Пример #3
0
def warnTagReserved(cn, count, sessid, nick):
	try:
		p = player(cn)
	except ValueError:
		return
	if p.name() != nick or sessid != p.sessionId():
		return
	if len(p.registered_tags) == 0:
		return
	if count > 4:
		ban(cn, 0, 'Use of reserved clan tag', -1)
		p.warning_for_login = False
		return
	remaining = 25-(count*5)
	p.message(warning('Your are using a reserved clan tag. You have ' + red('%i') + ' seconds to login or be kicked.') % remaining)
	addTimer(5000, warnTagReserved, (cn, count+1, sessid, nick))
Пример #4
0
def onCommand(cn, command):
			sbserver.playerMessage(cn, green(command) + green(": ") + red(commands[command]))