PtokaX forum

Development Section => Your Developing Problems => Topic started by: lysergicacid on 11 January, 2005, 01:14:06

Title: help with non ptokax script plz ??
Post by: lysergicacid on 11 January, 2005, 01:14:06
ok this is what ive got  -->>

Crontab -->>
*/1 * * * * /usr/local/bin/hubfortune

pathetic but functional bash script -->>

#!/bin/bash
/usr/bin/fortune > /etc/verlihub/scripts/fortune.txt


-- Fortune

botname = "Fortune"
filename = "/etc/verlihub/scripts/fortune.txt"
fortunes = {}
-- 30 min = 60 sec * 30
maxTicks = 1800
-- switch between 1 and nil
enabledTimer = 1

Func = {}

Func.LoadStrings = function()
i = 0
for line in io.lines(filename) do
 if line ~= nil then
  fortunes[i] = line
  i = i+1
 end
end
end

function Main()
VH:AddRobot(botname, 10, "Spam Bot", "Bot/Hub", "bot@hub.com", "1$
Func.LoadStrings()
end

return 1
end

-- Timer
TimerTicks = 0

function VH_OnTimer()
if (enabledTimer) then
 TimerTicks = TimerTicks + 1
 if TimerTicks == maxTicks then
  VH:SendDataToAll("<"..botname.."> "..fortunes[math.random(0, table.getn(fortu$
  TimerTicks = 0
 end
end
end


now its not right all i want to do is get the script to access a txt file i have setup and spam txt outa that every 30 mins into my hub chat anyone know how id accomplish this plz plz plz ???
Title:
Post by: plop on 11 January, 2005, 17:26:20
give this a try.
-- Fortune

botname = "Fortune"
filename = "/etc/verlihub/scripts/fortune.txt"
fortunes = {}
-- 30 min = 60 sec * 30
maxTicks = 1800
-- switch between 1 and nil
enabledTimer = 1

Func = {}

Func.LoadStrings = function()
   i = 0
   for line in io.lines(filename) do
if line ~= nil then
  fortunes[i] = line
  i = i+1
end
   end
end

function Main()
   VH:AddRobot(botname, 10, "Spam Bot", "Bot/Hub", "bot@hub.com", "1$")
   Func.LoadStrings()
end

-- Timer
TimerTicks = 0

function VH_OnTimer()
   if (enabledTimer) then
TimerTicks = TimerTicks + 1
if TimerTicks == maxTicks then
  VH:SendDataToAll("<"..botname.."> "..fortunes[math.random(0, table.getn(fortune))].."1$")
  TimerTicks = 0
end
   end
end

plop
Title:
Post by: lysergicacid on 16 January, 2005, 05:03:15
hmm nope doesnt say anything at all now, ima try get back in nilles hub so i can explain better, ty man

Aka - ?????rg?