PtokaX forum

Archive => Archived 5.0 boards => Request for scripts => Topic started by: GrinSlaW on 20 May, 2005, 23:32:42

Title: iNFO-Bot
Post by: GrinSlaW on 20 May, 2005, 23:32:42
Hi can someone convert this to LUA 5 ?

-------------------------------------------------
-- 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)
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"}


i have tried to do it my self but i get an syntx error like this: Info-Bot.lua5.lua:37: attempt to call global `readfrom' (a nil value)
dont know what to do with it  ?( so if someone can fix that it would be great and check the script if it is ok coded

cheers  8)
Title:
Post by: jiten on 21 May, 2005, 10:33:41
Have you search the Lua 5 Section of scripts before requesting this one?
This one has already been converted.

Cheers
Title:
Post by: GrinSlaW on 24 May, 2005, 13:47:44
oki i will do that

anyway i have a problem with this:

function TextFile(file)
readfrom(file, "r")
local message = ""
while 1 do



get syntax error on this one whats wrong here ?


cheers
Title:
Post by: GrinSlaW on 15 June, 2005, 17:06:49
Hi
i have search the forum but no luck can't find it  :(

so if someone can post the link or the script it would be nice  :)

cheers
Title:
Post by: Dessamator on 15 June, 2005, 17:16:14
search for "info bot lua 5" or "userinfo by nightlitch"
Title:
Post by: blackwings on 15 June, 2005, 17:30:42
QuoteOriginally posted by Dessamator
search for "info bot lua 5" or "userinfo by nightlitch"
with lua 5, all those function that is used in nightlitch usinfo script, to get the various information is unnecessary.
A good userinfo bot should be similiar to mine + the loading/saving to a txt added.
Title:
Post by: Dessamator on 15 June, 2005, 17:44:50
indeed that was just a lua 4 to 5 conversion !
Title:
Post by: GrinSlaW on 15 June, 2005, 19:55:54
Hi
tnx for your posts  :))

could not find it :(  but nevermind it is not so important hehe

i am not looking for a userinfo bot just a MOTD bot thats read  the info from a .txt file i know it is one in ptokax but that motd comes last and i have som bot that must come affter the modt so thats why i need a modt bot

tnx for your time

cheers :))
Title:
Post by: blackwings on 15 June, 2005, 20:00:08
QuoteOriginally posted by GrinSlaW
Hi
tnx for your posts  :))

could not find it :(  but nevermind it is not so important hehe

tnx for your time

cheers :))
try this link ;) = Click Here (http://board.univ-angers.fr/thread.php?threadid=4477&boardid=26&styleid=1&sid=8561cfe540f380025e6212ef0ce925a2)
Title:
Post by: GrinSlaW on 15 June, 2005, 20:01:52
hehe tnx :)) i have edit my last post with some more info that i forgot to post

cheers
Title:
Post by: yoonohoo on 16 June, 2005, 04:23:33
QuoteA good userinfo bot should be similiar to mine + the loading/saving to a txt added

Which is?
Title:
Post by: blackwings on 16 June, 2005, 07:47:11
QuoteOriginally posted by yoonohoo
QuoteA good userinfo bot should be similiar to mine + the loading/saving to a txt added

Which is?
this is my userinfo script = Click Here (http://board.univ-angers.fr/thread.php?threadid=4752&boardid=6&styleid=1&sid=3d76ca40aba3ca0c3e07132bbe173e4d#10)

And if you add a loading/saving functions to it, it will be a really good userinfo script :)