script with one command
 

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

script with one command

Started by Syphrone-NL, 05 May, 2005, 16:18:22

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Syphrone-NL

Can somebody make me a script with one command:

!diner1

If you type that there should appear a message in pm with some tekst in it

I want to change the tekst and want to putt the tekst file in a folder.

Uses a bot

I want that i can change the folder name and the bot name.

thx in advanced
Owner of 2 public hubs in Palace Network ---> www.palace-network.nl

jiten

QuoteOriginally posted by Syphrone-NL
Can somebody make me a script with one command:

!diner1

If you type that there should appear a message in pm with some tekst in it

I want to change the tekst and want to putt the tekst file in a folder.

Uses a bot

I want that i can change the folder name and the bot name.

thx in advanced
Have you searched in Lua 5 Request/Help with and Finished Scripts Section? I've seen scripts that do that there.

Cheers

Syphrone-NL

Cant find it you got a link
Owner of 2 public hubs in Palace Network ---> www.palace-network.nl

jiten

Something like this.

Cheers

Syphrone-NL

Almost

One little thing

I got the tekst file in a folder so can you add that folder thing to it please

So i need to fill in the folder and fill in the name of the tekst file
Owner of 2 public hubs in Palace Network ---> www.palace-network.nl

kepp

Or get guarding as it does exactly what you want + more
Guarding    

Syphrone-NL

got robocop and i only need that script
Owner of 2 public hubs in Palace Network ---> www.palace-network.nl

jiten

#7
Try this too:
-- rules by jiten

sConf = {
	sBot = frmHub:GetHubBotName(),
	sFile1 = "diner1.txt",
	sFolder = "txt"			-- folder where the file is stored
}

function Main()
	frmHub:RegBot(sConf.sBot)
end

function ChatArrival(user,data)
	local data = string.sub(data,1,-2)
	local s,e,cmd = string.find (data, "%b<>%s+[%!%?%+%#](%S+)" )
	if cmd then
		local tCmds = 	{
			["diner1"] = 	function(user,data)
						user:SendPM(sConf.sBot,ReadFile(sConf.sFile1))
					end,
		}
		if tCmds[cmd] then 
			return tCmds[cmd](user,data), 1
		end
	end
end

function ReadFile(file)
	local fFile = io.open(sConf.sFolder.."/"..file)
	if fFile then
		local message = fFile:read("*all");
		fFile:close();
		return message;
	else
		return file.." not found!"
	end
end
Best regards

Syphrone-NL

Owner of 2 public hubs in Palace Network ---> www.palace-network.nl

jiten

You're welcome...

Syphrone-NL

got an error when i want i do !dinner1

Syntax ...oftware\0.3.3.0.b16.09.nt.dbg\scripts\onecommand.lua:35: bad argument #2 to `sub' (number expected, got string)

How do i fix that
Owner of 2 public hubs in Palace Network ---> www.palace-network.nl

jiten

#11
Bug fixed. Copy the script again.
Where's my head at? :D

Cheers

Syphrone-NL

weird now i dont get anything
Owner of 2 public hubs in Palace Network ---> www.palace-network.nl

jiten


Syphrone-NL

Finally its works great


I tryed now seven commands lol for fun

I tryed this:
sConf = {
	sBot = frmHub:GetHubBotName(),
	sFile1 = "diner1.txt",
	sFile2 = "diner1.txt",
	sFile3 = "diner1.txt",
	sFile4 = "diner1.txt",
	sFile5 = "diner1.txt",
	sFile6 = "diner1.txt",
	sFile7 = "diner1.txt",
	sFolder = "txt"			-- folder where the file is stored
}

function Main()
	frmHub:RegBot(sConf.sBot)
end

function ChatArrival(user,data)
	local data = string.sub(data,1,-2)
	local s,e,cmd = string.find (data, "%b<>%s+[%!%?%+%#](%S+)" )
	if cmd then
		local tCmds = 	{
			["diner7"] = 	function(user,data)
						user:SendPM(sConf.sBot,ReadFile(sConf.sFile7))
					end,
		}
		if tCmds[cmd] then 
			return tCmds[cmd](user,data), 1
		end
	end
end

function ChatArrival(user,data)
	local data = string.sub(data,1,-2)
	local s,e,cmd = string.find (data, "%b<>%s+[%!%?%+%#](%S+)" )
	if cmd then
		local tCmds = 	{
			["diner1"] = 	function(user,data)
						user:SendPM(sConf.sBot,ReadFile(sConf.sFile1))
					end,
		}
		if tCmds[cmd] then 
			return tCmds[cmd](user,data), 1
		end
	end
end

function ChatArrival(user,data)
	local data = string.sub(data,1,-2)
	local s,e,cmd = string.find (data, "%b<>%s+[%!%?%+%#](%S+)" )
	if cmd then
		local tCmds = 	{
			["diner2"] = 	function(user,data)
						user:SendPM(sConf.sBot,ReadFile(sConf.sFile2))
					end,
		}
		if tCmds[cmd] then 
			return tCmds[cmd](user,data), 1
		end
	end
end

function ChatArrival(user,data)
	local data = string.sub(data,1,-2)
	local s,e,cmd = string.find (data, "%b<>%s+[%!%?%+%#](%S+)" )
	if cmd then
		local tCmds = 	{
			["diner3"] = 	function(user,data)
						user:SendPM(sConf.sBot,ReadFile(sConf.sFile3))
					end,
		}
		if tCmds[cmd] then 
			return tCmds[cmd](user,data), 1
		end
	end
end

function ChatArrival(user,data)
	local data = string.sub(data,1,-2)
	local s,e,cmd = string.find (data, "%b<>%s+[%!%?%+%#](%S+)" )
	if cmd then
		local tCmds = 	{
			["diner4"] = 	function(user,data)
						user:SendPM(sConf.sBot,ReadFile(sConf.sFile4))
					end,
		}
		if tCmds[cmd] then 
			return tCmds[cmd](user,data), 1
		end
	end
end

function ChatArrival(user,data)
	local data = string.sub(data,1,-2)
	local s,e,cmd = string.find (data, "%b<>%s+[%!%?%+%#](%S+)" )
	if cmd then
		local tCmds = 	{
			["diner5"] = 	function(user,data)
						user:SendPM(sConf.sBot,ReadFile(sConf.sFile5))
					end,
		}
		if tCmds[cmd] then 
			return tCmds[cmd](user,data), 1
		end
	end
end

function ChatArrival(user,data)
	local data = string.sub(data,1,-2)
	local s,e,cmd = string.find (data, "%b<>%s+[%!%?%+%#](%S+)" )
	if cmd then
		local tCmds = 	{
			["diner6"] = 	function(user,data)
						user:SendPM(sConf.sBot,ReadFile(sConf.sFile6))
					end,
		}
		if tCmds[cmd] then 
			return tCmds[cmd](user,data), 1
		end
	end
end

function ReadFile(file)
	local fFile = io.open(sConf.sFolder.."/"..file)
	if fFile then
		local message = fFile:read("*all");
		fFile:close();
		return message;
	else
		return file.." not found!"
	end
end

But that doesnt work
Maybe some can tell my why???
I think because i dont know how make a script
Owner of 2 public hubs in Palace Network ---> www.palace-network.nl

Dessamator

QuoteOriginally posted by Syphrone-NL
But that doesnt work
Maybe some can tell my why???
I think because i dont know how make a script

well, uve answered the question by urself, "I think because i dont know how make a script", u cant just make a new ChatArrival for each command u add, it just doesnt work that way, :)
Ignorance is Bliss.

Syphrone-NL

Can you help me a little bit forward???
Owner of 2 public hubs in Palace Network ---> www.palace-network.nl

jiten

Change ur code to this pattern:
function ChatArrival(user,data)
	local data = string.sub(data,1,-2)
	local s,e,cmd = string.find (data, "%b<>%s+[%!%?%+%#](%S+)" )
	if cmd then
		local tCmds = 	{
			["diner1"] = 	function(user,data)
						user:SendPM(sConf.sBot,ReadFile(sConf.sFile1))
					end,

		...


			["diner7"] = 	function(user,data)
						user:SendPM(sConf.sBot,ReadFile(sConf.sFile7))
					end,
		}
		if tCmds[cmd] then 
			return tCmds[cmd](user,data), 1
		end
	end
end

Cheers

Syphrone-NL

Cool got it

sConf = {
	sBot = frmHub:GetHubBotName(),
	sFile1 = "diner1.txt",
	sFile2 = "diner1.txt",
	sFile3 = "diner1.txt",
	sFile4 = "diner1.txt",
	sFile5 = "diner1.txt",
	sFile6 = "diner1.txt",
	sFile7 = "diner1.txt",
	sFolder = "txt"			-- folder where the file is stored
}

function Main()
	frmHub:RegBot(sConf.sBot)
end

function ChatArrival(user,data)
	local data = string.sub(data,1,-2)
	local s,e,cmd = string.find (data, "%b<>%s+[%!%?%+%#](%S+)" )
	if cmd then
		local tCmds = 	{
			["diner1"] = 	function(user,data)
						user:SendPM(sConf.sBot,ReadFile(sConf.sFile1))
					end,

			["diner2"] = 	function(user,data)
						user:SendPM(sConf.sBot,ReadFile(sConf.sFile2))
					end,
			
			["diner3"] = 	function(user,data)
						user:SendPM(sConf.sBot,ReadFile(sConf.sFile3))
					end,

			["diner4"] = 	function(user,data)
						user:SendPM(sConf.sBot,ReadFile(sConf.sFile4))
					end,

			["diner5"] = 	function(user,data)
						user:SendPM(sConf.sBot,ReadFile(sConf.sFile5))
					end,

			["diner6"] = 	function(user,data)
						user:SendPM(sConf.sBot,ReadFile(sConf.sFile6))
					end,

			["diner7"] = 	function(user,data)
						user:SendPM(sConf.sBot,ReadFile(sConf.sFile7))
					end,
		}
		if tCmds[cmd] then 
			return tCmds[cmd](user,data), 1
		end
	end
end


function ReadFile(file)
	local fFile = io.open(sConf.sFolder.."/"..file)
	if fFile then
		local message = fFile:read("*all");
		fFile:close();
		return message;
	else
		return file.." not found!"
	end
end
Owner of 2 public hubs in Palace Network ---> www.palace-network.nl

jiten

Nice to know it.

Cheers

PS: I'd be better for u use to use the Rotating Message script if you wanted them to be posted after x minutes.

Syphrone-NL

The rotating message is for a 24 hour rotating so after 24 hours there comes 1 tekst file with a message for a meal in it how to make the meal. But if the users want to see the meal on a other time they use that script
Owner of 2 public hubs in Palace Network ---> www.palace-network.nl

Syphrone-NL

Can somebody make me a little thing in the little script that if somebody uses the command his nick and the command he used  are send to opchat also
Owner of 2 public hubs in Palace Network ---> www.palace-network.nl

Syphrone-NL

Can somebody make me a little thing in the little script that if somebody uses the command his nick and the command he used  are send to opchat also

script
sConf = {
	sBot = frmHub:GetHubBotName(),
	sFile1 = "diner1.txt",
	sFile2 = "diner1.txt",
	sFile3 = "diner1.txt",
	sFile4 = "diner1.txt",
	sFile5 = "diner1.txt",
	sFile6 = "diner1.txt",
	sFile7 = "diner1.txt",
	sFolder = "txt"			-- folder where the file is stored
}

function Main()
	frmHub:RegBot(sConf.sBot)
end

function ChatArrival(user,data)
	local data = string.sub(data,1,-2)
	local s,e,cmd = string.find (data, "%b<>%s+[%!%?%+%#](%S+)" )
	if cmd then
		local tCmds = 	{
			["diner1"] = 	function(user,data)
						user:SendPM(sConf.sBot,ReadFile(sConf.sFile1))
					end,

			["diner2"] = 	function(user,data)
						user:SendPM(sConf.sBot,ReadFile(sConf.sFile2))
					end,
			
			["diner3"] = 	function(user,data)
						user:SendPM(sConf.sBot,ReadFile(sConf.sFile3))
					end,

			["diner4"] = 	function(user,data)
						user:SendPM(sConf.sBot,ReadFile(sConf.sFile4))
					end,

			["diner5"] = 	function(user,data)
						user:SendPM(sConf.sBot,ReadFile(sConf.sFile5))
					end,

			["diner6"] = 	function(user,data)
						user:SendPM(sConf.sBot,ReadFile(sConf.sFile6))
					end,

			["diner7"] = 	function(user,data)
						user:SendPM(sConf.sBot,ReadFile(sConf.sFile7))
					end,
		}
		if tCmds[cmd] then 
			return tCmds[cmd](user,data), 1
		end
	end
end


function ReadFile(file)
	local fFile = io.open(sConf.sFolder.."/"..file)
	if fFile then
		local message = fFile:read("*all");
		fFile:close();
		return message;
	else
		return file.." not found!"
	end
end
Owner of 2 public hubs in Palace Network ---> www.palace-network.nl

Markitos

QuoteOriginally posted by Syphrone-NL
Can somebody make me a little thing in the little script that if somebody uses the command his nick and the command he used  are send to opchat also

script
sConf = {
	sBot = frmHub:GetHubBotName(),
	sFile1 = "diner1.txt",
	sFile2 = "diner1.txt",
	sFile3 = "diner1.txt",
	sFile4 = "diner1.txt",
	sFile5 = "diner1.txt",
	sFile6 = "diner1.txt",
	sFile7 = "diner1.txt",
	sFolder = "txt"			-- folder where the file is stored
}

function Main()
	frmHub:RegBot(sConf.sBot)
end

function ChatArrival(user,data)
	local data = string.sub(data,1,-2)
	local s,e,cmd = string.find (data, "%b<>%s+[%!%?%+%#](%S+)" )
	if cmd then
		local tCmds = 	{
			["diner1"] = 	function(user,data)
						user:SendPM(sConf.sBot,ReadFile(sConf.sFile1))
					end,

			["diner2"] = 	function(user,data)
						user:SendPM(sConf.sBot,ReadFile(sConf.sFile2))
					end,
			
			["diner3"] = 	function(user,data)
						user:SendPM(sConf.sBot,ReadFile(sConf.sFile3))
					end,

			["diner4"] = 	function(user,data)
						user:SendPM(sConf.sBot,ReadFile(sConf.sFile4))
					end,

			["diner5"] = 	function(user,data)
						user:SendPM(sConf.sBot,ReadFile(sConf.sFile5))
					end,

			["diner6"] = 	function(user,data)
						user:SendPM(sConf.sBot,ReadFile(sConf.sFile6))
					end,

			["diner7"] = 	function(user,data)
						user:SendPM(sConf.sBot,ReadFile(sConf.sFile7))
					end,
		}
		if tCmds[cmd] then 
			return tCmds[cmd](user,data), 1
		end
	end
end


function ReadFile(file)
	local fFile = io.open(sConf.sFolder.."/"..file)
	if fFile then
		local message = fFile:read("*all");
		fFile:close();
		return message;
	else
		return file.." not found!"
	end
end

I didn't understand...Can u explain better???

Syphrone-NL

If a user types !diner1 he gets a message in pm with a tekst

But i want that if the user uses that that the bot also sends a message to opchat with something like:

[user] uses the command !diner1
Owner of 2 public hubs in Palace Network ---> www.palace-network.nl

SMF spam blocked by CleanTalk