--[[ cmd_userinfo.lua v0.01 by blastbeat - this script adds a command "userinfo" get infos about an user - usage: [+!#]userinfo sid|nick|cid || - no arguments means you get info about yourself ]]-- --// settings begin //-- local permission = { --// [ user_level = level means user_level can get info about users with level max //-- [ 0 ] = -1, -- cant use it [ 40 ] = 10, -- svip to guest [ 60 ] = 30, -- operator to vip [ 80 ] = 40, -- admin to svip [ 100 ] = 100, -- hubowner can get info about all } local msg_denied = "You are not allowed to use this command." local msg_usage = "Usage: [+!#]userinfo sid|nick|cid ||" local msg_off = "User not found." local msg_god = "You cannot investigate gods." local cmd = "userinfo" --// settings end //-- local utf_match = utf.match local hub_getbot = hub.getbot local hub_issidonline = hub.issidonline local hub_iscidonline = hub.iscidonline local hub_isnickonline = hub.isnickonline hub:setListener( "onStart", { }, function( ) local help = hub.import "cmd_help" if help then help.reg( "userinfo", "[+!#]userinfo sid|nick|cid ||", "get info about an user by sid or nick or cid; no arguments -> about yourself", 0 ) end return nil end ) hub:setListener( "onBroadcast", { }, function( user, adccmd, txt ) local command, parameters = utf_match( txt, "^[+!#](%a+) ?(.*)" ) if command == cmd then local level = user:getLevel( ) if permission[ level ] == -1 then user:reply( msg_denied, hub.getbot( ) ) return PROCESSED end local same local by, id = utf_match( parameters, "^(%S+) (.*)" ) local target if not ( (by == "sid" or by == "nick" or by == "cid" ) and id ) then target = user same = true else target = ( by == "nick" and hub_isnickonline( id ) ) or ( by == "sid" and hub_issidonline( id ) ) or ( by == "cid" and hub_iscidonline( id ) ) end if not target then user:reply( msg_off, hub_getbot( ) ) return PROCESSED end if not same and ( ( permission[ level ] or 0 ) < target:getLevel( ) ) then user:reply( msg_god, hub_getbot( ) ) return PROCESSED end local pass = "" local regged = target:isRegged( ) if regged then if target == user or level == 100 then -- for hubowner only pass = target:getPas( ) or "" end end local tmp = "" .. "\n\nUserinfo:\n\n" .. "Nick:\t " .. target:getNick( ) .. "\n" .. "1. Nick:\t " .. target:getFirstNick( ) .. "\n" .. "Desc: \t" .. target.getDesc( ) .. "\n" .. "Sid: \t" .. target:getSid( ) .. "\n" .. "Cid:\t " .. target:getCid( ) .. "\n" .. "Hash: \t" .. target:sessionHash( ) .. "\n" .. "Ip:\t " .. target:getIp( ) .. "\n" .. "Port:\t " .. target:getPort( ) .. "\n" .. "Srvport:\t " .. target:getServerPort( ) .. "\n" .. "SSL:\t " .. tostring( target:ssl( ) ) .. "\n" .. "Bot:\t " .. tostring( target:isBot( ) ) .. "\n" .. "Rank:\t " .. target:getRank( ) .. "\n" .. "Level:\t " .. target:getLevel( ) .. "\n" .. "Regged:\t " .. tostring( regged ) .. "\n" .. "Pass: \t " .. pass .. "\n" hub.debug( tmp ) user:reply( tmp, hub_getbot( ) ) return PROCESSED end return nil end ) hub.debug( "** Loaded cmd_userinfo.lua **" )