timebot
 

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

timebot

Started by Annie, 18 March, 2008, 13:12:57

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Annie

Hiya i got a little timebot for extra adds for main and i was wondering if somebody could convert it for me please :)

--Timebot for LUA 5
--
-- To main chat by blackwings
--Little changed by nErboS 
--
-- Converted to LUA 5 by Mutor 2/28/2005
--

bot = "info bot"
name1 = "Hub Info"
name2 = "Hub message"


sec = 60


fMsgAll = "MsgAll.txt"
sMsgAll = ""

fMsgAll2 = "MsgAll2.txt"
sMsgAll2 = ""

tClock = {
	["tMsgAll"] = os.clock() + 1*sec,	-- Time to show in math.minutes
	["tMsgAll2"] = os.clock() + 1*sec,	-- Time to show in math.minutes
}

function Main()
	frmHub:RegBot(bot)
	sMsgAll = Readtext(fMsgAll)
	sMsgAll2 = Readtext(fMsgAll2)
	StartTimer()
end

function OnTimer() 
	if (tClock["tMsgAll"] <= os.clock() and sMsgAll~= "") then 
		tClock["tMsgAll"] = os.clock() + 150*sec 
		SendToAll(bot, sMsgAll) 
	end 
	if (tClock["tMsgAll2"] <= os.clock() and sMsgAll2~= "") then 
		tClock["tMsgAll2"] = os.clock() + 220*sec 
		SendToAll(name2, sMsgAll2) 
	end 
end 


function Readtext(file)
local sTmp="\r\n\r\n"
    for line in io.lines(file) do
        sTmp = sTmp..line.."\r\n"
    end
    return sTmp
end


thank you :D

Madman

--Timebot for LUA 5
--
-- To main chat by blackwings
--Little changed by nErboS
--
-- Converted to LUA 5 by Mutor 2/28/2005
--
-- Converted to API 2 by Madman, 18.03.08

bot = "info bot"
name1 = "Hub Info"
name2 = "Hub message"

sec = 60

fMsgAll = "MsgAll.txt"
sMsgAll = ""

fMsgAll2 = "MsgAll2.txt"
sMsgAll2 = ""

tClock = {
	["tMsgAll"] = os.clock() + 1*sec,	-- Time to show in math.minutes
	["tMsgAll2"] = os.clock() + 1*sec,	-- Time to show in math.minutes
}

function OnStartup()
	Core.RegBot(bot,"","",true)
	sMsgAll = Readtext(fMsgAll)
	sMsgAll2 = Readtext(fMsgAll2)
	tID = TmrMan.AddTimer(1*sec)
end

function OnTimer(ID)
	if tID then
		if (tClock["tMsgAll"] <= os.clock() and sMsgAll~= "") then
			tClock["tMsgAll"] = os.clock() + 150*sec
			Core.SendToAll("<"..bot.."> ".. sMsgAll)
		end
		if (tClock["tMsgAll2"] <= os.clock() and sMsgAll2~= "") then
			tClock["tMsgAll2"] = os.clock() + 220*sec
			Core.SendToAll("<"..name2.."> ".. sMsgAll2)
		end
	end
end


function Readtext(file)
local sTmp="\r\n\r\n"
	for line in io.lines(file) do
		sTmp = sTmp..line.."\r\n"
		end
	return sTmp
end


That should do it...
It's untested tho..
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

Annie

It works great thank you Madman :D

Annie

Ive changed the hub now to ptokax 4.1.1  and now the time bot has an error

this is the error I get scripts\timebot.lua:50: bad argument #1 to 'lines' (MsgAll.txt: No such file or directory)

worked fine on the 4.0.0e hub

I was wondering can somebody fix it please  :D

Annie

Yes the files were there. Its working great now  thanks Mutor :D

SMF spam blocked by CleanTalk