One help
 

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

One help

Started by (!(Tys?kan)=), 20 April, 2004, 14:44:58

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

(!(Tys?kan)=)

Hi, that's my idea:
When user connecting to hub in first time, the bot showing the help file with description to the newbie...then his nickname is writing to the file
On next joing to the hub, the scrip reading file and search his nickname and don't showing anything...


--Ty--
--Ty--

nErBoS

Hi,

Hope it helps...

--Requested by (!(Tys?kan)=)
--Made by nErboS

sBot = "NewUser-HELPER"

helptxt = "help.txt"	--This file must be created in the script folder
usertxt = "user.txt"	--this file will be created in script folder
sHelp = ""

nonnew = {}

function Main()
	frmHub:RegBot(sBot)
end

function OnExit()
	SaveToFile(usertxt , nonnew , "nonnew")
end

function NewUserConnected(user, data)
	if (CheckUser(user) == 0) then
		if (readfrom(helptxt) ~= nil) then
			if (sHelp == "") then
				ReadText(user)
			else
				user:SendPM(sBot, sHelp)
			end
		end
	end
end

function CheckUser(user)
	local pos = 0
	local accept = 0
	if (nonnew[1] == nil) then
		LoadFromFile(usertxt)
	end
	for i=1, getn(nonnew) do
		if (nonnew[i] == user.sName) then
			accept = 1
		end
		pos = i
	end
	if (accept == 0) then
		nonnew[pos+1] = user.sName
	end
return accept
end

function ReadText(user)
	readfrom(helptxt)
	while 1 do
		local line = read()
		if (line == nil) then
			break
		else
			sHelp = sHelp..line.."\r\n"
		end
	end
	readfrom()
	user:SendData(sBot, sHelp)
end

function Serialize(tTable, sTableName, sTab)
	assert(tTable, "tTable equals nil");
	assert(sTableName, "sTableName equals nil");

	assert(type(tTable) == "table", "tTable must be a table!");
	assert(type(sTableName) == "string", "sTableName must be a string!");

	sTab = sTab or "";
	sTmp = ""

	sTmp = sTmp..sTab..sTableName.." = {\n"

	for key, value in tTable do
		local sKey = (type(key) == "string") and format("[%q]",key) or format("[%d]",key);

		if(type(value) == "table") then
			Serialize(value, sKey, sTab.."\t");
		else
			local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
			sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
		end

		sTmp = sTmp..",\n"
	end

	sTmp = sTmp..sTab.."}"
	return sTmp
end

function SaveToFile(file , table , tablename)
	writeto(file)
	write(Serialize(table, tablename))
	writeto()
end

function LoadFromFile(file)
	if (readfrom(file) ~= nil) then
		readfrom(file)
		dostring(read("*all"))
		readfrom()
	end
end

Best regards, nErBoS
--## nErBoS Spot ##--

(!(Tys?kan)=)

Don't working...Don't saving nick's to file and don't writing errors...Just 0b file...
--Ty--

nErBoS

Hi,

Same problem as the other, going to see that.

Best regards, nErBoS
--## nErBoS Spot ##--

nErBoS

Hi,

Smae bug as the other, try this..

--Requested by (!(Tys?kan)=)
--Made by nErboS

sBot = "NewUser-HELPER"

helptxt = "help.txt"	--This file must be created in the script folder
usertxt = "user.txt"	--this file will be created in script folder
sHelp = ""

nonnew = {}

function Main()
	frmHub:RegBot(sBot)
end

function OnExit()
	if (nonnew == nil and reafrom(usertxt) ~= nil) then
		LoadFromFile(usertxt)
	end
	SaveToFile(usertxt , nonnew , "nonnew")
end

function NewUserConnected(user, data)
	if (CheckUser(user) == 0) then
		if (readfrom(helptxt) ~= nil) then
			if (sHelp == "") then
				ReadText(user)
			else
				user:SendPM(sBot, sHelp)
			end
		end
	end
end

function CheckUser(user)
	local pos = 0
	local accept = 0
	if (nonnew[1] == nil) then
		LoadFromFile(usertxt)
	end
	for i=1, getn(nonnew) do
		if (nonnew[i] == user.sName) then
			accept = 1
		end
		pos = i
	end
	if (accept == 0) then
		nonnew[pos+1] = user.sName
	end
return accept
end

function ReadText(user)
	readfrom(helptxt)
	while 1 do
		local line = read()
		if (line == nil) then
			break
		else
			sHelp = sHelp..line.."\r\n"
		end
	end
	readfrom()
	user:SendData(sBot, sHelp)
end

function Serialize(tTable, sTableName, sTab)
	assert(tTable, "tTable equals nil");
	assert(sTableName, "sTableName equals nil");

	assert(type(tTable) == "table", "tTable must be a table!");
	assert(type(sTableName) == "string", "sTableName must be a string!");

	sTab = sTab or "";
	sTmp = ""

	sTmp = sTmp..sTab..sTableName.." = {\n"

	for key, value in tTable do
		local sKey = (type(key) == "string") and format("[%q]",key) or format("[%d]",key);

		if(type(value) == "table") then
			Serialize(value, sKey, sTab.."\t");
		else
			local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
			sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
		end

		sTmp = sTmp..",\n"
	end

	sTmp = sTmp..sTab.."}"
	return sTmp
end

function SaveToFile(file , table , tablename)
	writeto(file)
	write(Serialize(table, tablename))
	writeto()
end

function LoadFromFile(file)
	if (readfrom(file) ~= nil) then
		readfrom(file)
		dostring(read("*all"))
		readfrom()
	end
end

Best regards, nErBoS
--## nErBoS Spot ##--

tERBO

Hi
2nErBoS:
I have tasted this script on Ptocax 0.3.2.6 td4 and it still not saving nick's to file. After scripts restart user against receives help message :( With "(ip)::(nick)" same problem - don't saving nick's to file too...
Is this script works only with Ptocax 0.3.3.0? If it so - where we can get it? Its only for beta-testers...

2(!(Tys?kan)=):
Sorry, it is your topic, but i can't wait the answer more longer...

P.S. Excuse me for my bad English =)
__=(vshub)=__

(!(Tys?kan)=)

He there!
I'm have little modofications, and start up this script on PtorkaX 0.3.3.0, all working, greets!

2TerBo:
???, ????? ???-???? ???????????????????..

Sorry for non-english word's...
--Ty--

nErBoS

Hi,

Like i said this script will work 100% in ptokax 0.3.3.0, wait little more, because ptzacek is about to release a beta version to all.

Best regards, nErBoS
--## nErBoS Spot ##--

(!(Tys?kan)=)

#8
I'm already having 0.3.3.0 version of ptokax...But script don't working to ;( Don't saving user's to file, when i'm handly writing a table and do some text such:
nonnew = {
[1] = "(!(Tys?kan)=)"
}
On restarting this gone to
nonnew = {
}
When new user is joining the hub - help don't posting to him...
--Ty--

nErBoS

Hi,

Little Bug, try this one...

--Requested by (!(Tys?kan)=)
--Made by nErboS

sBot = "NewUser-HELPER"

helptxt = "help.txt"	--This file must be created in the script folder
usertxt = "user.txt"	--this file will be created in script folder
sHelp = ""

nonnew = {}

function Main()
	frmHub:RegBot(sBot)
end

function OnExit()
	if (nonnew[1] == nil and reafrom(usertxt) ~= nil) then
		LoadFromFile(usertxt)
	end
	SaveToFile(usertxt , nonnew , "nonnew")
end

function NewUserConnected(user, data)
	if (CheckUser(user) == 0) then
		if (readfrom(helptxt) ~= nil) then
			if (sHelp == "") then
				ReadText(user)
			else
				user:SendPM(sBot, sHelp)
			end
		end
	end
end

function CheckUser(user)
	local pos = 0
	local accept = 0
	if (nonnew[1] == nil) then
		LoadFromFile(usertxt)
	end
	for i=1, getn(nonnew) do
		if (nonnew[i] == user.sName) then
			accept = 1
		end
		pos = i
	end
	if (accept == 0) then
		nonnew[pos+1] = user.sName
	end
return accept
end

function ReadText(user)
	readfrom(helptxt)
	while 1 do
		local line = read()
		if (line == nil) then
			break
		else
			sHelp = sHelp..line.."\r\n"
		end
	end
	readfrom()
	user:SendData(sBot, sHelp)
end

function Serialize(tTable, sTableName, sTab)
	assert(tTable, "tTable equals nil");
	assert(sTableName, "sTableName equals nil");

	assert(type(tTable) == "table", "tTable must be a table!");
	assert(type(sTableName) == "string", "sTableName must be a string!");

	sTab = sTab or "";
	sTmp = ""

	sTmp = sTmp..sTab..sTableName.." = {\n"

	for key, value in tTable do
		local sKey = (type(key) == "string") and format("[%q]",key) or format("[%d]",key);

		if(type(value) == "table") then
			Serialize(value, sKey, sTab.."\t");
		else
			local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
			sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
		end

		sTmp = sTmp..",\n"
	end

	sTmp = sTmp..sTab.."}"
	return sTmp
end

function SaveToFile(file , table , tablename)
	writeto(file)
	write(Serialize(table, tablename))
	writeto()
end

function LoadFromFile(file)
	if (readfrom(file) ~= nil) then
		readfrom(file)
		dostring(read("*all"))
		readfrom()
	end
end

Best regards, nErBoS
--## nErBoS Spot ##--

(!(Tys?kan)=)

Hey, and in this moment script is don't working...build 15.25
--Ty--

nErBoS

#11
Hi,

Sorry a espeling mistake, fixed and tested...

--Requested by (!(Tys?kan)=)
--Made by nErboS

sBot = "NewUser-HELPER"

helptxt = "help.txt"	--This file must be created in the script folder
usertxt = "user.txt"	--this file will be created in script folder
sHelp = ""

nonnew = {}

function Main()
	frmHub:RegBot(sBot)
end

function OnExit()
	if (nonnew[1] == nil and readfrom(usertxt) ~= nil) then
		LoadFromFile(usertxt)
	end
	SaveToFile(usertxt , nonnew , "nonnew")
end

function NewUserConnected(user, data)
	if (CheckUser(user) == 0) then
		if (readfrom(helptxt) ~= nil) then
			if (sHelp == "") then
				ReadText(user)
			else
				user:SendPM(sBot, sHelp)
			end
		end
	end
end

OpConnected = NewUserConnected

function CheckUser(user)
	local pos = 0
	local accept = 0
	if (nonnew[1] == nil and readfrom(usertxt) ~= nil) then
		LoadFromFile(usertxt)
	end
	for i=1, getn(nonnew) do
		if (nonnew[i] == user.sName) then
			accept = 1
		end
		pos = i
	end
	if (accept == 0) then
		nonnew[pos+1] = user.sName
	end
return accept
end

function ReadText(user)
	readfrom(helptxt)
	while 1 do
		local line = read()
		if (line == nil) then
			break
		else
			sHelp = sHelp..line.."\r\n"
		end
	end
	readfrom()
	user:SendData(sBot, sHelp)
end

function Serialize(tTable, sTableName, sTab)
	assert(tTable, "tTable equals nil");
	assert(sTableName, "sTableName equals nil");

	assert(type(tTable) == "table", "tTable must be a table!");
	assert(type(sTableName) == "string", "sTableName must be a string!");

	sTab = sTab or "";
	sTmp = ""

	sTmp = sTmp..sTab..sTableName.." = {\n"

	for key, value in tTable do
		local sKey = (type(key) == "string") and format("[%q]",key) or format("[%d]",key);

		if(type(value) == "table") then
			Serialize(value, sKey, sTab.."\t");
		else
			local sValue = (type(value) == "string") and format("%q",value) or tostring(value);
			sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
		end

		sTmp = sTmp..",\n"
	end

	sTmp = sTmp..sTab.."}"
	return sTmp
end

function SaveToFile(file , table , tablename)
	writeto(file)
	write(Serialize(table, tablename))
	writeto()
end

function LoadFromFile(file)
	if (readfrom(file) ~= nil) then
		readfrom(file)
		dostring(read("*all"))
		readfrom()
	end
end

Best regards, nErBoS
--## nErBoS Spot ##--

(!(Tys?kan)=)

OK, this is working, thanks :D
--Ty--

SMF spam blocked by CleanTalk