PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: Ubikk on 21 December, 2004, 10:51:46

Title: whois scripts
Post by: Ubikk on 21 December, 2004, 10:51:46
Is there anyone out there who can provide me with a "whois " script?
The function is the same as in mIRC

For example when I type !whois , I get:

has been idle for 23 minutes, 12 seconds

idle = hasnt sent any msg to mainchat or PM

is it possible to do that?
Title:
Post by: BoJlk on 21 December, 2004, 11:19:39
in RoboCop script is command
!info    - Show all info about a user

for Example
==========================
                ? Info ?
==========================
? Name: nick
? Profile: User
? IP: ***.***.***.***
? Client: DC++
? Version: 0.401
? iVersion: 1,0091
? Descr: <++ V:0.401,M:A,H:6/0/0,S:5>
? Mode: Active
? Conn: Cable
? E-Mail:
? Upload limit: Unlimited
? Share: 56.37 GB

? Kicked: 1
? bWho: *****
? Reason: Connection timeout 10 times
? Warned: No warnings
? bWho: None
? Reason: None
? Away Mess: No message
? Connected at: N/A
? Total Time: 32
? Session Time: 32 Minutes

? Hub(s) as Operator: 0
? Hub(s) as Registered user: 0
? Hub(s) as Regular user: 6
? Open Slots: 5

There's another user info script by lallo82
just copy past into notepad and save as *.lua file

-- user info script by lallo82
-- functions by plop (great work)

Bot = "[BOT]UserInfo?"

function Main()
   frmHub:RegBot(Bot)
end

function DataArrival(user, data)
   if( strsub(data, 1, 1) == "<" ) then
      -- remove end pipe
      data=strsub(data,1,strlen(data)-1)
      -- parse the command
      s,e,cmd = strfind( data, "%b<>%s+(%S+)" )
      if (user.bOperator) then
         if (cmd=="+userinfo" or cmd=="+whois" ) then
            UserInfo(user, data)
            return 1
         end
      end
   end
end

function GetArgML(data)
   s,e,cmd,arg = strfind(data, "%b<>%s+(%S+)%s+(%S+)%s*")
   return arg
end

function UserInfo(user, data)
   who=GetArgML(data)
   local usr = GetItemByName(who)
   user:SendPM(Bot, "here is the info from: "..who.." |")
   -- now whe know the user lets extract the info
   -- ip of the user
   user:SendPM(Bot, "ip: "..usr.sIP.." |")
   -- client type and version
   if (strfind(usr.sMyInfoString,"      _,b, dcgui = strfind(usr.sMyInfoString,"V:0.(%x+.%x+)")
      user:SendPM(Bot, "DCgui version: 0."..dcgui.." |")
   elseif (strfind(usr.sMyInfoString,"<+")) then
      if strfind(usr.sMyInfoString,"         clienttype = "oDC"
      elseif strfind(usr.sMyInfoString,"V:0.%x+%a") then
         clienttype = "czdc++"
      elseif strfind(usr.sMyInfoString,"L:") or strfind(usr.sMyInfoString,"B:") then
         clienttype = "bcdc++"
      else
         clienttype = "dc++"
      end
      _,b, dcver = strfind(usr.sMyInfoString,"V:0.(%x+)")
      user:SendPM(Bot, clienttype.." client |")
      user:SendPM(Bot, "version: 0."..dcver.." |")
   end
   -- active or pasive
   if strfind(usr.sMyInfoString,"M:A") then
      mode = "active"
   else
      mode = "pasive"
   end
   user:SendPM(Bot, mode.." mode |")
   -- hub info
   _,b, guest = strfind(usr.sMyInfoString,"H:(%x+)/")
   if guest == nil then
      _,b, hubs = strfind(usr.sMyInfoString,"H:(%x+)")
      user:SendPM(Bot, hubs.." - hub(s) |")
   else
      _,b, regged = strfind(usr.sMyInfoString,"H:%x+/(%x+)/")
      _,b, opped = strfind(usr.sMyInfoString,"H:%x+/%x+/(%x+)")
      user:SendPM(Bot, guest.." - hub(s) as regular user |")
      user:SendPM(Bot, regged.." - hub(s) as registered user |")
      user:SendPM(Bot, opped.." - hub(s) as operator |")
   end
   -- slot info
   _,b, slots = strfind(usr.sMyInfoString,"S:(%x+)")
   user:SendPM(Bot, slots.." - slot(s) |")
   -- bandwidth upload limiter
   if strfind(usr.sMyInfoString,"L:") or strfind(usr.sMyInfoString,"B:") then
      _,b, limiter = strfind(usr.sMyInfoString,"B:(%x+)")
      if limiter == nil then
         _,b, limiter = strfind(usr.sMyInfoString,"L:(%x+)")
         if limiter == nil then
            _,b, limiter = strfind(usr.sMyInfoString,"U:(%x+)")
            if limiter == nil or limiter == "*" then
               limiter = "not limited"
            end
         end
      end
      if tonumber(limiter) ~= nil then
         if strlen(limiter) > 4 then
            limiter = limiter / 1024
         end
      end
      user:SendPM(Bot, "upload limited: "..limiter.." Kb/s |")
   end
   -- bandwidth download limiter
   _,b, dlimiter = strfind(usr.sMyInfoString,"D:(%x+)")
   if dlimiter ~= nil then
      user:SendPM(Bot, "download limited: "..dlimiter.." Kb/s |")
   end
end

and another one by NightLitch
-------------------------------------------------
-- iNFO-Bot Written by NightLitch
-------------------------------------------------
-- Usage:
--
-- [USER] = username, [IP] = ip, [HUB] = hubname, [CLIENT] = client, [VERSION] = client version,
--
-- [MODE] = client mode, [HUBS] = hubs, [SLOTS] = slots, [BANDWIDTH] = bandwidth,
--
-- [SHARE] = share (in GB), [SPEED] = speed
--
-------------------------------------------------
--// Set your filename here
MODT_FILE = "Text-Info.txt"
-------------------------------------------------
--// Don't edit below unless you do now what you're doing...
-------------------------------------------------
function NewUserConnected(sUser)
-- Code part here
end
OpConnected = NewUserConnected
function NewUserConnected(sUser)
local MyI,Speed,Share = ParseMyInfo(sUser.sMyInfoString)
local MODT_LINE = TextFile(MODT_FILE)
MODT_LINE = gsub(MODT_LINE, "%b[USER]", sUser.sName)
MODT_LINE = gsub(MODT_LINE, "%b[IP]", sUser.sIP)
MODT_LINE = gsub(MODT_LINE, "%b[HUB]", frmHub:GetHubName())
MODT_LINE = gsub(MODT_LINE, "%b[CLIENT]", MyI["C"])
MODT_LINE = gsub(MODT_LINE, "%b[VERSION]", MyI["V"])
MODT_LINE = gsub(MODT_LINE, "%b[MODE]", MyI["M"])
MODT_LINE = gsub(MODT_LINE, "%b[HUBS]", MyI["H"])
MODT_LINE = gsub(MODT_LINE, "%b[SLOTS]", MyI["S"])
MODT_LINE = gsub(MODT_LINE, "%b[BANDWIDTH]", MyI["B"])
MODT_LINE = gsub(MODT_LINE, "%b[SHARE]", format("%.2f",Share/1024/1024/1024))
MODT_LINE = gsub(MODT_LINE, "%b[SPEED]", Speed)

SendToNick(sUser.sName,MODT_LINE)
end

function TextFile(file)
readfrom(file, "r")
local message = ""
while 1 do
local line = read()
if line == nil then break
else
message = message..line.."\n"
end
end
readfrom()
return message
end

function ParseMyInfo(MyInfo)
Hubs = 0
local s,e,Speed,Share = strfind(MyInfo, "^%$MyINFO %$ALL [^ ]+ [^$]*%$ $([^$]+)[^$]%$[^$]*%$%s*(%d+)%$" )
local s,e,Mode,tHubs,Slots = strfind(MyInfo, "M:([5AP]),H:([%d%/]+),S:(%d+)")
if tonumber(tHubs) == nil then gsub(tHubs, "(%d+)", function (num) Hubs = Hubs +tonumber(num) end) else Hubs = tonumber(tHubs) end
local s,e,Bandwidth = strfind(MyInfo, "[BLUF]:([%.%d]+)")
local Client,Check,MinVer, Version = "Unknown",nil,nil,0
for c,t in CLIENTS do
if strfind(MyInfo, c) then
Client = t[2]
s,e,Version = strfind(MyInfo, t[1])
end
end
if Client=="DCGUI" and tonumber(Bandwidth) then Bandwidth = Bandwidth * Slots end
if Bandwidth==nil then Bandwidth = "Unlimited" end
if strfind(MyInfo, "L:") then
if not Client=="Strong DC++" then Client = "CZDC++" end
elseif strfind(MyInfo, "B:") then
if not Client=="Phantom DC++" then Client = "Bear Claw DC++" end
end
MyI = {["C"] = Client, ["V"] = Version, ["M"] = MODE[tostring(Mode)], ["H"] = tonumber(Hubs), ["S"] = tonumber(Slots), ["B"] = Bandwidth}
return MyI,Speed,tonumber(Share)
end

CLIENTS = {
["<++"] = {"V:([%d%.]+)", "DC++"},
["oDC"] = {"V:([%d%.]+)", "oDC"},
["", "oDC"},
[" [" ["http://dc.ketelhot.de"] = {"V:([%d%.]+)", "DCGUI"},
[" [" [" ["", "iDC++"},
["zDC++"] = {"V:([%d%.]+)", "zDC++"},
[" ["", "DC++ CDM"},
["<.P"] = {"V:([%d%.]+)", "Phantom DC++"},
}
MODE = {["5"] = "Socket5", ["A"] = "Active", ["P"] = "Passive"}
Title:
Post by: Ubikk on 21 December, 2004, 11:51:06
lol :)

I dont care about the user info. I already have a scripts for that.
All I want to know is if there is possible to make a scripts wich shows you the idle time of a user ;)
Title:
Post by: Ubikk on 23 December, 2004, 08:54:29
hey... can't anyone help me ?! :( Is it that difficult?
Title:
Post by: blackwings on 23 December, 2004, 10:21:17
QuoteOriginally posted by Ubikk
hey... can't anyone help me ?! :( Is it that difficult?
lol, a WhoIs is totally different from what you're asking for. Probably the elite programmers ignore the thread because either a WhoIs cannot be done or they ignore it because it would consume allot of time making one.

A more proper name for the command would be=
!tidletime (tidletime is short for "total idle time")

So create and new thread with a better topic and rewrite your question, then you might get some attention from the elite ones.
Title:
Post by: NightLitch on 23 December, 2004, 17:11:16
Mery Christmas Ubikk...

*code updated*

--###############################################--
-- Idle - Users -- By NightLitch 2004-12-23 --
--###############################################--
BotName = "InfoBot"
TableCommand = "!whois"
--###############################################--
IdleTimers = {}
--###############################################--
function DataArrival(sUser,sData)
if strsub(sData, 1,1) == "<" then
local _,_,Cmd,Arg = strfind(sData, "%b<>%s+(%S+)%s*(.*)%|")
if Command[Cmd] and sUser.bOperator then
return Command[Cmd](sUser,Arg)
end
IdleTimers[sUser.sName] = clock()
elseif strsub(sData,1,4) == "$To:" then
local s,e,WhoTo,From,Msg = strfind(sData,"%$To:%s+(%S+)%s+From:%s+(%S+)%s+%$%b<>%s+(.*)%|")
IdleTimers[From] = clock()
end

end--###############################################--
Command = {}
Command[TableCommand] = function(sUser,sArg)
local _,_,Nickname = strfind(sArg, "(%S+)")
if Nickname == nil then sUser:SendData(BotName, "Syntax: !table ") return 1 end
local tUser = GetItemByName(Nickname)
if tUser == nil then sUser:SendData(BotName, "User "..Nickname.." is not online or wrong username.") return 1 end
if IdleTimers[tUser.sName] then
iTime = clock() - IdleTimers[tUser.sName]
sUser:SendData(BotName, "User "..tUser.sName.." has been idle for "..TimeUnits(iTime))
else
sUser:SendData(BotName, "User "..tUser.sName.." haven't typed anything at all...")
end
return 1
end
--###############################################--
TimeUnits = function(time)
local time = time*1000
local msg = ""
local tO = {
[1] = { 86400000, 0, "days"},
[2] = { 3600000, 0, "hours"},
[3] = { 60000, 0, "minutes"},
[4] = { 1000, 0, "seconds"},
};
for i , v in (tO) do
if time >= tO[i][1] then
repeat
tO[i][2] = tO[i][2] + 1
time = time - tO[i][1]
until time < tO[i][1]
end
end
for i,v in tO do
if tO[i][2] ~= 0 then
msg = msg.." "..tO[i][2].." "..tO[i][3]
end
end
if msg == "" then msg = "0 minutes" end
return msg
end
--###############################################--
--// NightLitch 2004-12-23

Mery Christmas // NightLitch
Title:
Post by: kepp on 23 December, 2004, 20:34:00
Will give errors night :)
Title:
Post by: NightLitch on 23 December, 2004, 21:16:36
really where ???
Title:
Post by: Ubikk on 24 December, 2004, 00:05:22
Your script is great NightLich, but can you make it work for PM also? :) Atm, it only works for mainchat ;)
Title:
Post by: NightLitch on 24 December, 2004, 04:40:13
above code updated...