Author Topic: timebot  (Read 2475 times)

0 Members and 1 Guest are viewing this topic.

Offline Annie

  • Double Ace
  • *
  • Posts: 104
  • Karma: +13/-5
timebot
« on: 18 March, 2008, 13:12:57 »
Hiya i got a little timebot for extra adds for main and i was wondering if somebody could convert it for me please :)

Code: [Select]
--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

PtokaX forum

timebot
« on: 18 March, 2008, 13:12:57 »

Offline Madman

  • Scripter
  • Emperor
  • ******
  • Posts: 1 316
  • Karma: +75/-1
Re: timebot
« Reply #1 on: 18 March, 2008, 20:11:46 »
Code: [Select]
--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

Offline Annie

  • Double Ace
  • *
  • Posts: 104
  • Karma: +13/-5
Re: timebot
« Reply #2 on: 18 March, 2008, 20:36:56 »
It works great thank you Madman :D

Offline Annie

  • Double Ace
  • *
  • Posts: 104
  • Karma: +13/-5
Re: timebot
« Reply #3 on: 20 January, 2009, 14:45:45 »
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

Offline Annie

  • Double Ace
  • *
  • Posts: 104
  • Karma: +13/-5
Re: timebot
« Reply #4 on: 21 January, 2009, 13:11:42 »
Yes the files were there. Its working great now  thanks Mutor :D

PtokaX forum

Re: timebot
« Reply #4 on: 21 January, 2009, 13:11:42 »