rules 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

rules script

Started by Genius, 30 April, 2005, 18:36:13

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Genius

Hi evryone
I nedd a script for users see the rules typing !regras
Sory my bad inglish

jiten

Here you go (not tested):
-- rules by jiten

sConf = {
	sBot = frmHub:GetHubBotName(),
	sFile1 = "file1.txt",
}

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 = 	{
			["regras"] = 	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(file)
	if fFile then
		local message = ""
		for line in io.lines(file) do
			message = message..line.."\n"
		end
		fFile:close()
		return message
	else
		return file.." not found!"
	end
end

Cheers

Genius

Hi

Tank you

The script its working :)
Tankx again

jiten


chettedeboeuf

Merci pour le script

dkt

hi jiten,
nice script..
but i need to know who uses the script in the hub i.e the name of the user using the command and also what command he i using to be displayed in main chat...the current above script doesnt show the command in main chat

for eg :- i want the below to be displayed in main chat

!regras

is it possible..

also the text file is read in pm...
can we read tat file in main chat and a option in it..for the file to be viewed by you only or by all others in main chat ...

waiting for your reply .

Dessamator

-- rules by jiten

sConf = {
	sBot = frmHub:GetHubBotName(),
	sFile1 = "file1.txt",
	ShowAll = true -- true/false to show all
}

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 = 	{
			["regras"] = 	function(user,data)
						if sConf.ShowAll then
							SendToAll(sConf.sBot,ReadFile(sConf.sFile1))
						else
							user:SendData(sConf.sBot,ReadFile(sConf.sFile1))
						end
					end,
		}
		if tCmds[cmd] then 
			tCmds[cmd](user,data)
		end
	end
end

function ReadFile(file)
	local fFile = io.open(file)
	if fFile then
		local message = ""
		for line in io.lines(file) do
			message = message..line.."\n"
		end
		fFile:close()
		return message
	else
		return file.." not found!"
	end
end


Done !
Ignorance is Bliss.

jiten

Something like this? Have a look at Rotating Message. It may be more useful for you.
-- rules by jiten
-- Added option to send .txt to Main/PM/All

sConf = {
	sBot = frmHub:GetHubBotName(),
	sFile1 = "file1.txt",
	sView = 0 -- 0: Rules in PM; 1: Rules in Main; 2: Rules sent to everyone
}

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 = 	{
			["regras"] = 	function(user,data)
						if sConf.sView == 0 then
							user:SendPM(sConf.sBot,ReadFile(sConf.sFile1))
						elseif sConf.sView == 1 then
							user:SendData(sConf.sBot,ReadFile(sConf.sFile1))
						else
							SendToAll(sConf.sBot,ReadFile(sConf.sFile1))
						end
					end,
		}
		if tCmds[cmd] then return tCmds[cmd](user,data)	end
	end
end

function ReadFile(file)
	local fFile = io.open(file)
	if fFile then
		local message = ""
		for line in io.lines(file) do
			message = message..line.."\n"
		end
		fFile:close()
		return message
	else
		return file.." not found!"
	end
end
Cheers

SMF spam blocked by CleanTalk