PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: DorianG on 15 March, 2004, 20:02:51

Title: An Alarm Clock
Post by: DorianG on 15 March, 2004, 20:02:51
It's possible to create an alarm clock. Example, an user ,chat, and he doesn't want to forget an appointment. So the user can set the hour of the appointment and when it is the hour, the Bot sends him a message in mainchat.

Someone, can help me!!
Title:
Post by: Skrollster on 15 March, 2004, 21:08:06
as usual, haven't tested it, but it is atleast a start...

timerintervall = 1 -- Number of hours between timeractions
Bot
appointments = {}

function oneveryMin()
StopTimer()
local sHour,sSec,sMin = tonumber(date("%H")),tonumber(date("%S")),tonumber(date("%M")) --(sHour*60*60*1000)

if appointments[sHour..":"..sMin] then
for i=1, getn(appointments[sHour..":"..sMin]) do
SendPmToNick(appointments[sHour..":"..sMin].i.name, Bot, appointments[sHour..":"..sMin].i.message)
end
end

local sSec = tonumber(date("%S"))
SetTimer((60*1000)-(sSec*1000)+(1*1000))
StartTimer()
end

function OnTimer()
oneveryMin()
end

function Main()
local sSec = tonumber(date("%S"))
SetTimer((60*1000)-(sSec*1000)+(1*1000))
StartTimer()
end

function DataArrival(user, data)
local s,e,cmd = strfind(data, "%b<>(%S+).*|")
if (( strsub(data, 1, 1) == "<" ) or (strsub(data, 1, strlen(Bot) + 5) == "$To: "..Bot) then
data=strsub(data,1,strlen(data)-1)
if (strfind(strlower(data), strlower("+addTimer"))) then
local _,_,cmd,hour,minute,message = strfind(data, "%b<>(%S+)%s+(%d%d)%:(%d%d)%s+(.*)")
if hour and minute then
if not appointments[hour..":"..minute] then
appointments[hour..":"..minute] = { {name = user.sName,message = message} }
else
tinsert(appointments[hour..":"..minute], {name = user.sName,message = message})
end
end
end
end
end

this will only work as long as you don't restart the hub, you have to get it to save the data on the harddrive if you want to beable restart the hub
Title:
Post by: DorianG on 16 March, 2004, 10:54:56
the bot give me an error..

last token read: `then' at line 34 in string
Title:
Post by: Skrollster on 16 March, 2004, 11:04:22
there is a ) missing, try to fix it, this way you will learn much faster..
Title:
Post by: Dessamator on 22 March, 2005, 15:55:02
hmm, heres the script, Here (http://board.univ-angers.fr/thread.php?threadid=4008&boardid=26&styleid=1&sid=f7fbdc503ed591d453315139bfd0c127)
Title: great linking ;0)
Post by: UwV on 22 March, 2005, 22:58:48
QuoteOriginally posted by Dessamator
hmm, heres the script, Alarm bot (http://board.univ-angers.fr/thread.php?threadid=1609&boardid=11&sid=0afe01af3447d6bdd51af1163e9a3e56)
click here to go here .. ?  :P  ;)
Title:
Post by: jiten on 23 March, 2005, 07:19:29
I think he meant this (http://board.univ-angers.fr/thread.php?threadid=4008&boardid=26&styleid=1&sid=f7fbdc503ed591d453315139bfd0c127).  :]

Best regards,

jiten
Title:
Post by: Dessamator on 23 March, 2005, 14:37:47
yaps, exactly, jiten