Author Topic: command for search in reguser  (Read 2246 times)

0 Members and 1 Guest are viewing this topic.

Offline hermaniii

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
command for search in reguser
« 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

PtokaX forum

command for search in reguser
« on: 01 December, 2007, 21:50:17 »

Offline bastya_elvtars

  • Forum God
  • ****
  • Posts: 3 752
  • Karma: +173/-7
  • The rock n' roll doctor
    • The FreshStuff3 Site
Re: command for search in reguser
« Reply #1 on: 01 December, 2007, 22:10:33 »
This is for the new API:
Code: [Select]
-- 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
Everything could have been anything else and it would have just as much meaning.

Offline hermaniii

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
Re: command for search in reguser
« Reply #2 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

Offline bastya_elvtars

  • Forum God
  • ****
  • Posts: 3 752
  • Karma: +173/-7
  • The rock n' roll doctor
    • The FreshStuff3 Site
Re: command for search in reguser
« Reply #3 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
Everything could have been anything else and it would have just as much meaning.

PtokaX forum

Re: command for search in reguser
« Reply #3 on: 02 December, 2007, 00:55:00 »