PtokaX forum

Archive => Archived 4.0 boards => Finished Lua 4 scripts => Topic started by: WooshMan on 06 March, 2004, 11:15:22

Title: An Original TimeBot
Post by: WooshMan on 06 March, 2004, 11:15:22
This is my first submission for finished scripts and hopefully it is an original one.

-- timebot by WooshMan -- landofkaraoke.ath.cx
-- creates a dummy user at the top of the user list
-- and displays the time as the user name.
-- A clock which diplays the current time in Hours and minutes.

current = date("%H:%M")
min = 1000*60

--------------------------------------------------------
function Main()
frmHub:RegBot("---" ..current .."---")
SetTimer(min)
StartTimer()
end
--------------------------------------------------------
function OnTimer()
frmHub:UnregBot("---" ..current .."---")
time = date("%H:%M")
current = time
frmHub:RegBot("---" ..current .."---")
end
--------------------------------------------------------
function OnExit()
frmHub:UnregBot("---" ..current .."---")
end
--------------------------------------------------------
Title:
Post by: kepp on 06 March, 2004, 11:27:37
Really Cool :)
Title: Nice!!!! =)
Post by: WickeD on 06 March, 2004, 11:39:01
Good one!!!  It works too!!  =)

//WickeD
Title:
Post by: WooshMan on 06 March, 2004, 12:34:09
Here is a H:M:S version

-- timebot by WooshMan -- landofkaraoke.ath.cx
-- creates a dummy user at the top of the user list
-- and displays the time as the user name.
-- A clock which diplays the current time in Hours, Minutes and Seconds.

current = date("%H:%M:%S")
sec = 1000

--------------------------------------------------------
function Main()
frmHub:RegBot("---" ..current .."---")
SetTimer(sec)
StartTimer()
end
--------------------------------------------------------
function OnTimer()
frmHub:UnregBot("---" ..current .."---")
time = date("%H:%M:%S")
current = time
frmHub:RegBot("---" ..current .."---")
end
--------------------------------------------------------
function OnExit()
frmHub:UnregBot("---" ..current .."---")
end
--------------------------------------------------------

But when there is quite a lot of users in the hub.. the user list may flicker slightly.. but the overall effect of seconds on the clock is much nicer.

--14:34:24--

WooshMan
Title:
Post by: [NL]trucker on 06 March, 2004, 14:26:42
WoW
WooshMan

A great job and a nice one if i may say.

i really like it,

one question is it possiblle to add a description for it like
=current time= ?

thnx peter.
Title:
Post by: NightLitch on 06 March, 2004, 16:04:59
Nice Woosh, your skills are improving m8.

/NL
Title:
Post by: WooshMan on 06 March, 2004, 16:12:08
New Version:  But still working on it.

-- timebot by WooshMan -- landofkaraoke.ath.cx

-- creates a dummy user at the top of the user list
-- and displays the time as the user name.
-- A clock which diplays the current time in Hours and minutes.

-- Version 1.3
-- ops only can turn on and off
-- added !clockon and !clockoff.  Turns clock on and off
-- added characters to start and end of time.  User can choose anything to prefix and finish the clock

startchrs = "-*"   -- shows before clock
endchrs = "*-"    -- shows after clock

current = date("%H:%M:%S")
sec = 1000
min = sec*60
--------------------------------------------------------
function Main()
SetTimer(sec)
end
--------------------------------------------------------
function OnTimer()
frmHub:UnregBot(startchrs ..current ..endchrs)
time = date("%H:%M:%S")
current = time
frmHub:RegBot(startchrs ..current ..endchrs)
end
--------------------------------------------------------
function OnExit()
frmHub:UnregBot(startchrs ..current ..endchrs)
end
--------------------------------------------------------
function DataArrival(user, data)
if( strsub(data, 1, 1) == "<" ) then
if user.bOperator then
local s,e,prefix,cmd = strfind(data, "%b<>%s+(%S+)(%S+)")
if prefix == "!clockoff" then
StopTimer()
frmHub:UnregBot(startchrs ..current ..endchrs)
return 1
elseif prefix == "!clockon" then
current = date("%H:%M:%S")
StartTimer()
frmHub:RegBot(startchrs ..current ..endchrs)
return 1
end
end
end
end  

I will look at adding description for it Trucker.

Thanks NL... your help has got me this far :-)
Title:
Post by: pHaTTy on 06 March, 2004, 16:58:37
see problem with this is sending myinfo to all every second, ever heard of ruri destroyer 1?, well it does the same, faster tho i think, well u are technically doing the saame with a lau script, just so u know,

later,,
Title:
Post by: kepp on 06 March, 2004, 17:44:27
well, ruri's goes alot faster, i could guess 400 ms
Title:
Post by: WooshMan on 06 March, 2004, 18:09:39
Good point.

OK.. I will complete the script using Hours and minutes as then it will only send every minute, which will be no different to a large hub with useres joining and leaving.

Thanks for pointing that out to me.

Woosh
Title:
Post by: pHaTTy on 06 March, 2004, 20:36:28
QuoteOriginally posted by WooshMan
Good point.

OK.. I will complete the script using Hours and minutes as then it will only send every minute, which will be no different to a large hub with useres joining and leaving.

Thanks for pointing that out to me.

Woosh

np, but otherwise its a very good idea, makes some animation for a change on dc :)
Title:
Post by: ??????Hawk?????? on 06 March, 2004, 22:12:10
nice script WooshMan :-)
added  bot description / email / speed




-- A clock which diplays the current time in Hours and minutes.

-- Version 1.3
-- ops only can turn on and off
-- added !clockon and !clockoff.  Turns clock on and off
-- added characters to start and end of time.  User can choose anything to prefix and finish the clock
-- code added to give other bot info by ??????Hawk??????  06-03-04
startchrs = "-*"   -- shows before clock
endchrs = "*-"    -- shows after clock
gb = 15 * 1024 * 1024
botDesc = "I can tell the time"
botSpeed = "slow"
botEmail = "clocks@mynet.com"
botShare = 1 * 1024 * gb

current = date("%H:%M:%S")
sec = 1000
min = sec*60
--------------------------------------------------------
function Main()
SetTimer(sec)
end
--------------------------------------------------------
function OnTimer()
frmHub:UnregBot(startchrs ..current ..endchrs)
time = date("%H:%M:%S")
current = time
frmHub:RegBot(startchrs ..current ..endchrs)
  info = "$MyINFO $ALL -*"..current.."*- "..botDesc.."$ $"..botSpeed..strchar( 1 ).."$"..botEmail.."$"..botShare.."$"
SendToAll( info )
end
--------------------------------------------------------
function OnExit()
frmHub:UnregBot(startchrs ..current ..endchrs)
end
--------------------------------------------------------
function DataArrival(user, data)
if( strsub(data, 1, 1) == "<" ) then
if user.bOperator then
local s,e,prefix,cmd = strfind(data, "%b<>%s+(%S+)(%S+)")
if prefix == "!clockoff" then
StopTimer()
frmHub:UnregBot(startchrs ..current ..endchrs)
return 1
elseif prefix == "!clockon" then
current = date("%H:%M:%S")
StartTimer()
frmHub:RegBot(startchrs ..current ..endchrs)

return 1
end
end
end
end  
--------------------------------------------------------------------------------

Title:
Post by: Skrollster on 06 March, 2004, 22:49:06
please use [code] tags then you post any code, it is much esier to read then..
Title:
Post by: NightLitch on 06 March, 2004, 22:51:48
Damn to slow, you got before me Skroll. :-)
Title:
Post by: Skrollster on 06 March, 2004, 22:56:02
as always...
Title:
Post by: Skrollster on 06 March, 2004, 22:58:32
if you don't want your script to check the time every sec, though it might be very cpu expensive, check out my old script:

timerintervall = 3 -- Number of hours between timeractions

function oneveryhour()
local sHour = date("%H")
local sMin = date("%M")
if sMin=="00" then
SendToAll("Time", "\t\t\t\t- = [ " ..sHour.. ":" ..sMin.. " o'clock ] = - ")
end
StopTimer()
local sHour,sSec,sMin = tonumber(date("%H")),tonumber(date("%S")),tonumber(date("%M")) --(sHour*60*60*1000)
-- local sSec,sMin = tonumber(date("%S")),tonumber(date("%M"))

SetTimer(timerintervall*60*60*1000-(mod(sHour/24,timerintervall)*60*60*1000)-(sMin*60*1000)-(sSec*1000)+(1*1000))
StartTimer()
end

function OnTimer()
oneveryhour()
end

function Main()
local sSec,sMin = tonumber(date("%S")),tonumber(date("%M"))
SetTimer(60*60*1000-(sMin*60*1000)-(sSec*1000)+(1*1000))
StartTimer()
end--Skrollster 2003-07-18
Title:
Post by: WooshMan on 06 March, 2004, 23:05:35
Fantastic Hawk.... I will try it tomorrow.  TY

Saves me doing it :-)

As for not using seconds Skroller, change timer to min and remove the :%S and thats all you need to do.

But thanks for your old script.

Woosh
Title:
Post by: Skrollster on 06 March, 2004, 23:15:18
my bad, didn't check what the script did.. sorry.. ;)
Title:
Post by: Sky on 06 March, 2004, 23:42:46
Top Marks Woosh m8
We've got 2 Brains on our network now
hope you have more to follow this TimeBot
:c) :D
Title:
Post by: Skrollster on 07 March, 2004, 00:33:58
after thinking a while i realise this can't be healthy for your upload... at least not for bigger hubs...

2000 users x 1 messages per sec...

each message is about 130 byte

($Quit -*00:00:00*-|
$Hello -*00:00:01*-|
$MyINFO $ALL -*00:00:01*- I can tell the time$ $slow1$clocks@mynet.com$16106127360$|)

this means about 250kbyte/sec

and this more then most of you have....
and this is only for this bot alone...
Title:
Post by: WooshMan on 07 March, 2004, 01:01:33
I see your point.....

Hence the minute script.. it just so happened I updated the seconds script....

I will write the full script for minutes only, which will save all of that bandwidth.
Title:
Post by: Skrollster on 07 March, 2004, 01:23:27
;)
Title:
Post by: pHaTTy on 07 March, 2004, 02:31:35
QuoteOriginally posted by Skrollster
after thinking a while i realise this can't be healthy for your upload... at least not for bigger hubs...

2000 users x 1 messages per sec...

each message is about 130 byte

($Quit -*00:00:00*-|
$Hello -*00:00:01*-|
$MyINFO $ALL -*00:00:01*- I can tell the time$ $slow1$clocks@mynet.com$16106127360$|)

this means about 250kbyte/sec

and this more then most of you have....
and this is only for this bot alone...


ya i was talking to trucker about the same thing eheh, just as well u posted it,, id of forgot lmao
Title:
Post by: Skrollster on 07 March, 2004, 02:39:26
but it wasn't as bad as i would have thought though..
Title:
Post by: pHaTTy on 07 March, 2004, 09:45:54
hmm i dunno, i seen in a few hubs, and it took me 2-3 mins to get in, and the time was skipping 6-7 seconds a time,
Title:
Post by: ??????Hawk?????? on 09 March, 2004, 00:37:59
Hello again   this is how mine is set up   runs sweet updating once a min:-

Great script Woosh :-)



-- timebot by WooshMan -- landofkaraoke.ath.cx

-- creates a dummy user at the top of the user list
-- and displays the time as the user name.
-- A clock which diplays the current time in Hours and minutes.

-- Version 1.3
-- ops only can turn on and off
-- added !clockon and !clockoff.  Turns clock on and off
-- added characters to start and end of time.  User can choose anything to prefix and finish the clock
-- code added to give other bot info by ??????Hawk??????  06-03-04
startchrs = "-?????"   -- shows before clock
endchrs = "?????-"    -- shows after clock
gb = 15 * 1024 * 1024
botDesc = "??????Hubs Local Time??????"
botSpeed = "Time"
botEmail = "clocks@hawks-world.com"
botShare = 1 * 1024 * gb

current = date("%H:%M:%S")
sec = 1000
min = sec*60
--------------------------------------------------------
function Main()
SetTimer(min)
end
--------------------------------------------------------
function OnTimer()
frmHub:UnregBot(startchrs ..current ..endchrs)
time = date("%H:%M_Hrs_GmT")
current = time
frmHub:RegBot(startchrs ..current ..endchrs)
  info = "$MyINFO $ALL -?????"..current.."?????- "..botDesc.."$ $"..botSpeed..strchar( 1 ).."$"..botEmail.."$"..botShare.."$"
SendToAll( info )
end
--------------------------------------------------------
function OnExit()
frmHub:UnregBot(startchrs ..current ..endchrs)
end
--------------------------------------------------------
function DataArrival(user, data)
if( strsub(data, 1, 1) == "<" ) then
if user.bOperator then
local s,e,prefix,cmd = strfind(data, "%b<>%s+(%S+)(%S+)")
if prefix == "!clockoff" then
StopTimer()
frmHub:UnregBot(startchrs ..current ..endchrs)
return 1
elseif prefix == "!clockon" then
current = date("%H:%M_Hrs_GmT")
StartTimer()
frmHub:RegBot(startchrs ..current ..endchrs)
return 1
end
end
end
end  
--------------------------------------------------------------------------------



BTW....  the  other info dosnt appear for 1 min on clock start
Title:
Post by: spurlos on 13 March, 2004, 18:37:45
Part|Join messages spamming..
Is it any way to disable this message from bot on server side?
Any clients want to see part|join messages, but not from timebot =)
Title:
Post by: DorianG on 15 March, 2004, 13:33:59
I want to add an alarm clock. Example, an user ,chat, and he doesn't want to forget an appointment. So set the hour of the appointment and when it is the hour the Bot sends him a message in mainchat. Is it possible?
Title: Help mee plz!
Post by: WickeD on 16 March, 2004, 17:09:49
Can eny one take away from this script the on/off funktion! So I do not need to start the Time script when I restart all scripts i the hubsoft!  I want the Time script to bee on ON all the time!


-- timebot by WooshMan -- landofkaraoke.ath.cx

-- creates a dummy user at the top of the user list
-- and displays the time as the user name.
-- A clock which diplays the current time in Hours and minutes.

-- Version 1.3
-- ops only can turn on and off
-- added !clockon and !clockoff.  Turns clock on and off
-- added characters to start and end of time.  User can choose anything to prefix and finish the clock
-- code added to give other bot info by ??????Hawk??????  06-03-04
startchrs = "[Bot]-?-?-"   -- shows before clock
endchrs = "-?-?-"    -- shows after clock
gb = 15 * 1024 * 1024
botDesc = "??????Show local time in this hub??????"
botSpeed = "BOT"
botEmail = "support@northside.se"
botShare = 0 * 1024 * gb

current = date("%H:%M:%S")
sec = 1000
min = sec*60
--------------------------------------------------------
function Main()
SetTimer(min)
end
--------------------------------------------------------
function OnTimer()
frmHub:UnregBot(startchrs ..current ..endchrs)
time = date("%H:%M")
current = time
frmHub:RegBot(startchrs ..current ..endchrs)
  info = "$MyINFO $ALL [Bot]-?-?-"..current.."-?-?- "..botDesc.."$ $"..botSpeed..strchar( 1 ).."$"..botEmail.."$"..botShare.."$"
SendToAll( info )
end
--------------------------------------------------------
function OnExit()
frmHub:UnregBot(startchrs ..current ..endchrs)
end
--------------------------------------------------------
function DataArrival(user, data)
if( strsub(data, 1, 1) == "<" ) then
if user.bOperator then
local s,e,prefix,cmd = strfind(data, "%b<>%s+(%S+)(%S+)")
if prefix == "!clockoff" then
StopTimer()
frmHub:UnregBot(startchrs ..current ..endchrs)
return 1
elseif prefix == "!clockon" then
current = date("%H:%M")
StartTimer()
frmHub:RegBot(startchrs ..current ..endchrs)
return 1
end
end
end
end  



//WickeD
Title:
Post by: WooshMan on 16 March, 2004, 17:44:02
Hi,

Take out the DataArrival(user,data)  part.

And in Main()

StartTimer()
frmHub:RegBot(startchrs ..current ..endchrs)

Add that.

That should put the clock in all the time.

Not tested though.

Woosh
Title: Help whit that!
Post by: WickeD on 16 March, 2004, 18:41:05
Can you fix that for me? I can not get it to work!

Can you add that in the script and post it here??? Plzzz!


//WickeD
Title:
Post by: ??????Hawk?????? on 16 March, 2004, 19:37:07
try this WickeD m8



-- timebot by WooshMan -- landofkaraoke.ath.cx

-- creates a dummy user at the top of the user list
-- and displays the time as the user name.
-- A clock which diplays the current time in Hours and minutes.

-- Version 1.3
-- ops only can turn on and off
-- added !clockon and !clockoff.  Turns clock on and off
-- added characters to start and end of time.  User can choose anything to prefix and finish the clock
-- code added to give other bot info by ??????Hawk??????  06-03-04 / removed switches 16-13-04
startchrs = "[Bot]-?-?-"   -- shows before clock
endchrs = "-?-?-"    -- shows after clock
gb = 15 * 1024 * 1024
botDesc = "??????Show local time in this hub??????"
botSpeed = "BOT"
botEmail = "support@northside.se"
botShare = 0 * 1024 * gb

current = date("%H:%M:%S")
sec = 1000
min = sec*60
--------------------------------------------------------
function Main()
SetTimer(min)
current = date("%H:%M")
StartTimer()
frmHub:RegBot(startchrs ..current ..endchrs)

end
--------------------------------------------------------
function OnTimer()
frmHub:UnregBot(startchrs ..current ..endchrs)
time = date("%H:%M")
current = time
frmHub:RegBot(startchrs ..current ..endchrs)
  info = "$MyINFO $ALL [Bot]-?-?-"..current.."-?-?- "..botDesc.."$ $"..botSpeed..strchar( 1 ).."$"..botEmail.."$"..botShare.."$"
SendToAll( info )
end
--------------------------------------------------------
function OnExit()
frmHub:UnregBot(startchrs ..current ..endchrs)
end
--------------------------------------------------------

Title: Thx my m8!!!
Post by: WickeD on 16 March, 2004, 19:50:47
It works fine now!!!!  " My WickeD m8"  =)

Thx a lot for your help!!  


//WickeD
Title: One more thing!!
Post by: WickeD on 16 March, 2004, 19:56:48
Is there a way to get the Description to bee there all the time??  It vanish from user list when I restart the scripts from hubsoft!

//WickeD
Title:
Post by: ??????Hawk?????? on 16 March, 2004, 20:04:29


-- timebot by WooshMan -- landofkaraoke.ath.cx

-- creates a dummy user at the top of the user list
-- and displays the time as the user name.
-- A clock which diplays the current time in Hours and minutes.

-- Version 1.3
-- ops only can turn on and off
-- added !clockon and !clockoff.  Turns clock on and off
-- added characters to start and end of time.  User can choose anything to prefix and finish the clock
-- code added to give other bot info by ??????Hawk??????  06-03-04 / removed switches 16-13-04
startchrs = "[Bot]-?-?-"   -- shows before clock
endchrs = "-?-?-"    -- shows after clock
gb = 15 * 1024 * 1024
botDesc = "??????Show local time in this hub??????"
botSpeed = "BOT"
botEmail = "support@northside.se"
botShare = 0 * 1024 * gb
current = date("%H:%M")
sec = 1000
min = sec*60
info = "$MyINFO $ALL [Bot]-?-?-"..current.."-?-?- "..botDesc.."$ $"..botSpeed..strchar( 1 ).."$"..botEmail.."$"..botShare.."$"
--------------------------------------------------------
function Main()
SetTimer(min)
current = date("%H:%M")
StartTimer()
frmHub:RegBot(startchrs ..current ..endchrs)
SendToAll( info )

end
--------------------------------------------------------
function OnTimer()
frmHub:UnregBot(startchrs ..current ..endchrs)
time = date("%H:%M")
current = time
frmHub:RegBot(startchrs ..current ..endchrs)
  info = "$MyINFO $ALL [Bot]-?-?-"..current.."-?-?- "..botDesc.."$ $"..botSpeed..strchar( 1 ).."$"..botEmail.."$"..botShare.."$"
SendToAll( info )
end
--------------------------------------------------------
function OnExit()
frmHub:UnregBot(startchrs ..current ..endchrs)
end
--------------------------------------------------------


Title: Thx m8!!
Post by: WickeD on 16 March, 2004, 20:16:32
Now it is working!!!


//WickeD
Title:
Post by: ??????Hawk?????? on 16 March, 2004, 20:31:45
hi WickeD

Although it didnt show on log in  it would have appeared on timer trigger ( no more than 1 min on entring the hub )
Title:
Post by: Psycho_Chihuahua on 23 February, 2005, 21:27:56
is it possible to port this to lua5 (dchpp++)?

i tried using plops converter but i only get errors