PtokaX forum

PtokaX => Feature Proposals => Topic started by: hermaniii on 01 December, 2007, 21:50:17

Title: command for search in reguser
Post by: hermaniii on 01 December, 2007, 21:50:17

Search in all registerd users with part off the name and get a list off users that matches.
maybe something to add directly to the soft?

!find <part_of_nick>  or  !search/!finduser

min 2 char for search

//Herman
Title: Re: command for search in reguser
Post by: bastya_elvtars on 01 December, 2007, 22:10:33
This is for the new API:
-- RegSearch by bastya_elvtars
-- Requested by hermaniii

command = "searchreg" -- no trailing prefix!
minlen = 2 -- minimum search length

-- don't edit below

function ChatArrival (user, data)
  local cmd,str=data:match("^%b<>%s+[%!%+%#%?%-](%S+)%s(%S+)%|$")
  -- We are parsing the command here
  if cmd == command then
    if str:len() < 2 then
      Core.SendToUser(user, "<RegSearch> Search string must be at least "..minlen.." characters long!|")
    else
      local found
      local rettbl = {}
      local regusers = RegMan.GetRegs()
      for _,reg in ipairs(regusers) do
        if reg.sNick:find(str) then
          rettbl[reg.sNick] = ProfMan.GetProfile(reg.iProfile).sProfileName
          found = true
        end
      end
      if found then
        local msg = "<RegSearch> Found the following users:\r\n\r\n"..("-"):rep(60).."\r\n"
        for nick, prof in pairs (rettbl) do
          msg=msg..nick.."\t".."(Profile: "..prof..")\r\n"
        end
        msg=msg..("-"):rep(60).."|"
        Core.SendToUser(user,msg)
      end
    end
    return true
  end
end
Title: Re: command for search in reguser
Post by: hermaniii on 02 December, 2007, 00:52:30

:/ was not a script req.
Have it already in my hub but thought it could be a good feature for the soft.

//Herman
Title: Re: command for search in reguser
Post by: bastya_elvtars on 02 December, 2007, 00:55:00
I think this should be done by a script, that's why Px has a nice scripting interface. Things that get into the main hubsoft are usually impossible or too slw via the Lua interface. And don't be so lazy to add a script. :P