Memories Script
 

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

Memories Script

Started by 6Marilyn6Manson6, 16 January, 2005, 20:58:17

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

6Marilyn6Manson6

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

bastya_elvtars

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. :)
Everything could have been anything else and it would have just as much meaning.

6Marilyn6Manson6

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

??????Hawk??????

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

6Marilyn6Manson6

HAWK thanks for all ;)

SMF spam blocked by CleanTalk