hublifetime
 

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

hublifetime

Started by Northwind, 10 September, 2006, 22:50:13

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Northwind

Script what counts days,hours,minutes,seconds

We give hubs startingday
Hubborn = "24.4.2005"

Scripts will say:

Welcome to <hubname>. Hub is <counted days,hrs,mins,sec> old and current uptime is <uptime>

thanks again folsk you're the best :)


jiten

Quote from: Northwind on 10 September, 2006, 22:50:13
Script what counts days,hours,minutes,seconds

We give hubs startingday
Hubborn = "24.4.2005"

Scripts will say:

Welcome to <hubname>. Hub is <counted days,hrs,mins,sec> old and current uptime is <uptime>

thanks again folsk you're the best :)

Hint: Top Hubbers, Birthday Man and Countdown Bot would help you with this.

Northwind

well as im not a scripter and i wanted a script to what shows only those after motd  not other what those scripts can offer... i try to keep my hub clean and simply..:P


jiten

Quote from: Northwind on 14 September, 2006, 23:33:49
well as im not a scripter and i wanted a script to what shows only those after motd  not other what those scripts can offer... i try to keep my hub clean and simply..:P

Well, I wasn't forcing you to use one [or more] of them.

It's just that their code would suit perfectly for this request, though with small modifications.

jiten

#4
As previously stated, those bot's codes could be perfectly used altogether to fill your request, and here goes a quick [and mixed] attempt:

--[[

	LifeTime Bot 1.02 - 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

]]--

tSettings = {

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

	-- RightClick Menu
	sMenu = "LifeTime",

	-- Hub's 'birth' date
	iSetup = {
		year = 2006,
		month = 3,
		day = 28,
		hour = 21,
		min = 00,
		sec = 00
	},
}

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 current uptime is "..SecondsToTime(frmHub:GetUpTime(), true).."!")
			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,
		},
		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

Madman

if (to and to == tSettings.sBot) or not to then

Maybe i'm tierd... but isn't that like...   if (find to and to is botname) or if not find to then

I think the or should be removed.. or am i wrong?
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

Northwind

[17:21] Syntax D:\HUBIX\scripts\lifetime.lua:97: 'string.gfind' was renamed to 'string.gmatch'
stack traceback:
	[C]: in function 'gfind'
	D:\HUBIX\scripts\lifetime.lua:97: in function 'SecondsToTime'
	D:\HUBIX\scripts\lifetime.lua:77: in function 'fFunction'
	D:\HUBIX\scripts\lifetime.lua:66: in function <D:\HUBIX\scripts\lifetime.lua:53>


Psycho_Chihuahua

well it works nicely the way jiten had it in his last post - only thing missing is the amount of years :(
PtokaxWiki ?PtokaX Mirror + latest Libs

01100001011011000111001101101111001000000110101101101110011011110111011101101110001000000110000101110011001000000101010001101111011010110110111101101100011011110111001101101000

jiten

Quote from: Madman on 16 September, 2006, 03:53:06
if (to and to == tSettings.sBot) or not to then

Maybe i'm tierd... but isn't that like...   if (find to and to is botname) or if not find to then
I think the or should be removed.. or am i wrong?

If we remove the or not to part, then that function will only
deal with messages sent in PM to the bot.
Thus, those typed in main chat will be ignored.

So, it's really necessary to have it here, mate.

Quote from: Northwind on 16 September, 2006, 16:17:54
[17:21] Syntax D:\HUBIX\scripts\lifetime.lua:97: 'string.gfind' was renamed to 'string.gmatch'


Thank you for your report. I missed the function that dealt with the LUA 5.0/5.1 compatibility.

Quote from: Psycho_Chihuahua on 16 September, 2006, 19:40:37
well it works nicely the way jiten had it in his last post - only thing missing is the amount of years :(

I've also added 'years' support to the updated script :P

TiMeTrAVelleR

[22:21] Syntax ...\TestHub Leviathan Lua 5.11\scripts\LifeTime Bot.lua:105: attempt to call a string value
stack traceback:
   ...\TestHub Leviathan Lua 5.11\scripts\LifeTime Bot.lua:105: in function 'SecondsToTime'
   ...\TestHub Leviathan Lua 5.11\scripts\LifeTime Bot.lua:83: in function 'fFunction'
   ...\TestHub Leviathan Lua 5.11\scripts\LifeTime Bot.lua:72: in function <...\TestHub Leviathan Lua 5.11\scripts\LifeTime Bot.lua:59>

jiten

First post has been updated once more.

Northwind

Could you add one more thing :)

possibility to add hublifetime in topic every xx min

update topic every = 6 hours

random choose topic 1 to 5

--topic profiles--
[1]"We have been exist [days-hours]"
[2]"Our hub is [days-hours] old"
[3]"Alive and kickin' [days-hours]"
[4]"Hub's has born [days-hours] a go"
[5]"Look at our hubs lifetime, [days-hours] and counting"
--topic profile end--


jiten

Quote from: Northwind on 20 September, 2006, 04:27:42
Could you add one more thing :)

possibility to add hublifetime in topic every xx min

Yes, it can and will be added.

jiten


SMF spam blocked by CleanTalk