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