An Alarm Clock
 

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

An Alarm Clock

Started by DorianG, 15 March, 2004, 20:02:51

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

DorianG

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!!

Skrollster

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

DorianG

the bot give me an error..

last token read: `then' at line 34 in string

Skrollster

there is a ) missing, try to fix it, this way you will learn much faster..

Dessamator

#4
hmm, heres the script, Here
Ignorance is Bliss.

UwV

QuoteOriginally posted by Dessamator
hmm, heres the script, Alarm bot
click here to go here .. ?  :P  ;)
\NL   The knowledge and skills you have achieved are meant to be forgotten so you can float comfortably in emptiness, without obstruction.
" Holly loves me,...  . "      ;o)

& don't forget, the motto is :
  -- SUPPORT YOUR LOCAL DJ'S --

jiten

I think he meant this.  :]

Best regards,

jiten

Dessamator

yaps, exactly, jiten
Ignorance is Bliss.

SMF spam blocked by CleanTalk