iNFO-Bot
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

iNFO-Bot

Started by GrinSlaW, 20 May, 2005, 23:32:42

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

GrinSlaW

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"},
	["", "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)
.:: AcExtreme ::. | .:: AcPro ::.

jiten

Have you search the Lua 5 Section of scripts before requesting this one?
This one has already been converted.

Cheers

GrinSlaW

#2
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
.:: AcExtreme ::. | .:: AcPro ::.

GrinSlaW

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
.:: AcExtreme ::. | .:: AcPro ::.

Dessamator

search for "info bot lua 5" or "userinfo by nightlitch"
Ignorance is Bliss.

blackwings

#5
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.


Dessamator

indeed that was just a lua 4 to 5 conversion !
Ignorance is Bliss.

GrinSlaW

#7
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 :))
.:: AcExtreme ::. | .:: AcPro ::.

blackwings

#8
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


GrinSlaW

hehe tnx :)) i have edit my last post with some more info that i forgot to post

cheers
.:: AcExtreme ::. | .:: AcPro ::.

yoonohoo

QuoteA good userinfo bot should be similiar to mine + the loading/saving to a txt added

Which is?

It might be simple for you but rocket science for me...

blackwings

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

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


SMF spam blocked by CleanTalk