-=Rule-Kicker=- by ((UKSN))shad_dow
 

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

-=Rule-Kicker=- by ((UKSN))shad_dow

Started by ((UKSN))shad_dow, 25 June, 2004, 20:53:26

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

((UKSN))shad_dow

heres my bots rulekicker ,now in stand alone bot ..
hope u like it :)

--// Rule-Kicker - taken from my Therapy-X? bot
--// created by ((UKSN))shad_dow


Bot = "-=Rule-Kicker=-"


--//- add ur rules in between " and " , if u say only got 6 rules , leave rule7 and rule8 (blank) as they are :)
rule1 = "Rule 1) NO PORN"
rule2 = "Rule 2) VOB-files (the large files which is on the DVD's)."
rule3 = " "
rule4 = " "
rule5 = " "
rule6 = " "
rule7 = " "
rule8 = " "
rule9 = " "
rule10 = " "


function Main()
frmHub:RegBot(Bot)
end

function DataArrival(user,data)

if (strsub(data,1,1)=="<") or (strsub(data,1,5+strlen(Bot))=="$To: "..Bot) then
		data=strsub(data,1,strlen(data)-1)
		s,e,cmd = strfind(data,"%b<>%s+(%S+)")

if (cmd == "+kick") and (user.bOperator)  then
dokick(user,data)
return 1
end
end


function dokick(user,data)

		local s,e,usr,unit = strfind(data,"%b<>%s+%S+%s+(%S+)%s+(.*)")	
			if usr == nil and unit == nil then
user:SendData(Bot,"Syntex is !kick [nick] [reason] ,reason is 1 = Rule 1 , 2 = Rule 2  , etc..!")
else
local userToKick = GetItemByName(usr)
				if unit == "1" then

						
						SendToAll(Bot, "User "..userToKick.sName.." was kicked by "..Bot.." because of "..rule1)
						userToKick:SendPM(Bot, "You have been kicked because: "..rule1)
						userToKick:TempBan()

														
				elseif unit == "2" then
						SendToAll(Bot, "User "..userToKick.sName.." was kicked by "..Bot.." because of "..rule2)
						userToKick:SendPM(Bot, "You have been kicked because: "..rule2)
						userToKick:TempBan()
				

				elseif unit == "3" then
						SendToAll(Bot, "User "..userToKick.sName.." was kicked by "..Bot.." because of "..rule3)
						userToKick:SendPM(Bot, "You have been kicked because: "..rule3)
						userToKick:TempBan()


				elseif unit == "4" then
						SendToAll(Bot, "User "..userToKick.sName.." was kicked by "..Bot.." because of "..rule4)
						userToKick:SendPM(Bot, "You have been kicked because: "..rule4)
						userToKick:TempBan()



				elseif unit == "5" then
						SendToAll(Bot, "User "..userToKick.sName.." was kicked by "..Bot.." because of "..rule5)
						userToKick:SendPM(Bot, "You have been kicked because: "..rule5)
						userToKick:TempBan()


				elseif unit == "6" then
						SendToAll(Bot, "User "..userToKick.sName.." was kicked by "..Bot.." because of "..rule6)
						userToKick:SendPM(Bot, "You have been kicked because: "..rule6)
						userToKick:TempBan()


				elseif unit == "7" then
						SendToAll(Bot, "User "..userToKick.sName.." was kicked by "..Bot.." because of "..rule7)
						userToKick:SendPM(Bot, "You have been kicked because: "..rule7)
						userToKick:TempBan()


				elseif unit == "8" then
						SendToAll(Bot, "User "..userToKick.sName.." was kicked by "..Bot.." because of "..rule8)
						userToKick:SendPM(Bot, "You have been kicked because: "..rule8)
						userToKick:TempBan()


				elseif unit == "9" then
						SendToAll(Bot, "User "..userToKick.sName.." was kicked by "..Bot.." because of "..rule9)
						userToKick:SendPM(Bot, "You have been kicked because: "..rule9)
						userToKick:TempBan()

				elseif unit == "10" then
						SendToAll(Bot, "User "..userToKick.sName.." was kicked by "..Bot.." because of "..rule10)
						userToKick:SendPM(Bot, "You have been kicked because: "..rule10)
						userToKick:TempBan()
					end
				
 
				end	
					
				end
			
			end
creator of Therapy-X? bot

tezlo

nice idea. just one thing though..
if at any point you end up with multiple ifs elseifs looking like
if x = "something" then y = 1
elseif x = "something else" then y = 2
elseif ..
the chances are that you can save yourself some time and space by using a table
and end up with more elegant code that also runs faster

rules = {
	"NO PORN",
	"NO VOBS",
}

function DataArrival(user, data)
	if strsub(data, 1, 1) == "<" and user.bOperator then
		local s, e, cmd, args = strfind(data, "^%b<> %!(%S+)%s*(.*)|$")
		if s then
			if cmd == "kick" then
				local s, e, nick, rule = strfind(args, "(%S+) (%d+)")
				if s then
					local victim = GetItemByName(nick)
					if not victim then
						user:SendData(">> "..nick.." is not online")
					else
						local tmp = rules[tonumber(rule)]
						if not tmp then
							user:SendData("invalid rule id "..rule)
						else
							victim:Kick(tmp)
						end
					end
				else
					user:SendData(">> syntax: !kick  ")
				end
			elseif cmd == "krules" then
				user:SendData(">> kick rules..")
				for id = 1, getn(rules) do
					user:SendData(">>\t"..id..". "..rules[id])
				end
			else return
			end; return 1
		end
	end
end

btw your script will choke on offline users and invalid rules

((UKSN))shad_dow

Nice 1 tezlo

benn looking into using tables , read as many how-tos i can find and dtill getting confused ..

ps can i use ur version  above and il will add creadits to the bot for u :) .. ps got any other info on tables plase , by looks of it i can cut down and make bot do less work with tables :)

and thx again :)
creator of Therapy-X? bot

plop

QuoteOriginally posted by ((UKSN))shad_dow
benn looking into using tables , read as many how-tos i can find and dtill getting confused ..
ps got any other info on tables plase , by looks of it i can cut down and make bot do less work with tables :)

have you checked my howto ??
also search for a topic with the something like "having OP's ammed with there own description".
lost the precise name but it shows how 2 make a bot using tables with a welcome msg per OP.
how the OP can change his own welcome msg and load/save the table from/to file.

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 <----<<

((UKSN))shad_dow

hi plop

yes i have cheack ur how-to , still trying to understand it ,(see still keep reading it ) , its not so much as writeing the code , its more understanding the code , put il get there in end :) ... PS haveing a look for that script u meantion as i type this :)

thx again plop
creator of Therapy-X? bot

SMF spam blocked by CleanTalk