Immune 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

Immune script

Started by Guibs, 06 December, 2003, 04:18:45

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Guibs

Hi there,,

A script to make users immuned by their nick,,

-------
-- Immune script
-- !immune  < to add a user immuned
-- !delimmune  < to delete a user immuned
-- ?immune < show the current users immuned


function Main()
	Bot = "YourBot"
	ImmunesTotal = 0
	ImmunesList = {}
	ReadImmunes()
end

function ReadImmunes()
	readfrom("Immune.lst")
	while 1 do 
		local line = read() 
		if line == nil then
			break 
		else 
			ImmunesTotal = ImmunesTotal + 1
			rawset(ImmunesList,ImmunesTotal,line)
		end 
	end 
	readfrom() 
end

function WriteImmunes()
	writeto("Immune.lst") 
	for i=1,ImmunesTotal,1 do
		write(rawget(ImmunesList,i).."\n") 
	end
	writeto() 
end 

function DeleteImmunes(opNick)
	errlvl = 1
	for i=1,ImmunesTotal,1 do
		if rawget(ImmunesList,i) == opNick then
			if i ~= ImmunesTotal then
				rawset(ImmunesList,i,rawget(ImmunesList,ImmunesTotal))
			end
			ImmunesTotal = ImmunesTotal - 1
			SortImmunes()
			WriteImmunes()
			errlvl = 0
			break
		end
	end
	-- returns 1 if Immune could not be found
	return errlvl
end

function AddImmunes(opNick)
	errlvl = CheckUserNickImmune(opNick)
	if errlvl == 0 then
		ImmunesTotal = ImmunesTotal + 1
		rawset(ImmunesList,ImmunesTotal,opNick)
		SortImmunes()
		WriteImmunes()
	end
	-- returns 1 if Immune already exists
	return errlvl
end

function SortImmunes()
	for passNum=1,ImmunesTotal-1,1 do
		for i=1,ImmunesTotal-passNum,1 do
			if rawget(ImmunesList,i) > rawget(ImmunesList,i+1) then
				tempNick = rawget(ImmunesList,i)
				rawset(ImmunesList,i,rawget(ImmunesList,i+1))
				rawset(ImmunesList,i+1,tempNick)
			end
		end
	end
end

function ShowImmunes(user)
	nickimmune = 0
	nickimmunelist = ""
	for i=1,ImmunesTotal,1 do
		nickimmunelist = nickimmunelist..rawget(ImmunesList,i).."\r\n"
		nickimmune = nickimmune+1
	end
	if nickimmune > 0 then
		nickfound = "***Current users Immuned by their Nick are listed as:\r\n"..nickimmunelist
	else
		nickfound = "***None users immuned by their Nick found."
	end

	user:SendData(Bot,"\r\n"..nickfound)
end


function DoAddImmunes(user, data)
	arg = GetArgML(data)
	if arg ~= nil then
		if AddImmunes(arg) == 1 then
			user:SendData(Bot,"User "..arg.." is already Immune!")
		else
			SendToOps(Bot, user.sName.." just made "..arg.." a Immune!")
			user:SendData(Bot,"You just made "..arg.." a Immune!")
			SendToNick(arg, "<"..Bot.."> "..user.sName.." just made you a Immune!")
		end
	else
		user:SendData(Bot, "You provided insufficient information for me to run the specified command.")
	end
end

function DoDeleteImmunes(user, data)
	arg = GetArgML(data)
	if arg ~= nil then
		if DeleteImmunes(arg) == 1 then
			user:SendData(Bot,"User "..arg.." was not found in the current Immune list!")
		else
			SendToOps(Bot, user.sName.." just revoked Immune status from: "..arg)
			user:SendData(Bot,"You just revoked Immune status from: "..arg)
			SendToNick(arg, "<"..Bot.."> "..user.sName.." just revoked your Immune status.")
		end
	else
		user:SendData(Bot, "You provided insufficient information for me to run the specified command.")
	end
end

function CheckNickImmune(user)
	found = 0
	for i=1,ImmunesTotal,1 do
		if rawget(ImmunesList,i) == user.sName then
			found = 1
			break
		end
	end
	-- returns 1 if user specified is Immuned
	return found
end

function CheckUserNickImmune(opNick)
	errlvl = 0
	for i=1,ImmunesTotal,1 do
		if rawget(ImmunesList,i) == opNick then
			errlvl = 1
			break
		end
	end
	-- returns 1 if user specified is Immuned
	return errlvl
end

function GetArgML(data)
	s,e,cmd,arg = strfind(data, "%b<>%s+(%S+)%s+(%S+)%s*")
	return arg
end

function DataArrival(user,data)
	if (strsub(data,1,1)=="<") or (strsub(data,1,4)=="$To:") then
		data=strsub(data,1,strlen(data)-1)
		s,e,cmd = strfind(data,"%b<>%s+(%S+)")

		if (cmd=="!addimmune" or cmd == "!immune") then
			if user.bOperator then
				DoAddImmunes(user,data)
				return 1
			end

		elseif (cmd=="!deleteimmune" or cmd == "!delimmune") then
			if user.bOperator then
				DoDeleteImmunes(user,data)
				return 1
			end
		elseif (cmd=="!showimmune" or cmd == "?immune") then
			if user.bOperator then
				ShowImmunes(user)
				return 1
			end
		end
	end
end

function OpConnected(user)
	immune=CheckNickImmune(user)
	if immune == 1 then
		user:SendData(Bot, "Welcom there, lucky guy,... ;o)")
	else
		-- Do Your Code There
	end
end

function NewUserConnected(user)
	immune=CheckNickImmune(user)
	if immune == 1 then
		user:SendData(Bot, "Welcom there, lucky guy,... ;o)")
	else
		-- Do Your Code There
	end
end
-------

l8tr, ;)
-- Please,... don\'t ask help in Pm,...Forums are made for that, to help everyone & my Inbox pm will be safe,... Thks,,  :))  --
CB forum     /     CB Home page

Guibs

Hi?,,

Updated, about some immune functions on Ips,, :)

That one is not tested,,... so,, to test... :))

Hub owner can enter >manually< some Ips in the file 'IpImmune.lst',... then, those Ips should be immuned on a '!banip',...

-----
-- Immune-example script v1.1, By Guibs
-- Added Ip immune list (IpImmune.lst) to show an other example about immune functions on Ip
-- !immune  < to add a user immuned
-- !delimmune  < to delete a user immuned
-- ?immune < show the current users immuned
-- This is just an example about the way to make some users immuned


function Main()
	Bot = "YourBot"
	ImmunesTotal = 0
	ImmunesList = {}
	IpImmunesTotal = 0
	IpImmunesList = {}
	ReadImmunes()
	ReadIpImmunes()
end

function ReadImmunes()
	readfrom("Immune.lst")
	while 1 do 
		local line = read() 
		if line == nil then
			break 
		else 
			ImmunesTotal = ImmunesTotal + 1
			rawset(ImmunesList,ImmunesTotal,line)
		end 
	end 
	readfrom() 
end

function ReadIpImmunes()
	readfrom("IpImmune.lst")
	while 1 do 
		local line = read() 
		if line == nil then
			break 
		else 
			IpImmunesTotal = IpImmunesTotal + 1
			rawset(IpImmunesList,IpImmunesTotal,line)
		end 
	end 
	readfrom() 
end

function WriteImmunes()
	writeto("Immune.lst") 
	for i=1,ImmunesTotal,1 do
		write(rawget(ImmunesList,i).."\n") 
	end
	writeto() 
end 

function DeleteImmunes(opNick)
	errlvl = 1
	for i=1,ImmunesTotal,1 do
		if rawget(ImmunesList,i) == opNick then
			if i ~= ImmunesTotal then
				rawset(ImmunesList,i,rawget(ImmunesList,ImmunesTotal))
			end
			ImmunesTotal = ImmunesTotal - 1
			SortImmunes()
			WriteImmunes()
			errlvl = 0
			break
		end
	end
	-- returns 1 if Immune could not be found
	return errlvl
end

function AddImmunes(opNick)
	errlvl = CheckUserNickImmune(opNick)
	if errlvl == 0 then
		ImmunesTotal = ImmunesTotal + 1
		rawset(ImmunesList,ImmunesTotal,opNick)
		SortImmunes()
		WriteImmunes()
	end
	-- returns 1 if Immune already exists
	return errlvl
end

function SortImmunes()
	for passNum=1,ImmunesTotal-1,1 do
		for i=1,ImmunesTotal-passNum,1 do
			if rawget(ImmunesList,i) > rawget(ImmunesList,i+1) then
				tempNick = rawget(ImmunesList,i)
				rawset(ImmunesList,i,rawget(ImmunesList,i+1))
				rawset(ImmunesList,i+1,tempNick)
			end
		end
	end
end

function ShowImmunes(user)
	nickimmune = 0
	nickimmunelist = ""
	for i=1,ImmunesTotal,1 do
		nickimmunelist = nickimmunelist..rawget(ImmunesList,i).."\r\n"
		nickimmune = nickimmune+1
	end
	if nickimmune > 0 then
		nickfound = "***Current users Immuned by their Nick are listed as:\r\n"..nickimmunelist
	else
		nickfound = "***None users immuned by their Nick found."
	end

	user:SendData(Bot,"\r\n"..nickfound)
end


function DoAddImmunes(user, data)
	arg = GetArgML(data)
	if arg ~= nil then
		if AddImmunes(arg) == 1 then
			user:SendData(Bot,"User "..arg.." is already Immune!")
		else
			SendToOps(Bot, user.sName.." just made "..arg.." a Immune!")
			user:SendData(Bot,"You just made "..arg.." a Immune!")
			SendToNick(arg, "<"..Bot.."> "..user.sName.." just made you a Immune!")
		end
	else
		user:SendData(Bot, "You provided insufficient information for me to run the specified command.")
	end
end

function DoDeleteImmunes(user, data)
	arg = GetArgML(data)
	if arg ~= nil then
		if DeleteImmunes(arg) == 1 then
			user:SendData(Bot,"User "..arg.." was not found in the current Immune list!")
		else
			SendToOps(Bot, user.sName.." just revoked Immune status from: "..arg)
			user:SendData(Bot,"You just revoked Immune status from: "..arg)
			SendToNick(arg, "<"..Bot.."> "..user.sName.." just revoked your Immune status.")
		end
	else
		user:SendData(Bot, "You provided insufficient information for me to run the specified command.")
	end
end

function CheckNickImmune(user)
	found = 0
	for i=1,ImmunesTotal,1 do
		if rawget(ImmunesList,i) == user.sName then
			found = 1
			break
		end
	end
	-- returns 1 if user specified is Immuned
	return found
end

function CheckUserNickImmune(opNick)
	errlvl = 0
	for i=1,ImmunesTotal,1 do
		if rawget(ImmunesList,i) == opNick then
			errlvl = 1
			break
		end
	end
	-- returns 1 if user specified is Immuned
	return errlvl
end

function GetArgML(data)
	s,e,cmd,arg = strfind(data, "%b<>%s+(%S+)%s+(%S+)%s*")
	return arg
end

function GetLongArgML(data)
	s,e,cmd,arg = strfind(data, "%b<>%s+(%S+)%s+(.+)*")
	return arg
end

function DataArrival(user,data)
	if (strsub(data,1,1)=="<") or (strsub(data,1,4)=="$To:") then
		data=strsub(data,1,strlen(data)-1)
		s,e,cmd = strfind(data,"%b<>%s+(%S+)")

		if (cmd=="!addimmune" or cmd == "!immune") then
			if user.bOperator then
				DoAddImmunes(user,data)
				return 1
			end

		elseif (cmd=="!deleteimmune" or cmd == "!delimmune") then
			if user.bOperator then
				DoDeleteImmunes(user,data)
				return 1
			end
		elseif (cmd=="!showimmune" or cmd == "?immune") then
			if user.bOperator then
				ShowImmunes(user)
				return 1
			end

		elseif (cmd=="!banip") then
			if user.bOperator then
				BanIp(user,data)
			end
		end
	end
end

function OpConnected(user)
	immune=CheckNickImmune(user)
	if immune == 1 then
		user:SendData(Bot, "Welcom there, lucky guy,... ;o)")
	else
		-- Do Your Code There
	end
end

function NewUserConnected(user)
	immune=CheckNickImmune(user)
	if immune == 1 then
		user:SendData(Bot, "Welcom there, lucky guy,... ;o)")
	else
		-- Do Your Code There
	end
end

function BanIp(user,data)
	arg = GetLongArgML(data)
	if arg ~= nil then
		ipimmune = CheckIpImmunes(arg)
		if ipimmune == 1 then
			SendToOps(Bot, user.sName.." has tried to ban "..arg.." as it was an Ip immuned,... Bo0h!!")
			user:SendData(Bot,"You can't do a BanIp on such Ip!")
			return 1
		else
		end
	else
		user:SendData(Bot, "You provided insufficient information for me to run the specified command.")
	end
end

function CheckIpImmunes(arg)
	ipimmune = 0
	for a,b, in IpImmunesList do
		if arg == b then
			ipimmune == 1
		end
	end
	return ipimmune
end
-----
Hoping it works,,

Good test & script with this example,, :)

l8tr,, ;o)
-- Please,... don\'t ask help in Pm,...Forums are made for that, to help everyone & my Inbox pm will be safe,... Thks,,  :))  --
CB forum     /     CB Home page

pHaTTy

excellent when i lost all my scripts in hdd failure, i never did find that one :))

ty guibs nearly re-done my collection wooo loool :))
Resistance is futile!

[NL]trucker

guibs

thanks alot was waiting fo this one. ';))


now one request left

can you make it so that it also logs the one who trys to kick the users in immunelist?

and as far as i understand if i want to make a command not  to work i need to put [--] infront of that line? right?


will test this script as soon as i got my comp back online
had a crash last thursday and i couldnt fix the prob so i had to bring it to the shop (:- but hopefully it will be back on monday.

then i will test it.
Owner of FunnyHub
 
Funyhub.no-ip.info
       Forum Master of


Snoris

syntax error `in* expected;
 last token read `; at line 261 in string "--immune-example script v1.1 By Guibs


-what does it mean??

Guibs

Hi there,,

Phatty,
pleasure to help, m8,, ;o)
Catch u soon on checkers,,... when you learn a few more about,... ^^

[NL]trucker,,
yw too,, ;)
> can you make it so that it also logs the one who trys to kick the users in immunelist?  < if i get it & if you want,, a message could be send to the ops on a 'bad kick', yep, .. tell me if i get your request,... :)

Snooris,
Be sure to take & use the code after the line:
----
 > code: <
----
I get none syntax error on a simple restart script there,...

l8tr,, ;)
-- Please,... don\'t ask help in Pm,...Forums are made for that, to help everyone & my Inbox pm will be safe,... Thks,,  :))  --
CB forum     /     CB Home page

pHaTTy

hmm sorry guibs you just aint good enuff :P beat ya in that one ;)
Resistance is futile!

Guibs

erf,... easy,.... you give up on the revenge,... ;)
-- Please,... don\'t ask help in Pm,...Forums are made for that, to help everyone & my Inbox pm will be safe,... Thks,,  :))  --
CB forum     /     CB Home page

pHaTTy

loooooooool whatevr :P
Resistance is futile!

[NL]trucker

#9
Guibs

> can you make it so that it also logs the one who trys to kick the users in immunelist?

< if i get it & if you want,, a message could be send to the ops on a 'bad kick', yep, .. tell me if i get your request,... :)


almost m8 i just want it to LOG the one who tried to kick a immune user.
No need for messages send to the OPs

btw

do i need to make the log-files or are they made automatticly?
and if so where are they placed?
Owner of FunnyHub
 
Funyhub.no-ip.info
       Forum Master of


[NL]trucker

sorry m8  ;(


i have a problem/bug

in this section function CheckIpImmunes(arg)
   ipimmune = 0
   for a,b, in IpImmunesList do
      if arg == b then
         ipimmune == 1
      end
   end
   return ipimmune

Syntax error: `in' expected;
  last token read: `,' at line 243 in file `E:\==DC==\ptotaxbuild15.16\scripts\immune.lua'

dont know what is wrong (:-
Owner of FunnyHub
 
Funyhub.no-ip.info
       Forum Master of


plop

for a,b, in IpImmunesList do
after a,b  is an , 2 much.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Snoris

QuoteOriginally posted by plop
for a,b, in IpImmunesList do
after a,b  is an , 2 much.

plop

noticed that to after a while :]

[NL]trucker

another one

i have removed the second , now i get this:

Syntax error: `=' expected;
  last token read: `==' at line 245 in file `E:\==DC==\ptotaxbuild15.16\scripts\immune.lua'



in this section function CheckIpImmunes(arg)
ipimmune = 0
for a,b  in IpImmunesList do
if arg == b then
ipimmune == 1     <--line 245
end
end
return ipimmune
Owner of FunnyHub
 
Funyhub.no-ip.info
       Forum Master of


plop

QuoteOriginally posted by [NL]trucker
another one

i have removed the second , now i get this:

Syntax error: `=' expected;
  last token read: `==' at line 245 in file `E:\==DC==\ptotaxbuild15.16\scripts\immune.lua'



in this section function CheckIpImmunes(arg)
ipimmune = 0
for a,b  in IpImmunesList do
if arg == b then
ipimmune == 1     <--line 245
end
end
return ipimmune
it expects 1 = not 2.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

[NL]trucker

Thnx m8

that did it :-))

working fine now Guibs thanks alot to all off you .
Owner of FunnyHub
 
Funyhub.no-ip.info
       Forum Master of


Ricky12

I installed the script and I get this....
Syntax Error: `in' expected;
  last token read: `,' at line 244 in string "
..."

the script looks like this at the moment...
function CheckIpImmunes(arg)
   ipimmune = 0
   for a,b, in IpImmunesList do
      if arg == b then
         ipimmune == 1
      end
   end
   return ipimmune
end

I read the other replies and I dont under stand what to do. I tried to fix it and it still gave the the same problem. PLease any help would be nice. :rolleyes:
===========H=U=B==I=N=F=O=============
?Hub Owner:     Ricky12
?Hub Name:      >>>??Ricky12\'s T?@M?T??? Hub??<<<
?Hub Address:   Ricky12.no-ip.info or Ricky12.dyndns.org
?Web Address:  http://teamsters.no-ip.com/tmsts/index.php
=====================================

plop

QuoteOriginally posted by Ricky12
I installed the script and I get this....
Syntax Error: `in' expected;
  last token read: `,' at line 244 in string "
..."

the script looks like this at the moment...
function CheckIpImmunes(arg)
   ipimmune = 0
   for a,b, in IpImmunesList do
      if arg == b then
         ipimmune == 1
      end
   end
   return ipimmune
end

I read the other replies and I dont under stand what to do. I tried to fix it and it still gave the the same problem. PLease any help would be nice. :rolleyes:
check back and change the next marked lines.

function CheckIpImmunes(arg)
   ipimmune = 0
   for a,b, in IpImmunesList do   <-------------- remove the , after the b
      if arg == b then
         ipimmune == 1  <----------------- remove 1 =
      end
   end
   return ipimmune
end

thats all.

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

Ricky12

Thanks it works now!!! Keep up the good work!!  :] And I look foward to downloading more scripts. ;)
===========H=U=B==I=N=F=O=============
?Hub Owner:     Ricky12
?Hub Name:      >>>??Ricky12\'s T?@M?T??? Hub??<<<
?Hub Address:   Ricky12.no-ip.info or Ricky12.dyndns.org
?Web Address:  http://teamsters.no-ip.com/tmsts/index.php
=====================================

Devastator

Syntax Error: `then' expected;
  last token read: `=' at line 230

thats an error i get and sadly i dnt understand it.....i think ma new years resolution is 2 learn LUA *-) :-p

plz sum1 help me with that cos i've stared at it 4 ages but still i'm useless.

Thanx

Devastator
(? ?.??.->PLOP DEFINATELY 4 MOD!!!<-.??.???)


[NL]trucker

devastator

 look in the posts above and then post your question like we all did maybey then we can help ya.

so post the piece where it is all about.

QuoteSyntax error: `=' expected;
last token read: `==' at line 245 in file `E:\==DC==\ptotaxbuild15.16\scripts\immune.lua'



in this section function CheckIpImmunes(arg)
ipimmune = 0
for a,b in IpImmunesList do
if arg == b then
ipimmune == 1 <--line 245
end
end
return ipimmune

something like this.
Owner of FunnyHub
 
Funyhub.no-ip.info
       Forum Master of


enema

Only thing - I still can kick immune users.. Can someone fix this little bug in this script??

enema

Please, someone help me! My problem is, that I want to make some users immune from kicks, but I dont want them give any special profile! If you cant edit this one, then please give me something better! Please!

SMF spam blocked by CleanTalk