Little lifetime script!
 

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

Little lifetime script!

Started by Vipertje, 01 June, 2007, 20:23:49

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Vipertje

Hi m8s,

I have a question. I use latest RoboCop but what I miss is a all time life indicator in the hubstatus messages. Normaly theres standing, the hub is xx weeks, xx day and xx hours online.

But I want a all time lifetime line in it what Lev 3 already has, is it possible 2 create a script for it and that I can put a line in the hub status message?

Does someone understand what I mean?

grts,
Vipertje

Snooze

Hey Vipertje,

The script your're suggesting is possible, though adding it to Robocop cannot be done as it's closed source.
If you can stop the "one join message" in Robocop, it would be possible to add a 2nd script to delive the suggested message.

I know that more than one alt. script do what you suggest .. Perhaps one of those will do with a few changes?

-Snooze

Psycho_Chihuahua

I'm not sure what exactly you are looking for but maybe this could be it

--[[

	LifeTime Bot 1.03 - LUA 5.0/5.1 version by jiten
	????????????????????????????????????????????????

	DESCRIPTION:

	- Get Hub's current uptime;
	- Determine how old is the hub

	CHANGELOG:

	Added: Missing LUA 5.1 compatibility - reported by NorthWind;
	Added: Support for years - requested by Psycho_Chihuahua (9/16/2006)
	Changed: LUA 5.1 compatibility vars
	Added: Lifetime topic updater - requested by NorthWind;
	Added: Leviathan profiles (9/30/2006)

]]--

tSettings = {

	-- Bot Name
	sBot = frmHub:GetHubBotName(),

	-- RightClick Menu
	sMenu = "LifeTime",

	-- Hub's 'birth' date
	iSetup = {
		year = 2004,
		month = 1,
		day = 1,
		hour = 08,
		min = 30,
		sec = 00
	},

	-- Update topic [true = on, false = off]
	bUpdateTopic = false,
		-- Topic update delay (in hours)
		iTime = 6,
}

Main = function()
	-- Topic Timer
	SetTimer(tSettings.iTime*60*60*1000); StartTimer()
end

OnTimer = function()
	-- Update Topic
	if tSettings.bUpdateTopic then
		local iDiff = os.difftime(os.time(os.date("!*t")), os.time(tSettings.iSetup))
		if iDiff > 0 then
			local tTopic = {
				"we exist since [TIME]",
				"Our hub is [TIME] old",
				"Running since [TIME]",
			}
			local sTopic = string.gsub(tTopic[math.random(1, table.getn(tTopic))], "%[TIME%]", SecondsToTime(iDiff, true))
			frmHub:SetHubTopic(sTopic)
		end
	end
	-- Collect garbage
	collectgarbage(gc); io.flush()
end

ChatArrival = function(user, data)
	local _,_, to = string.find(data, "^$To:%s(%S+)%s+From:")
	local _,_, msg = string.find(data, "%b<>%s(.*)|$") 
	-- Message sent to Bot or in Main
	if (to and to == tSettings.sBot) or not to then
		-- Parse command
		local _,_, cmd = string.find(msg, "^%p(%S+)")
		-- Exists
		if cmd and tCommands[string.lower(cmd)] then
			cmd = string.lower(cmd)
			-- If user has permission
			if tCommands[cmd].tLevels[user.iProfile] and tCommands[cmd].tLevels[user.iProfile] == 1 then
				return tCommands[cmd].fFunction(user, msg), 1
			else
				return user:SendData(tSettings.sBot, "*** Error: You are not allowed to use this command!"), 1
			end
		end
	end
end

ToArrival = ChatArrival

NewUserConnected = function(user)
	-- Supports UserCommands
	if user.bUserCommand then
		-- For each entry in table
		for i, v in pairs(tCommands) do
			-- If member
			if v.tLevels[user.iProfile] then
				-- Send
				user:SendData("$UserCommand 1 3 "..tSettings.sMenu.."\\"..v.tRC[1]..
				"$<%[mynick]> !"..i..v.tRC[2].."&#124;")
			end
		end
	end
	user:SendData(tSettings.sBot, "*** Welcome to "..(frmHub:GetHubName() or "Unknown").." !"); tCommands["lifetime"].fFunction(user)
end

OpConnected = NewUserConnected

tCommands = {
	lifetime = {
		fFunction = function(user)
			local iDiff = os.difftime( os.time(os.date("!*t")), os.time(tSettings.iSetup))
			if iDiff > 0 then
				user:SendData(tSettings.sBot, "*** This Hub is "..
				SecondsToTime(iDiff).." old and the latest uptime is "..SecondsToTime(frmHub:GetUpTime(), true).."\r\n\t\t\t Today is the "..os.date("%d. %B %Y and it is now %X o'clock").."!")
			else
				user:SendData(tSettings.sBot, "*** Error: You must enter a valid Hub Birthday!")
			end
		end,
		tLevels = {
			[-1] = 0, [0] = 1, [1] = 1, [2] = 1, [3] = 1, [4] = 1, [5] = 1, [6] = 1,
		},
		tRC = { "Show hub's age and uptime", "" }
	},
}

SecondsToTime = function(iTime, bSmall)
	-- LUA 5.0/5.1 compatibility
	string.gmatch = (string.gmatch or string.gfind)
	-- Build table with time fields
	local T = os.date("!*t", tonumber(iTime)); 
	-- Format to string
	local sTime = string.format("%i year(s), %i month(s), %i day(s), %i hour(s), %i minute(s)", T.year-1970, T.month-1, T.day-1, T.hour, T.min)
	-- Small stat?
	if bSmall then
		-- For each digit
		for i in string.gmatch(sTime, "%d+") do
			-- Reduce if is preceeded by 0
			if tonumber(i) == 0 then sTime = string.gsub(sTime, "^"..i.."%s(%S+),%s", "") end
		end
	end
	-- Return
	return sTime
end
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

Tw?sT?d-d?v

Nice Script   working ok here      ;D ;D

Vipertje

Yes I am searching somthing like that, but I only want it show in the hub status message..

Like this:

  =================================================================================
  ? Hub Information:
  ------------------------------------------------------------------------------------------------------------------------------------------------------------------
  ? Hub owner:         [MCN-NF][NL]Vipertje
  ? Hub name:         MainCore Networx
  ? Hub address:         **.********.**:1250
  ? Hub uptime:         3 Weeks 3 Days 20 Hours 44 Minutes and 48 Seconds
  ? Hub software:         PtokaX 0.3.6.0 running RoboCop v10.023 - created by Optimus?
  ? Hub web address:      http://nl.hublist.org/?p=hub&id=188932 Vote for ***** uitmuntend!!
                             http://www.dchublist.com/index.php?page=show&id=10762 Vote Excelent!!
  ? Hub share amount:      49.50 TB
  ? Hub users (actual/max):      44 / 1000
  ? Hub users peak (actual/max):   83 / 118
  ------------------------------------------------------------------------------------------------------------------------------------------------------------------
 
  ------------------------------------------------------------------------------------------------------------------------------------------------------------------


under the line:
[size=8
pt]? Hub uptime:         3 Weeks 3 Days 20 Hours 44 Minutes and 48 Seconds[/size]
I want to have the line  ? Hub Lifetime  6 month 3 Weeks 3 Days 20 Hours 44 Minutes and 48 Seconds (or something like that.

The same is in Levithian V3.1

I think its possible the get the hub first start time from a own created txt file en counting from then. The only thing is that the line to call it must be put in the hubaddmessage.lua in robo script.

This is the line to call up the current hub uptime:
   info = info.."  ? Hub uptime:\t\t\t"..weeks.." Weeks "..days.." Days "..hours.." Hours "..minutes.." Minutes and "..seconds.." Seconds\r\n"

And under it there must be some input what refures to the lifetime script.

I dont know if this is possile, but it sounds logical to me (but who am I to call it correct, I'm just a guy that ask for help ;) :P :D )

Psycho_Chihuahua

#5
well i have been intending updating InfoBot so i did a start.

looks like this on hub entry

????????????????????????????????????????
	Hub Information:
	??????????????
	Welcome:	Psycho_Chihuahua, It's nice of you to stop by...
	Hub Name: 	-SanitariuM-,  This hub is powered b
	Hub Version: 	PtokaX 0.3.6.0 Lua 5.12
	Hub description:	yet another swiss hub
	Hub Address:	localhost:411
	Hub Owner:	Psycho_Chihuahua
	Reg Servers:	AutoReg not active
	Hub Uptime:	0 day(s) 0 hour(s) 0 minute(s) 20 second(s)
	Windows Uptime:	0 day(s) 5 hour(s) 12 minute(s) 11 second(s)
	Peak Users:	7
	Hub Share:	0.00 B
	There Are Now:	0 of 100 max users online.

	????????????????????????????????????????
	Your Information:
	??????????????
	Username:	Psycho_Chihuahua
	User Profile:	Owner
	IP Address:	127.0.0.1
	Share Size:	216.36 MB
	DC Tag:		<++ V:0.699,M:A,H:0/2/10,S:1>
	Description:	not set
	Email:		tokolosh@tokolosh.selfip.com
	Connection:	0.02


	????????????????????????????????????????
	? [ This information is only being shown to you ] ?

	????????????????????????????????????????


but it is not finished so state it as "work in progress"
also you will need PxUtilities_l51.dll in your hubroot folder (thats where ptokax.exe is) if you dont have it you can get it from libs.ptokax.ath.cx



** Edit: Updated package to fix the Error Vipertje mentioned **
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

Vipertje

I get an error:

[01:40] Syntax C:\HUBSOFT\[NL]MainCore\scripts\InfoBot.lua:227: 'string.gfind' was renamed to 'string.gmatch'

I wait for your reply ;) :D I know that this is work in progress ;) :)

Psycho_Chihuahua

#7
yeah, well in the meantime you can fix that one yourself.

Search for Line 227 and change string.gfind  to   string.gmatch  and it will work

Alternately you can download it again from my last post as i have fixed that error. Now i am working on adding the total Hub lifetime to the script
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

Vipertje

Works fine now m8, only I this its better to leave out de server regs, because its in most cases to long. Its only a sugetion :)

PS windows online time dont works correct

   ????????????????????????????????????????
   Hub Information:
   ??????????????
   Welcome:   [MCN-NF]Server, It's nice of you to stop by...
   Hub Name:    MainCore Networx,  COME ON !!! And take a look around !
   Hub Version:    PtokaX 0.3.6.0 Lua 5.12
   Hub description:   Minshare 25GB / 50+TB's hubshare on a 100Mbit Hub Host ! RCv10.023
   Hub Address:   xx.xxxxxxxx.xx:1250
   Hub Owner:   Psycho_Chihuahua
   Reg Servers:   hub2list.no-ip.info - allhublista.myip.hu - dc.wikfall.se - dchublist.myip.hu - dchelp.no-ip.org - hubinfo.myip.hu - hublist.wikfall.se - hublista.myip.hu - hublist.awenet.org - hublist.djinncity.net - koris.sytes.net - reg.ancient.pl - reg-dchublist.no-ip.org - thomace.myip.hu - serv.hubs-list.com - hublist.zapto.org - zengeday.sytes.net - hubs.hublist.co.uk - dcreg.mine.nu - hublist.adrenaline-network.com - dreamland.gotdns.org - reg.hublist.nu - reg.hublist.org
   Hub Uptime:   25 day(s) 14 hour(s) 0 minute(s) 42 second(s)
   Windows Uptime:   2 day(s) 18 hour(s) 27 minute(s) 33 second(s)
   Peak Users:   118
   Hub Share:   55463.02 GB
   There Are Now:   47 of 1000 max users online.

   ????????????????????????????????????????
   Your Information:
   ??????????????
   Username:   [MCN-NF]Server
   User Profile:   NetFounder
   IP Address:   xx.xxx.xxx.xxx
   Share Size:   1488.39 GB
   DC Tag:      <++ V:0.674,M:A,H:0/1/1,S:1>
   Description:   NetFounder of MainCore Network
   Email:      not set
   Connection:   25Kb/s Upload


   ????????????????????????????????????????
   ? [ This information is only being shown to you ] ?

   ????????????????????????????????????????


Here is a copy of me clients info where a indication is of me sytem online status:
Memory
Physical memory (available/total): 357,78 MiB/1023,18 MiB
Pagefile (available/total): 1,11 GiB/2,63 GiB
Virtual memory (available/total): 1,78 GiB/2,00 GiB
Memory load: 65%

CPU
Name: Intel(R) Pentium(R) 4 CPU 3.20GHz
Speed: 3198MHz
Identifier: x86 Family 15 Model 3 Stepping 4

OS
5.2.3790 SP: 2
Platform: Win32 NT Type: Domain Controller

Uptime
System uptime: 16 days 22 hours 10 minutes 53 seconds
fulDC uptime: 16 days 3 hours 8 minutes 26 seconds

Disk
Disk space(free/total): 221,59 GiB/1,73 TiB

Transfer
Upload: 35,13 GiB, Download: 4,58 GiB
Ratio (up/down): 7,67


And me windows uptime on the hub is a langer, I think that you must input a months also ;) so you have a better indication :)
Maybe, it's more simplier to put in the settings.ini the options what the hubowner want's to see at connection.

Just like On or Off by the options.

You did it already with showpassword and showscriptinfo ;)

This way you make this script a super and easy to use script. I know for sure that I really going to use this one :) Its allready in me script list :)

Extra future a timebased hubadmessage ;) a smaller version of this info what you get on connect :)

Psycho_Chihuahua

well, firstly i am still in NOOB status when it comes to scripting and secondly it was working fine on my system  ???

anyways, i have added a Hub Age/Lifetime Line into the Message

[19:50:26] 

	????????????????????????????????????????
	Hub Information:
	??????????????
	Welcome:	Psycho_Chihuahua, It's nice of you to stop by...
	Hub Name: 	-SanitariuM-,  just chilling
	Hub Version: 	PtokaX 0.3.6.0 Lua 5.12
	Hub description:	yet another swiss hub
	Hub Address:	localhost:411
	Hub Owner:	Psycho_Chihuahua
	Reg Servers:	dreamland.gotdns.org - reg.hublist.org - bwhubreg.no-ip.info
	Hub Life: 		3  year(s) , 5  month(s) , 1  day(s) , 8  hour(s) , 80  minute(s) 
	Hub Uptime:	0  day(s)  0  hour(s)  0  minute(s)  7  second(s)
	Windows Uptime:	0  day(s)  4  hour(s)  46  minute(s)  28  second(s)
	Peak Users:	7
	Hub Share:	0.00 B
	There Are Now:	0 of 100 max users online.

	????????????????????????????????????????
	Your Information:
	??????????????
	Username:	Psycho_Chihuahua
	User Profile:	Owner
	IP Address:	127.0.0.1
	Share Size:	216.36 MB
	DC Tag:		<++ V:0.699,M:A,H:0/2/9,S:1>
	Description:	not set
	Email:		tokolosh@tokolosh.selfip.com
	Connection:	0.02


	????????????????????????????????????????
	? [ This information is only being shown to you ] ?

	????????????????????????????????????????


and to be honest the windows uptime that i get reported from PxUtilities has always been correct so i really do not know why you get false results



Oh and by the way i have redone the Settings.ini a bit ;)
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

Vipertje

Quote from: Psycho_Chihuahua on 02 June, 2007, 20:03:18
and to be honest the windows uptime that i get reported from PxUtilities has always been correct so i really do not know why you get false results

I did really say that it is wrong, I did correct me self with, the you must put in month before weeks ;) this way you get a better reading :)

Psycho_Chihuahua

#11
fixed bug in hub lifetime showing more than 59 minutes (had values of way over 80 lol)
cleaned code a bit and got rid of some obsolete stuff too

Credits for me to be able to build this script go to:

Mutor for starting InfoBot
plop for Time Measurement Fuctions i ripped from Artificial insanety V2
jiten for the Hub Lifetime bit i ripped from his Hub Lifetime script Version 1.02

and everyone else who helped me along
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

SMF spam blocked by CleanTalk