Hellp I request script for memories of hub with commands:
!addmemories for add new memories
!delmemories for delete old memories
!settimers for set timers in minute of next memories
and when show all memories...... restart memories in automatic of... firte memories. Thank a lot byeeeeeeeeeee
so is this basically a log where you enter things manuall?
i am terribly sorry, but i cannot get the timer part - please a bit more understtandable. :)
Hello bas... thank for your help.. I have this script:
BotName="[Chaotic1]"
memoriesline=5
TimeSpanInMinutes = 1
function Main()
frmHub:RegBot(BotName)
SetTimer(TimeSpanInMinutes*60000)
StartTimer()
SendToAll(BotName,"Chaotic1 V 1.0 STaRTeD")
end
function GetCommand(message)
s,e,command=strfind(message,"(%S+)")
return command
end
function GetOneParam(message)
s,e,param1=strfind(message,"%S+%s(.*)")
return param1
end
function DataArrival(curUser, data)
if( strsub(data, 1, 1) == "<" ) then
data=strsub(data,1,strlen(data)-1)
s,e,message = strfind( data, "%b<>%s+(.*)")
command=GetCommand(message)
if (curUser.bOperator) then
if (command=="!addmemories") then
text=GetOneParam(message)
if (text~=nil) then
local file=openfile("memories.txt","a")
write(file,text.."\n")
closefile(file)
SendToAll(BotName,"Aggiunta nuova memories... Chi sar? il fortunato???")
curUser:SendPM(BotName,"Memories aggionato..")
return 1
else
curUser:SendPM(BotName,"Hai cannato qualcosa la sintassi corretta : !addmemories frase")
end
end
end
end
end
function OnTimer()
countline=1
numberline=random(1,memoriesline)
readfrom("memories.txt")
while 1 do
line = read()
if line == nil then
break
end
if countline==numberline then
SendToAll(BotName,line)
break
end
countline=countline+1
end
readfrom()
end
and I have only this command:
!addmemories
but I want 2 commands:
!addmemories for add new memories
!delmemories for delete old memories
and i request the memories too, not randoms, but one standing the last, in a couple of time, of my own decision; and when, a part, the last memories, and so the script get start again with the first.. thanksssssssss
hi peeps ...
i only had 15 Mins so its NOT Finished But its a start.
Problems with function FRemovememory(user, data) . Something to do with the Re Indexing. deletes first ok BUt errors when you try to remove another.
SetTimer(user,data) -- To Do Should be Easy Enough
also does not appear to send Memory to main in the ontime function...
Goin out on the Beer now good luck to anyone....
--// Memories By ....
--// ??????Hawk?????? & ........ Any One Else gonna finish it :p
--// 17/01/2005
bot = "Memories" -- Bots name
Mins = 1
MemoriesF = "memories.txt"
--==================================================================
tMemories = {}
IdX = 0
timer = 60000 * Mins
function Main()
loadfile(MemoriesF,tMemories)
SetTimer(timer)
StartTimer()
end
function DataArrival(user, data)
if strsub(data,1,1) == "<" then
if strfind(data,"!addmemories") then
FAddMemory(user, data)
return 1
elseif strfind(data,"!delmemories") then
FRemovememory(user, data)
return 1
elseif strfind(data,"!showmemories") then
FShowMemories(user, data)
return 1
elseif cmd == "!settimers" then
-- SetTimer(user,data) -- To Do
end
end
end
function OnTimer()
if IdX >= getn(tMemories) then
IdX = 1
SendToAll(bot,tMemories[IdX])
IdX = IdX + 1
else
SendToAll(bot,tMemories[IdX])
IdX = IdX + 1
end
end
function FRemovememory(user, data)
local _,_, ToRemove = strfind(data,"%s+%S+%s+(%d+)")
SendToAll("DEBUG","'"..ToRemove.."'")
if ToRemove ~= nil then
user:SendData(bot,"\r\n\r\n\tRemoving :- "..tMemories[ToRemove].."\r\n\r\n\tReindexing..........\r\n\r\n")
tMemories[ToRemove] = nil
TemptMemories = {}
local Reindex = 1
for index, value in tMemories do
TemptMemories[Reindex] = value
Reindex = Reindex + 1
end
SaveTable(MemoriesF,TemptMemories)
TemptMemories = {}
tMemories = {}
loadfile(MemoriesF,tMemories)
FShowMemories(user, data)
else
user:SendData(bot,"ERR. Command is:- !delmemories [Memory Number]")
end
end
function FShowMemories(user, data)
local ttempline = "\r\n\r\n"
for a , b in tMemories do
ttempline = ttempline..a.." "..b.."\r\n"
end
user:SendData(bot,ttempline.."\r\n\!delmemories [Number]\tRemoves a Memory\r\n\t")
end
function FAddMemory(user, data)
local s,e,Linkcmd,MemToAdd = strfind(data, "%b<>%s(%S+)%s*(.*)")
tMemories[getn(tMemories) + 1] = MemToAdd
SendToAll(bot," New Memory Added ! ! !")
TemptMemories = {}
local Reindex = 1
for index, value in tMemories do
TemptMemories[Reindex] = value
Reindex = Reindex + 1
end
tMemories = {}
for index, value in TemptMemories do
tMemories[index] = value
end
TemptMemories = {}
SaveTable(MemoriesF,tMemories)
end
function SaveTable(filetoSave, TabletoSave)
writeto(filetoSave)
for aaa,bbb in TabletoSave do
TabletoSave[aaa]=bbb
write(aaa.."$$$"..bbb.."\n")
end
writeto()
end
function loadfile(filetoload, TabletoLoad)
readfrom(filetoload)
while 1 do
local line = read()
if line == nil then
break
end
local s,e,InfoOne,InfoTwo = strfind(line, "(.+)$$$(.+)")
if InfoOne ~= nil then
TabletoLoad[InfoOne]=InfoTwo
end
end
readfrom()
end
HAWK thanks for all ;)