PtokaX forum

Archive => Archived 5.0 boards => Finished Scripts => Topic started by: NightLitch on 14 May, 2005, 16:20:49

Title: *** Standalone Userinfo Database
Post by: NightLitch on 14 May, 2005, 16:20:49
here is a little something from me to you all that want to use it:

--###------------------------------------------------------###--
--       Standalone Userinfo Database
--       Created by NightLitch (2005)
--###------------------------------------------------------###--
tSet = {}
tSet.BotName = "-Database-"
tSet.Weeks = 2
--###------------------------------------------------------###--
sMyINFO = {}
sTIME = {}
sIP = {}

tFunc = {}
tFunc.LoadFile = function(filename,table)
local file,err = io.open(filename, "r")
if err then tFunc.SaveFile(filename, table) return 1 end
for line in file:lines() do
local s,e,nick,value = string.find(line, "(%S+)%|(.*)")
if nick and value ~= "" then
table[nick] = value
end
end
file:close()
end
tFunc.SaveFile = function(filename,table)
local file,err = io.open(filename, "w")
for nick, value in table do
file:write(nick.."|"..value.."\n")
end
file:close()
end
tFunc.Add = function(nick,value,table)
table[nick] = value
end
tFunc.Remove = function(nick,value,table)
table[nick] = nil
end
tFunc.GetTime = function()
local T = {}
for a,b in os.date("*t") do T[a] = b end
local time = os.time({year = T.year,month = T.month,day = (T.day+(tSet.Weeks*7)),hour = T.hour,min = T.min,sec = T.sec,isdst = T.isdst})
return time
end
tFunc.Cleaner = function()
local t,c = 0,0
for sNick,sTime in sTIME do
t = t + 1
if os.time() > tonumber(sTime) then
c = c + 1
sTIME[sNick] = nil
sMyINFO[sNick] = nil
sIP[sNick] = nil
end
end
OnExit()
return "*** "..c.." / "..t.." users have been deleted from database ***"
end
tFunc.List = function()
local line = "\r\n"
line = line .. "\r\n -----###-----------------------------------------------------------------------------------------------------------------------------------------------------------------###-----"
line = line .. "\r\n                    # Current Clean List #       "
line = line .. "\r\n -----###-----------------------------------------------------------------------------------------------------------------------------------------------------------------###-----"
for sNick,sTime in sTIME do
if os.time() > tonumber(sTime) then
line = line .. "\r\n\t "..sNick.." is last seen "..os.date("%A %d %B %Y (%H:%M:%S)", tonumber(sTime))
end
end
line = line .. "\r\n -----###-----------------------------------------------------------------------------------------------------------------------------------------------------------------###-----"
return line
end
tFunc.Online = function(nick)
if GetItemByName(nick) then return "Online" else return "Offline" end
end
tFunc.Find = function(value)
if string.find(value, "%d+%.%d+%.%d+%.%d+") then
local line = "*** Users found on IP: "..value..": \r\n\r\n"
for nick,ip in sIP do
if ip == value then
line = line .. "\t "..nick.."  ("..tFunc.Online(nick)..")\r\n"
end
end
return line
else
local tUser = GetItemByName(value)
if tUser then
return tUser
else
for nick,ip in sIP do
if string.lower(value) == string.lower(nick) then
return {sName = nick, sIP = sIP[nick], sMyInfoString = sMyINFO[nick]}
end
end
end
end
return
end
tFunc.SplitMyInfoString = function(MyINFO,table)
    local _,_,Descr,Speed,Mail,Share = string.find(MyINFO, "%$MyINFO %$ALL %S+ (.*)%$ %$(.*)%$(%S*)%$%s*(%-*%d*)%$%|$")
    local _,_,Tag = string.find(Descr, "(%b<>)$")
    Tag = Tag or ""
    Descr = string.sub(Descr, 1,string.len(Descr) - string.len(Tag))
    Speed = string.sub(Speed, 1,string.len(Speed) - 1)
    table["sDescription"] = Descr table["sTag"] = Tag table["sConnection"] = Speed table["sEmail"] = Mail table["iShareSize"] = tFunc.ShareUnit(tonumber(Share))
if Tag == "" then return table end
local Limiter = {["B"] = "(%d+)",["L"] = "(%d+)",["F"] = "%d+%/(%d+)"}
local Mode = {["A"] = "Active",["P"] = "Passive", ["5"] = "Socket"}
local TagString, TagTable = Tag, {}
TagString = string.sub(TagString,1,string.len(TagString)-1)
TagString = TagString..","
string.gsub( TagString, "(.):([^,]+),", function( letter, value ) if letter == "O" then return "" end if Limiter[letter] then _,_,value = string.find(value, Limiter[letter]) end TagTable[letter] = value end)
local _,_,sClient = string.find(TagString, "^(<%S+)%s+")
hubs = 0
if tonumber(TagTable["H"]) == nil then string.gsub(TagTable["H"], "(%d+)", function (num) hubs = hubs +tonumber(num) end) else hubs = tonumber(TagTable["H"]) end
table["sClient"] = sClient
table["sClientVersion"] = TagTable["V"]
table["sMode"] = Mode[TagTable["M"]]
table["iBlimit"] = TagTable["B"] or TagTable["L"] or TagTable["F"] or "unlimited"
table["iSlots"] = TagTable["S"]
table["iHubs"] = hubs
return table
end
tFunc.ShareUnit = function(intSize)
if tonumber(intSize) ~= 0 then
local tUnits = { "Bytes", "KB", "MB", "GB", "TB" }
intSize = tonumber(intSize);
local sUnits;
for index = 1, table.getn(tUnits) do
if(intSize < 1024) then
sUnits = tUnits[index];
break;
else
intSize = intSize / 1024;
end
end
return string.format("%0.1f %s",intSize, sUnits);
else
return "0 Bytes"
end
end

function NewUserConnected(sUser)
tFunc.Add(sUser.sName,sUser.sIP, sIP)
tFunc.Add(sUser.sName,sUser.sMyInfoString, sMyINFO)
tFunc.Add(sUser.sName,tFunc.GetTime(), sTIME)
end

function UserDisconnected(sUser)
tFunc.Add(sUser.sName,sUser.sIP, sIP)
tFunc.Add(sUser.sName,sUser.sMyInfoString, sMyINFO)
tFunc.Add(sUser.sName,tFunc.GetTime(), sTIME)
end

OpConnected = NewUserConnected
OpDisconnected = UserDisconnected

function Main()
tFunc.LoadFile("sMyINFO.dat", sMyINFO)
tFunc.LoadFile("sIP.dat", sIP)
tFunc.LoadFile("sTIME.dat", sTIME)
end

function OnExit()
tFunc.SaveFile("sMyINFO.dat", sMyINFO)
tFunc.SaveFile("sIP.dat", sIP)
tFunc.SaveFile("sTIME.dat", sTIME)
end

function ChatArrival(sUser,sData)
local _,_,Cmd,Arg = string.find(sData, "%b<>%s*(%S+)%s*(.*)%|")
if Cmd == "!cleanlist" and sUser.bOperator then
sUser:SendData(tSet.BotName, tFunc.List() )
return 1
elseif Cmd == "!clean" and sUser.bOperator then
local msg = tFunc.Cleaner()
SendToAll(tSet.BotName, msg)
elseif Cmd == "!getinfo" and sUser.bOperator then
local s,e,value = string.find(Arg, "(%S+)")
if value == nil then sUser:SendData(tSet.BotName, "*** Syntax: !getinfo ") return 1 end
local usr = tFunc.Find(value)
if usr == nil then sUser:SendData(tSet.BotName, "*** Nothing found on "..value) return 1
elseif type(usr) == "string" then sUser:SendData(tSet.BotName, usr) return 1
elseif type(usr) == "table" then
usr = tFunc.SplitMyInfoString(usr.sMyInfoString,usr)
local line = ""
line = line .. "\r\n -----###-----------------------------------------------------------------------------------------------------------------------------------------------------------------###-----"
line = line .. "\r\n                    # Information on: "..value.." #       "
line = line .. "\r\n -----###-----------------------------------------------------------------------------------------------------------------------------------------------------------------###-----"
line = line .. "\r\n                              Nickname: "..usr.sName
line = line .. "\r\n                              IP: "..usr.sIP
line = line .. "\r\n                              Client: "..usr.sClient.." v."..usr.sClientVersion
line = line .. "\r\n                              Share: "..usr.iShareSize
line = line .. "\r\n                              Mode: "..usr.sMode
line = line .. "\r\n                              Slots: "..usr.iSlots
line = line .. "\r\n                              Hubs: "..usr.iHubs
line = line .. "\r\n                              Bandwidth: "..usr.iBlimit
line = line .. "\r\n                              Description: "..usr.sDescription
line = line .. "\r\n                              Tag: "..usr.sTag
line = line .. "\r\n                              Connection Speed: "..usr.sConnection
line = line .. "\r\n                              Email: "..usr.sEmail
line = line .. "\r\n                              Status: "..tFunc.Online(usr.sName)
line = line .. "\r\n                              Last Login: "..os.date("%A %d %B %Y (%H:%M:%S)", tonumber(sTIME[usr.sName]) )
line = line .. "\r\n -----###-----------------------------------------------------------------------------------------------------------------------------------------------------------------###-----"
sUser:SendData(tSet.BotName, line)
return 1
end
end
end

report errors and other things...

Cheers // NightLitch
Title:
Post by: Dessamator on 14 May, 2005, 16:34:31
hmmm, looks a lot cleaner than ur other code, and more optimized as well, well done !
Title:
Post by: NightLitch on 14 May, 2005, 18:14:03
QuoteOriginally posted by Dessamator
hmmm, looks a lot cleaner than ur other code, and more optimized as well, well done !

Question is does it work OK that is what I need to know...

The cleaner part that is...

Other then that it could be some minior bugs, but what doesn't have bugs.  ;)
Title:
Post by: Dessamator on 14 May, 2005, 20:32:04
yah sure ill test it, but dont worry there's gonna be a lot of testers soon, and bugs will arise as always, :)
Title:
Post by: Oz on 29 June, 2005, 10:53:33
can u add this function and for registered users?

thx
Title:
Post by: GeceBekcisi on 21 July, 2005, 21:26:27
Having an IP history of the queried nick would also be very good...

Thanks..
Title:
Post by: GeceBekcisi on 23 July, 2005, 14:06:02
Getting "Saturday 20 August 2005" like Last login query results for queries made in "Saturday 23 August 2005".. Date is buggy..

I tried to correct but couldnt succeed due to being unable where this error happens from. Anyone can correct that?
Title:
Post by: GeceBekcisi on 09 August, 2005, 22:44:46
Some one can correct that date bug? Please :(
Title:
Post by: bastya_elvtars on 09 August, 2005, 23:26:56
Maybe some of you would like to try this (http://ptxscriptdb.psycho-chihuahua.net/download.php?view.83), as many requests are covered.
Title:
Post by: GeceBekcisi on 10 August, 2005, 12:22:01
bastya_elvtars, your script is really good and nearly what I need but;BTW thanks for the script..
Title:
Post by: bastya_elvtars on 10 August, 2005, 13:16:00
QuoteOriginally posted by GeceBekcisi
iprange info command locks computer, i couldnt find why

Yeah, I saw it, and frankly, I don't know the reason at the moment, but already inspecting.

-- // EDIT

It crashed PtokaX here. I think it is weird, because it worked fine with the previous version. Gonna build a coroutine for the range info, maybe that helps, because this shouldnt't happen.


QuoteOriginally posted by GeceBekcisi
Instead of local v,u=bytestoh(Share)
msg=msg.."Shared: "..sUsersShare.." "..u.."\r\n"..
this local v,u=bytestoh(Share)
local sUsersShare = string.format( "%.2f",v)
msg=msg.."Shared: "..sUsersShare.." "..u.."\r\n"..
kinda things would be much useful

Oh, yes, I way lowe loooooooong decimal numbers. The bytestoh function does not format the string it returns, you have to do it yourself, feel free to edit my scripts.
Title:
Post by: bastya_elvtars on 10 August, 2005, 17:04:54
Found and eliminated the bug. Please update (http://ptxscriptdb.psycho-chihuahua.net/download.php?view.84).
Title:
Post by: Jaakko on 06 September, 2005, 13:26:44
Two requests.
1. Option to disable inbuilt right click commands. It looks kind of stupid now when at my hub I have all mouse commands translated in finnish. All but dabase's.
2. Profile names aren't same in every hub. In my case all my op's are vip's at userinfo and so on.
Title:
Post by: Herman on 07 September, 2005, 23:24:00
Bastya? Im having a problem with the script. Im using robocop as security software, and im having a netfounder profile, which im using....and the script wont recognize me as operator so i cant use it....you have a quick fix for this problem?
Title:
Post by: bastya_elvtars on 07 September, 2005, 23:34:48
QuoteOriginally posted by Herman
Bastya? Im having a problem with the script. Im using robocop as security software, and im having a netfounder profile, which im using....and the script wont recognize me as operator so i cant use it....you have a quick fix for this problem?

It is not designed to use nonstandard profiles, it can be changed to support it, but I cannot do it for you now.
Title:
Post by: Psycho_Chihuahua on 08 September, 2005, 00:42:35
my guess would be to edit the line
local proftable={[0]="Superoperator",[1]="Operator",[2]="VIP",[3]="Registered User"}to match your Profile settings


but then on the other hand i'm still a bit of a noob in scripting myself  :D
Title:
Post by: Herman on 08 September, 2005, 13:07:25
QuoteOriginally posted by Psycho_Chihuahua
my guess would be to edit the line
local proftable={[0]="Superoperator",[1]="Operator",[2]="VIP",[3]="Registered User"}to match your Profile settings


but then on the other hand i'm still a bit of a noob in scripting myself  :D




Well, i tried adding netfounder to that line...but it didnt work. When i use the !getinfo command on a netfounder, it says he is a "user"
Title:
Post by: GrinSlaW on 11 September, 2005, 17:15:18
hello

how can i change the rightclick name in your userinfo script bastya_elvtars ? i whant to change the name from Userinfo to -=] UserInfo [=- but i dont see where to do it in the script  ?(


cheers
Title:
Post by: Herman on 12 September, 2005, 13:08:30
QuoteOriginally posted by GrinSlaW
hello

how can i change the rightclick name in your userinfo script bastya_elvtars ? i whant to change the name from Userinfo to -=] UserInfo [=- but i dont see where to do it in the script  ?(


cheers

In the lua file at the top you see this:

-- Bot's data

Bot={
name="-UserInfo-"


Change -UserInfo- to the name you want your bot to be called
Title:
Post by: GrinSlaW on 12 September, 2005, 13:45:28
umh thats where i change the bot name i know that. The questions was where i change the rightclick name

tnx anyway  :)

cheers
Title:
Post by: Herman on 12 September, 2005, 13:55:07
QuoteOriginally posted by GrinSlaW
umh thats where i change the bot name i know that. The questions was where i change the rightclick name

tnx anyway  :)

cheers

Think you have to change the names in the rigstration commands at the bottom of the file.

Dunno what tho, if not helped by bastya, you could just use the trial and error way
Title:
Post by: GrinSlaW on 12 September, 2005, 14:32:06
i have tried that just get syntax error when i change there

yes hope bastya will post some help  :)

*EDIT* found out where it was it was not so hard if you read the script properly then i found it :)

cheers
Title:
Post by: bastya_elvtars on 14 September, 2005, 01:39:14
QuoteOriginally posted by GrinSlaW
i have tried that just get syntax error when i change there

yes hope bastya will post some help  :)

*EDIT* found out where it was it was not so hard if you read the script properly then i found it :)

cheers

Sorry for not posting the solution, I could not use my HDDs for a while, otherwise I would post a fix. Gotta create a lecture now... later...
Title: conserning rightclick namechange
Post by: gander on 14 September, 2005, 10:08:22
well i had a look trough the script and it looks like the whole script is based on the botname ... so i guess its not possible to change rightclick without rewriting the script... or?
Title:
Post by: gander on 14 September, 2005, 10:16:05
guess i found it


here you go

 if not PM then
    rightclick["$UserCommand "..context.." Userinfo\\"..name.."$<%[mynick]> "..command.."|"]=level
  else
    rightclick["$UserCommand "..context.." Userinfo\\"..name.."$$To: "..Bot.name.." From: %[mynick] $<%[mynick]> "..command.."|"]=level
  end

just change where it says "userinfo\\"  to what ever...like ex "]userinfo[\\"

worked here
Title:
Post by: Herman on 20 September, 2005, 12:31:29
Hey bastya? could you add so i can use NetFounder profile with the db?
Title:
Post by: bastya_elvtars on 20 September, 2005, 12:42:13
QuoteOriginally posted by Herman
Hey bastya? could you add so i can use NetFounder profile with the db?

Post your Profiles.xml.
Title:
Post by: Herman on 20 September, 2005, 23:34:51
QuoteOriginally posted by bastya_elvtars
QuoteOriginally posted by Herman
Hey bastya? could you add so i can use NetFounder profile with the db?

Post your Profiles.xml.



   
        Master
        1111111111111111111111111111111111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
   

   
        Operator
        1001111110110011111001100010111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
   

   
        VIP
        0000000000000001111000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
   

   
        Reg
        0000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
   

   
        Moderator
        1111111110110011111011100110111101000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
   

   
        NetFounder
        1111111111111111111111111111111111100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
   

Title:
Post by: Herman on 24 September, 2005, 11:22:01
Isnt it possible to make the Netfounder profile recieve the Usrinfo bot commands?
Title:
Post by: Psycho_Chihuahua on 24 September, 2005, 12:33:00
QuoteOriginally posted by Psycho_Chihuahua
my guess would be to edit the line
local proftable={[0]="Superoperator",[1]="Operator",[2]="VIP",[3]="Registered User"}to match your Profile settings


but then on the other hand i'm still a bit of a noob in scripting myself  :D


i guess for you it would probably be something like

local proftable={[0]="Master",[1]="Operator",[2]="VIP",[3]="Registered User",[4]="Moderator",[5]="Netfounder"}
Title:
Post by: Jitway on 24 September, 2005, 17:29:19
Getting this error with bastya_evltars script

Syntax ...d Settings\user\Desktop\PtokaX1\scripts\UserInfo.lua:561: ...d Settings\user\Desktop\PtokaX1\scripts\UserInfo.lua:524: attempt to index local `f' (a nil value)
Title:
Post by: bastya_elvtars on 24 September, 2005, 19:23:19
My script contains a serious flaw and I strongly discourage using it. I will post a fixed version soon, in case you need it.
Title:
Post by: Herman on 27 September, 2005, 16:36:48
Thnx i would appretiate it
Title:
Post by: Herman on 12 October, 2005, 22:06:41
Errh, are this tread dead? Wonder if you have updated the userinfo script bast. :))
Title:
Post by: QuikThinker on 08 November, 2005, 22:27:28
I would like use this script if there's any progress on it or a similar script if sum1 can point me in the right direction?

Many thanx.
Title:
Post by: bastya_elvtars on 08 November, 2005, 23:10:27
I am sorry, but working on it, won't be released until the new PtokaX.