Help: number of hubs on request
 

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

Help: number of hubs on request

Started by Stravides, 04 September, 2004, 23:27:10

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Stravides

Ok, I'm getting lazy now ... not with the coding, just with the opping.

I want to be able to type a command ie !hubscan and it then looks at all the users and PM's the ops with all the users above the max hub level.

there are some that are getting through the hubsoftware n I want to limit the searching and adding I need to perform.

I have this in dataarrival, but this is a bit of an overhead as it is checked a lot I believe (when its on it cripples the hub)

please can you help me out on this one as I'm not sure what I should be looking at :)

if (strsub(data,1,7)=="$MyINFO") then
		local _,_,a,b,c = strfind(data, "H:(%d+)/(%d+)/(%d+)")
		local hub1 = tonumber(a)
		local hub2 = tonumber(b)
		local hub3 = tonumber(c)
		local maxhub = tonumber(maxhub)
		local tothub = hub1 + hub2 + hub3
		if maxhub ~= 0 then
			if tothub > maxhub and not user.bOperator then
				SendToNick("Stravides"," "..user.." Was disconnected for having "..tostring(tohub).." Hubs Open")
				return 1
			end
		end
	end
Stravides
For RPG Books, Mp3 & Videos
We host trivia  and the ever failing Smeagolbot

nErBoS

Hi,

Try this...

--## HUB Scan BOT
--## Requested by Stravides
--## Made by nErBoS
--## Commands:
--##	!hubscan	- Check if there are users with more them Max HUBs

sBot = "Scan-BOT"

arrUser = {}
fUser = "user.dat"

--## Configuration ##--

uLaterPtokax = 0	-- Choose 0 if you are using Ptokax version 0.3.3.0 or higher
			-- Choose 1 if you are using Ptokax version lower then 0.3.3.0

iMaxHubs = 5	-- Number of Max HUBs allowed in your HUB

--## END ##--

function Main()
	frmHub:RegBot(sBot)
	LoadFromFile(fUser)
end

function OnExit()
	SaveToFile(fUser , arrUser , "arrUser")
end

function NewUserConnected(user)
	arrUser[user.sName] = 1
	if (uLaterPtokax == 1) then
		OnExit()
	end
end

function UserDisconnected(user)
	arrUser[user.sName] = nil
	if (uLaterPtokax == 1) then
		OnExit()
	end
end

function DataArrival(user, data)
	if (strsub(data,1,1) == "<" or strsub(data,1,5+strlen(sBot)) == "$To: "..sBot) then
		data = strsub(data,1,strlen(data)-1)
		s,e,cmd = strfind(data, "%b<>%s+(%S+)")
		if (cmd == "!hubscan" and user.bOperator) then
			CheckHUBs(user)
			return 1
		end
	end
end

function CheckHUBs(user)
	local sTmp,usr,aux = "Users that are more then "..iMaxHubs.." HUBs:\r\n\r\n"
	for usr, aux in arrUser do
		if (GetItemByName(usr) ~= nil and GetItemByName(usr).sMyInfoString ~= nil) then
			local s,e,hubs = strfind(GetItemByName(usr).sMyInfoString, "H:(%S+),")
			if (tonumber(hubs) ~= nil) then
				if (tonumber(hubs) > iMaxHubs) then
					sTmp = sTmp.."User: "..usr.."\tHUBs: "..hubs.."\r\n"
				end
			else
				local s,e,a,b,c = strfind(hubs, "(%d+)/(%d+)/(%d+)")
				if (a ~= nil and b ~= nil and c ~= nil) then
					hubs = tonumber(a) + tonumber(b) + tonumber(c)
					if (tonumber(hubs) > iMaxHubs) then
						sTmp = sTmp.."User: "..usr.."\tHUBs: "..hubs.."\r\n"
					end
				end
			end
		end
	end
end

function Serialize(tTable, sTableName, sTab)
	assert(tTable, "tTable equals nil");
	assert(sTableName, "sTableName equals nil");

	assert(type(tTable) == "table", "tTable must be a table!");
	assert(type(sTableName) == "string", "sTableName must be a string!");

	sTab = sTab or "";
	sTmp = ""

	sTmp = sTmp..sTab..sTableName.." = {\n"

	for key, value in tTable do
		local sKey = (type(key) == "string") and format("[%q]",key) or format("[%d]",key);

		if(type(value) == "table") then
			sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
		else
			local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
			sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
		end

		sTmp = sTmp..",\n"
	end

	sTmp = sTmp..sTab.."}"
	return sTmp
end

function SaveToFile(file , table , tablename)
	writeto(file)
	write(Serialize(table, tablename))
	writeto()
end

function LoadFromFile(file)
	if (readfrom(file) ~= nil) then
		readfrom(file)
		dostring(read("*all"))
		readfrom()
	end
end

Best regards, nErBoS
--## nErBoS Spot ##--

Stravides

#2
Ok not quite working here...

I have added a line to PM to OPS ie so it outputs the info.

Have tested it with another account

on max 5 hubs...

6/0/0 is detected
5/1/0 is not detected
5/0/1 is not detected

these should be counted as > 5

sorry to be a pain :)

Stravides
Stravides
For RPG Books, Mp3 & Videos
We host trivia  and the ever failing Smeagolbot

BottledHate

try this function in place ofthe old... not tested.. but it
looks like it should work ;)

function CheckHUBs(user)
   local sTmp,usr,aux = "Users that are more then "..iMaxHubs.." HUBs:\r\n\r\n"
   for usr, aux in arrUser do
      if (GetItemByName(usr) ~= nil and GetItemByName(usr).sMyInfoString ~= nil) then
         local s,e,hubs = strfind(GetItemByName(usr).sMyInfoString, "H:(%d+)/")
         if tonumber(hubs) ~= nil then
            if tonumber(hubs) >= tonumber(iMaxHubs) then
               sTmp = sTmp.."User: "..usr.."\tHUBs: "..hubs.."\r\n"
            end
         else
            s,e,hubs = strfind(GetItemByName(usr).sMyInfoString, "H:(%S+),")
            local s,e,a,b,c = strfind(hubs, "(%d+)/(%d+)/(%d+)")
            if (a ~= nil and b ~= nil and c ~= nil) then
               hubs = tonumber(a) + tonumber(b) + tonumber(c)
               if hubs >= iMaxHubs then
                  sTmp = sTmp.."User: "..usr.."\tHUBs: "..hubs.."\r\n"
               end
            end
         end
      end
   end
end

-BH
Homepage: www.bottledhate.webhop.org

Compiling  Lua scripts is LAME!!!!!

nErBoS

Hi,

Forgot the output and i have tested and caugth every one...

--## HUB Scan BOT
--## Requested by Stravides
--## Made by nErBoS
--## Commands:
--##	!hubscan	- Check if there are users with more them Max HUBs

sBot = "Scan-BOT"

arrUser = {}
fUser = "user.dat"

--## Configuration ##--

uLaterPtokax = 0	-- Choose 0 if you are using Ptokax version 0.3.3.0 or higher
			-- Choose 1 if you are using Ptokax version lower then 0.3.3.0

iMaxHubs = 5	-- Number of Max HUBs allowed in your HUB

--## END ##--

function Main()
	frmHub:RegBot(sBot)
	LoadFromFile(fUser)
end

function OnExit()
	SaveToFile(fUser , arrUser , "arrUser")
end

function NewUserConnected(user)
	arrUser[user.sName] = 1
	if (uLaterPtokax == 1) then
		OnExit()
	end
end

function UserDisconnected(user)
	arrUser[user.sName] = nil
	if (uLaterPtokax == 1) then
		OnExit()
	end
end

function DataArrival(user, data)
	if (strsub(data,1,1) == "<" or strsub(data,1,5+strlen(sBot)) == "$To: "..sBot) then
		data = strsub(data,1,strlen(data)-1)
		s,e,cmd = strfind(data, "%b<>%s+(%S+)")
		if (cmd == "!hubscan" and user.bOperator) then
			CheckHUBs(user)
			return 1
		end
	end
end

function CheckHUBs(user)
	local sTmp,usr,aux = "Users that are more then "..iMaxHubs.." HUBs:\r\n\r\n"
	for usr, aux in arrUser do
		if (GetItemByName(usr) ~= nil and GetItemByName(usr).sMyInfoString ~= nil) then
			local s,e,hubs = strfind(GetItemByName(usr).sMyInfoString, "H:(%S+),")
			if (tonumber(hubs) ~= nil) then
				if (tonumber(hubs) > iMaxHubs) then
					sTmp = sTmp.."User: "..usr.."\tHUBs: "..hubs.."\r\n"
				end
			else
				local s,e,a,b,c = strfind(hubs, "(%d+)/(%d+)/(%d+)")
				if (a ~= nil and b ~= nil and c ~= nil) then
					hubs = tonumber(a) + tonumber(b) + tonumber(c)
					if (tonumber(hubs) > iMaxHubs) then
						sTmp = sTmp.."User: "..usr.."\tHUBs: "..hubs.."\r\n"
					end
				end
			end
		end
	end
	user:SendPM(sBot, sTmp)
end

function Serialize(tTable, sTableName, sTab)
	assert(tTable, "tTable equals nil");
	assert(sTableName, "sTableName equals nil");

	assert(type(tTable) == "table", "tTable must be a table!");
	assert(type(sTableName) == "string", "sTableName must be a string!");

	sTab = sTab or "";
	sTmp = ""

	sTmp = sTmp..sTab..sTableName.." = {\n"

	for key, value in tTable do
		local sKey = (type(key) == "string") and format("[%q]",key) or format("[%d]",key);

		if(type(value) == "table") then
			sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
		else
			local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
			sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
		end

		sTmp = sTmp..",\n"
	end

	sTmp = sTmp..sTab.."}"
	return sTmp
end

function SaveToFile(file , table , tablename)
	writeto(file)
	write(Serialize(table, tablename))
	writeto()
end

function LoadFromFile(file)
	if (readfrom(file) ~= nil) then
		readfrom(file)
		dostring(read("*all"))
		readfrom()
	end
end

BH...

Your function will not catch DC with H:(number), with only one field in the HUB area.

Best regards, nErBoS
--## nErBoS Spot ##--

BottledHate

oh bleh... i see... becasue of the "/"

well give me a lil break, it was 4:30 or so in the morning when i did that. :D


-BH
Homepage: www.bottledhate.webhop.org

Compiling  Lua scripts is LAME!!!!!

nErBoS

Hi,

hehe, i am like that  ;)  (We should sleep more  :)) )

Best regards, nErBoS
--## nErBoS Spot ##--

Stravides

Thanks for this - we're nearly there !! :)

I have been running it for a few days now, but i have to keep restarting the scripts and deleting the user.dat file as I keep on getting errors.

I have been trying to locate the error and as yet have not had any joy :(

The script runs and does not give any output via messaging as it should, I just get an error in the hub which is
syntax error: bad arguement #1 to 'strfind' (string expected, got nil)

it captures a user offending I kick them and its ok - but leave it running a while (hour or two) and it stops working it just displays the command !hubscan in main chat even tho return 1 is enabled

I kick users for not having the correct allocation of slots and hubs etc. and then I get errors. not all of the time.

I have set it to "LaterPtokax = 1" as I am using ptokax 0.3.2.6 td4

Any help would be appreciated...
Stravides
For RPG Books, Mp3 & Videos
We host trivia  and the ever failing Smeagolbot

Stravides

its as tho the script isnt even running
Stravides
For RPG Books, Mp3 & Videos
We host trivia  and the ever failing Smeagolbot

nErBoS

Hi,

I belive that the problem is from NMDC or any client with no tag, this should fixed...

--## HUB Scan BOT
--## Requested by Stravides
--## Made by nErBoS
--## Commands:
--##	!hubscan	- Check if there are users with more them Max HUBs

sBot = "Scan-BOT"

arrUser = {}
fUser = "user.dat"

--## Configuration ##--

uLaterPtokax = 0	-- Choose 0 if you are using Ptokax version 0.3.3.0 or higher
			-- Choose 1 if you are using Ptokax version lower then 0.3.3.0

iMaxHubs = 5	-- Number of Max HUBs allowed in your HUB

--## END ##--

function Main()
	frmHub:RegBot(sBot)
	LoadFromFile(fUser)
end

function OnExit()
	SaveToFile(fUser , arrUser , "arrUser")
end

function NewUserConnected(user)
	arrUser[user.sName] = 1
	if (uLaterPtokax == 1) then
		OnExit()
	end
end

function UserDisconnected(user)
	arrUser[user.sName] = nil
	if (uLaterPtokax == 1) then
		OnExit()
	end
end

function DataArrival(user, data)
	if (strsub(data,1,1) == "<" or strsub(data,1,5+strlen(sBot)) == "$To: "..sBot) then
		data = strsub(data,1,strlen(data)-1)
		s,e,cmd = strfind(data, "%b<>%s+(%S+)")
		if (cmd == "!hubscan" and user.bOperator) then
			CheckHUBs(user)
			return 1
		end
	end
end

function CheckHUBs(user)
	local sTmp,usr,aux = "Users that are more then "..iMaxHubs.." HUBs:\r\n\r\n"
	for usr, aux in arrUser do
		if (GetItemByName(usr) ~= nil and GetItemByName(usr).sMyInfoString ~= nil) then
			local s,e,hubs = strfind(GetItemByName(usr).sMyInfoString, "H:(%S+),")
			if (tonumber(hubs) ~= nil) then
				if (tonumber(hubs) > iMaxHubs) then
					sTmp = sTmp.."User: "..usr.."\tHUBs: "..hubs.."\r\n"
				end
			elseif (hubs ~= nil) then
				local s,e,a,b,c = strfind(hubs, "(%d+)/(%d+)/(%d+)")
				if (a ~= nil and b ~= nil and c ~= nil) then
					hubs = tonumber(a) + tonumber(b) + tonumber(c)
					if (tonumber(hubs) > iMaxHubs) then
						sTmp = sTmp.."User: "..usr.."\tHUBs: "..hubs.."\r\n"
					end
				end
			end
		end
	end
	user:SendPM(sBot, sTmp)
end

function Serialize(tTable, sTableName, sTab)
	assert(tTable, "tTable equals nil");
	assert(sTableName, "sTableName equals nil");

	assert(type(tTable) == "table", "tTable must be a table!");
	assert(type(sTableName) == "string", "sTableName must be a string!");

	sTab = sTab or "";
	sTmp = ""

	sTmp = sTmp..sTab..sTableName.." = {\n"

	for key, value in tTable do
		local sKey = (type(key) == "string") and format("[%q]",key) or format("[%d]",key);

		if(type(value) == "table") then
			sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
		else
			local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
			sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
		end

		sTmp = sTmp..",\n"
	end

	sTmp = sTmp..sTab.."}"
	return sTmp
end

function SaveToFile(file , table , tablename)
	writeto(file)
	write(Serialize(table, tablename))
	writeto()
end

function LoadFromFile(file)
	if (readfrom(file) ~= nil) then
		readfrom(file)
		dostring(read("*all"))
		readfrom()
	end
end

Best regards, nErBoS
--## nErBoS Spot ##--

Stravides

thanks - I'll give it a  try
Stravides
For RPG Books, Mp3 & Videos
We host trivia  and the ever failing Smeagolbot

SMF spam blocked by CleanTalk