PtokaX forum

Archive => Archived 5.0 boards => Request for scripts => Topic started by: Cosmos on 04 June, 2005, 22:58:37

Title: request: Random quote
Post by: Cosmos on 04 June, 2005, 22:58:37
Simply a data file... 1 quote per line

and then any user can type !getquote or something and it will say 1 of the quotes in the main chat for everyone to see.

I did this in IRC and it was a big hit..  but basically whenever the chat is slow people type !getquote  and itll display one of the funny quotes.. in my case i want to use a list of funny things people have said in the hub..
Title:
Post by: jiten on 04 June, 2005, 23:11:59
Found this one in my scripts folder:
------------------------------------------------------------------------
------
--// Send Random Text Line every x minute // By NightLitch
-- little mod by Dessamator, added memlines and memory
------------------------------------------------------------------------------
cBotName = "botnamehere" -- enter botname
cFilename = "memories.txt" -- enter filename
cTime = 10 -- enter time in minutes
------------------------------------------------------------------------------
lineTable = {n=0}

function Main()
frmHub:RegBot(cBotName)
GetLines(cFilename)
SetTimer(cTime*60000)
StartTimer()
end


function OnTimer()
SendStuff()
end

function GetLines(filename)
local file = io.open(filename, "r")
for line in file:lines() do
table.insert(lineTable, line)
end
file:close()
end

function ChatArrival(curUser, sdata)

local s, e, cmd, args = string.find(sdata, "^%b<> %!(%a+)%s*(.*)|$")
if curUser.bOperator then
if cmd == "memories" then
SendStuff()
return 1
elseif cmd == "memaddline"  then
addline("memories.txt", args)
curUser:SendData(cBotName,"Done ,memory added")
return 1
end
end
end

function SendStuff()
GetLines(cFilename)
local message = lineTable[math.random(1,table.getn(lineTable))]
SendToAll(cBotName, message)
         return message
end

function addline(filename,msg)
local file = io.open(filename, "a+")
file:write("\n"..msg)
file:close()
end
Title:
Post by: Meka][Meka on 04 June, 2005, 23:56:39
i've wrote an external version about 3 month ago in c#, i'm gonna rewrite in either delphi or c++, once i do i'll release it here also