Implant some strings
 

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

Implant some strings

Started by Smulf, 27 July, 2004, 21:18:49

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Smulf

Wazup guess

Is it posible to write a string that would do so you are not only banned after 3 kicks, but also the "!drop" command. So that when the OPs kicks or drops the user 3 times he will get banned. Here is the script thats in use:

--Ban-4X-Kick 1.0
--
--Auto bans a user on 'x' times kicked.    [+1]     :)
--
-- Provides option for:
--	- Report to Admin, Ops or Main
-- 	- Set number of kicks before ban
-- 	- send user website/forum message
--	- loads/saves kicks to external files
-- 	  files(s) when hub/scripts restart
--
-- Local Ops now exempt
--
--User Settings-------------------------------------------------------------------------------------

--Number of time a user may be kicked, user will be banned at next login.
kickcount = 1
--Send report to main chat
Snd2All = "0"
--Send pm report to ops
Snd2Ops = "1"	-- 1 = on / 0 = off
--Send pm report Admin's Nick
Snd2Admin = "0"
--Admin's Nick or any other single nick
AdminName = "Mutor"
--Name for bot [You can use your main bot, if so no need to register this bot. See 'function main'.
Bot = "OP_Ban"

--End User Settings----------------------------------------------------------------------------------

--
Kicked = {}
KickFile = "OP_Ban\kicks.txt"

function Main() 
--frmHub:RegBot(Bot)	--If using main bot, remark this line, add -- ie.. --frmHub:RegBot(Bot)
frmHub:EnableFullData(1)
LoadFromFile(KickFile)
end

function NewUserConnected(user, data)
	if Kicked[user.sName]==kickcount then Kicked[user.sName]=nil
	local Report2
	Report2 = "\r\n\r\n\t---<>-------------------------------------------------------<>---    \r\n"  
	Report2 = Report2.."\tThe user "..user.sName.." has been kicked [ "..kickcount.." ] times.\r\n"
	Report2 = Report2.."\t"..user.sName.." attempted login and has been banned.               \r\n" 
	Report2 = Report2.."\t---<>-------------------------------------------------------<>---   \r\n"
			if Snd2Admin == "1" then
				SendPmToNick(AdminName,Bot,Report2)
				end
			if Snd2Ops == "1" then
				SendPmToOps(Bot,Report2) 
				end
			if Snd2All == "1" then
				SendToAll(Bot,Report2)
				end
	local BanMsg
	BanMsg = "\r\n\r\n\t---<>----------------------------------------------------------------<>---\r\n"  
	BanMsg = BanMsg.."\tYou had been kicked [ "..kickcount.." ] times, now your banned.           \r\n"
	BanMsg = BanMsg.."\tIf you disagree with your ban. Visit our forum at :                   \r\n\r\n" 
	BanMsg = BanMsg.."\t\thttp://hubforum.no-ip.com                                               \r\n" 
	BanMsg = BanMsg.."\t---<>----------------------------------------------------------------<>---\r\n"
	user:SendData(Bot, BanMsg)
	user:SendPM(Bot, BanMsg)
	user:Ban()
	end
end

function DataArrival(user, data)
data=strsub(data,1,-2)
_,_,cmd,unick = strfind( data, "(%S+)%s+(%S+)" )
	if cmd == "$Kick" and user.bOperator then
			if Kicked[unick]==nil then Kicked[unick]=1
			elseif Kicked[unick]~= nil then Kicked[unick] = Kicked[unick]+1
				if Kicked[unick]== kickcount then
	local Report1
	Report1 = "\r\n\r\n\t---<>-------------------------------------------------------<>---\r\n"  
	Report1 = Report1.."\tThe user "..unick.." has been kicked [ "..kickcount.." ] times.\r\n"
	Report1 = Report1.."\t"..unick.." will be banned at next login to this hub.\r\n" 
	Report1 = Report1.."\t---<>-------------------------------------------------------<>---\r\n"
			if Snd2Admin == "1" then
				SendPmToNick(AdminName,Bot,Report2)
				end
			if Snd2Ops == "1" then
				SendPmToOps(Bot,Report2) 
				end
			if Snd2All == "1" then
				SendToAll(Bot,Report2)
				end

			end	
			end						
	end	
end


function OnExit()
	SaveToFile(KickFile , Kicked , "Kicked")
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


Thanks for your time...!
[Smulf]

Troubadour

you could change this line

   if cmd == "$Kick" and user.bOperator then

to

   if cmd == "$Kick" or cmd == "$Drop" and user.bOperator then

so with both commands it will do the same counting.
Regards,

Troubadour

** Guardian Forum **

hubaddy:   nederfun.no-ip.com

nErBoS

Hi,

"$Drop" ??? Dc client don't have this string sent, i suposse that !drop is an in script command or potkax comand, can you tell us ?? And also tell us the phrase sent by the bot when some one is droped.

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

NightLitch

This should maybe work:

_,_,cmd,unick = strfind( data, "%!*(%S+)%s+(%S+)" )
	if cmd == "$Kick" or cmd=="drop" and user.bOperator then

/NL
//NL

nErBoS

Hi,

Other note to take the script must be first in the list of the scripts then the script that have the !drop command because of the return 1

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

Smulf

QuoteHi,

"$Drop" ??? Dc client don't have this string sent, i suposse that !drop is an in script command or potkax comand, can you tell us ?? And also tell us the phrase sent by the bot when some one is droped.

Best regards, nErBoS

I think it's an Potkax command.

QuoteMethods:
SendData(data)
SendPM(from, data)
Disconnect()
Ban()
NickBan()
TempBan()
TimeBan(time)

Am I missing any?

!drop is just curUser:Disconnect()

Anyway I made this script at request for the kick but
you can use this script for any string

Adjust function:

DataArrival(user, data)

to suit your needs.

Thx Mutor, you'v solt my other problem with the "TempBan()" method:)


Thx to Troubadour and NightLitch for the tip, but it makes a - "Syntax Error: table index is nil" - and I have changed what you'v told me:

--Ban-4X-Kick 1.0
--
--Auto bans a user on 'x' times kicked.    [+1]     :)
--
-- Provides option for:
--	- Report to Admin, Ops or Main
-- 	- Set number of kicks before ban
-- 	- send user website/forum message
--	- loads/saves kicks to external files
-- 	  files(s) when hub/scripts restart
--
-- Local Ops now exempt
--
--User Settings-------------------------------------------------------------------------------------

--Number of time a user may be kicked, user will be banned at next login.
kickcount = 1
--Send report to main chat
Snd2All = "0"
--Send pm report to ops
Snd2Ops = "1"	-- 1 = on / 0 = off
--Send pm report Admin's Nick
Snd2Admin = "0"
--Admin's Nick or any other single nick
AdminName = "Mutor"
--Name for bot [You can use your main bot, if so no need to register this bot. See 'function main'.
Bot = "OP_Ban"

--End User Settings----------------------------------------------------------------------------------

--
Kicked = {}
KickFile = "OP_Ban\kicks.txt"

function Main() 
--frmHub:RegBot(Bot)	--If using main bot, remark this line, add -- ie.. --frmHub:RegBot(Bot)
frmHub:EnableFullData(1)
LoadFromFile(KickFile)
end

function NewUserConnected(user, data)
	if Kicked[user.sName]==kickcount then Kicked[user.sName]=nil
	local Report2
	Report2 = "\r\n\r\n\t---<>-------------------------------------------------------<>---    \r\n"  
	Report2 = Report2.."\tThe user "..user.sName.." has been kicked [ "..kickcount.." ] times.\r\n"
	Report2 = Report2.."\t"..user.sName.." attempted login and has been banned.               \r\n" 
	Report2 = Report2.."\t---<>-------------------------------------------------------<>---   \r\n"
			if Snd2Admin == "1" then
				SendPmToNick(AdminName,Bot,Report2)
				end
			if Snd2Ops == "1" then
				SendPmToOps(Bot,Report2) 
				end
			if Snd2All == "1" then
				SendToAll(Bot,Report2)
				end
	local BanMsg
	BanMsg = "\r\n\r\n\t---<>----------------------------------------------------------------<>---\r\n"  
	BanMsg = BanMsg.."\tYou had been kicked [ "..kickcount.." ] times, now your banned.           \r\n"
	BanMsg = BanMsg.."\tIf you disagree with your ban. Visit our forum at :                   \r\n\r\n" 
	BanMsg = BanMsg.."\t\thttp://hubforum.no-ip.com                                               \r\n" 
	BanMsg = BanMsg.."\t---<>----------------------------------------------------------------<>---\r\n"
	user:SendData(Bot, BanMsg)
	user:SendPM(Bot, BanMsg)
	user:Ban()
	end
end

function DataArrival(user, data)
data=strsub(data,1,-2)
_,_,cmd,unick = strfind( data, "%!*(%S+)%s+(%S+)" )
			if cmd == "$Kick" or cmd == "$Drop" and user.bOperator then 
			if Kicked[unick]==nil then Kicked[unick]=1
			elseif Kicked[unick]~= nil then Kicked[unick] = Kicked[unick]+1
				if Kicked[unick]== kickcount then
	local Report1
	Report1 = "\r\n\r\n\t---<>-------------------------------------------------------<>---\r\n"  
	Report1 = Report1.."\tThe user "..unick.." has been kicked [ "..kickcount.." ] times.\r\n"
	Report1 = Report1.."\t"..unick.." will be banned at next login to this hub.\r\n" 
	Report1 = Report1.."\t---<>-------------------------------------------------------<>---\r\n"
			if Snd2Admin == "1" then
				SendPmToNick(AdminName,Bot,Report2)
				end
			if Snd2Ops == "1" then
				SendPmToOps(Bot,Report2) 
				end
			if Snd2All == "1" then
				SendToAll(Bot,Report2)
				end

			end	
			end						
	end	
end


function OnExit()
	SaveToFile(KickFile , Kicked , "Kicked")
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
[Smulf]

NightLitch

change:

if cmd == "$Kick" or cmd == "$Drop" and user.bOperator then

to

if cmd == "$Kick" or cmd == "drop" and user.bOperator then

the drop is a command not a $Syntax/Cmd.

/NL
//NL

SMF spam blocked by CleanTalk