--[[ etc_usercommands.lua v0.01 by blastbeat - this script exports a module to reg usercommands ]]-- --// settings begin //-- local toplevelmenu = "Luadch Commands" --// settings end //-- local commands = { } local level = { } local sep = [[\]] -- accordings the UCMD specs this should be '/' but it doesnt work in dc++ local add = function( menu, command, params, flags, llevel ) -- quick and dirty... table.insert( menu, 1, toplevelmenu ) local menu = hub.escapeto( table.concat( menu, sep ) ) -- create ucmd name with submenus local ucmd = "ICMD " .. menu --hub.debug( ucmd ) ucmd = ucmd .. " TTBMSG\\s%[mySID]\\s+" ucmd = ucmd .. hub.escapeto( hub.escapeto( command .. " " .. table.concat( params, " " ) ) .. "\n" ) ucmd = ucmd .. " " .. table.concat( flags, " " ) .. "\n" assert( not level[ ucmd ] ) -- names are unique level[ ucmd ] = llevel --hub.debug( ucmd ) commands[ #commands + 1 ] = ucmd end hub.setlistener( "onLogin", { }, function( user ) --if user:supports( "UCMD" ) or user:supports( "UCM0" ) then -- BCDC 0.699 supports it, but doesnt send a sup local userlevel = user:level( ) for i, ucmd in ipairs( commands ) do if level[ ucmd ] <= userlevel then user.write( ucmd ) end end --end return nil end ) hub.debug( "** Loaded etc_usercommands.lua **" ) --// public //-- --addcommand( { "Misc", "Userinfo", }, "userinfo", { "%[line:Nick]", "%[line:Nick]" }, { "CT1" }, 100 ) return { add = add, }