Luadch - Help 0.01

Post finished Hubside Scripts here, known supporting hubsofts for LUA scripting.

ADCH++ | DCWatch | LUADCH
Post Reply
Toast

Luadch - Help 0.01

Post by Toast » 30 Mar 2008, 13:12

Code: Select all

--[[

		help.lua v0.01 by Toast

]]--

local check_failed = function( user, rank )
	if not user:isRegged( ) or user:getRank( ) < rank then		
		return true			
	end
	return false
end

hub:setListener( "onLogin", { }, 								
	function( p )
		local user = p.user
		if user:supports( "UCMD" ) or user:supports( "UCM0" ) then
			if hub:getCfg( "nick_change" ) then
				user:send( "ICMD Nick\\sChange TTBMSG\\s%[mySID]\\s+nick\\\\s%[line:Nick]\\n CT1\n" )	--// send usercommand
			end
			if not check_failed( user, hub:getCfg "admin_rank" ) then 
				user:send( "ICMD Reg\\suser TTBMSG\\s%[mySID]\\s+reg\\\\s%[userCID]\\\\s%[line:Password]\\\\s%[line:Level]\\n CT2\n" )				
			end
		end
		return nil
	end

)

hub:setListener( "onBroadcast", { }, 								--// chatarrival..
	function( p )
		local user, cmd = p.user, p.cmd	
		local adc_msg = cmd:param( 3 )							--// text, adc formated
		local msg = hub:escapeFrom( adc_msg )						--// text, normal formated
		--hub:debug( "Escaped ADC msg: ", msg )						--// debugs to hub cl..
		--hub:debug( "Normal string: ", hub:escapeFrom( msg ) )	
		return nil	
	end
)

hub:setListener( "onBroadcast", { }, 									
	function( p )
		local user, cmd = p.user, p.cmd		
		local msg = hub:escapeFrom( cmd:param( 3 ) ) or ""				
		local command, parameters = utf.match( msg, "^[+!#](%a+) ?(.*)" )
		if command == "help" then
		user:reply{ msg = "Help Commands", from = hub:getBot( ) }
		user:reply{ msg = "!Kick - usage: [+!#]kick <sid> [<time> <reason>]", from = hub:getBot( ) }
		user:reply{ msg = "!Killscripts- usage: [+!#]killscripts", from = hub:getBot( ) }
		user:reply{ msg = "!Mass- usage: [+!#]mass <message>", from = hub:getBot( ) }
		user:reply{ msg = "!Nick- usage: [+!#]nick <nick>", from = hub:getBot( ) }
		user:reply{ msg = "!Regnick- usage: [+!#]regnick <nick> <password> <level>", from = hub:getBot( ) }
		user:reply{ msg = "!Reloadcfg- usage: [+!#]reloadcfg", from = hub:getBot( ) }
		user:reply{ msg = "!Restart- usage: [+!#]restart", from = hub:getBot( ) }
		user:reply{ msg = "!Restarthub- usage: [+!#]restarthub", from = hub:getBot( ) }
		user:reply{ msg = "!Shutdown- usage: [+!#]shutdown", from = hub:getBot( ) }
		user:reply{ msg = "!Sid- usage: [+!#]sid <option> <argument>", from = hub:getBot( ) }
			return PROCESSED
		elseif command == "regcid" then
			if check_failed( user, hub:getCfg "op_rank" ) then user:reply{ msg = "You are not allowed to use this command.", from = hub:getBot( ) } return PROCESSED end				
			local cid, password, rank = utf.match( parameters, "^(%S+) (%S+) (%d+)" )
			rank = tonumber( rank )
			if not ( cid and password and rank ) then
				user:reply{ msg = "Usage: +regcid <cid> <password> <rank>", from = hub:getBot( ) }
				return PROCESSED
			end
			if user:getRank( ) < rank then
				user:reply{ msg = "Rank must be lower than " .. rank .. ".", from = hub:getBot( ) }
				return PROCESSED
			end		
			user:reply{ msg = hub:regUser{ cid = cid, hash = "TIGR", password = password, rank = rank }, from = hub:getBot( ) } 		
			return PROCESSED
		end
		return nil			
	end
)

hub:debug( "** Loaded help.lua **" )

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest