PtokaX forum

Archive => Archived 4.0 boards => Finished Lua 4 scripts => Topic started by: 6Marilyn6Manson6 on 13 September, 2004, 20:24:17

Title: SetRedirect ON/OFF
Post by: 6Marilyn6Manson6 on 13 September, 2004, 20:24:17
Ehy hallo. I need a bot with these two commands: !setredirect
where i can set the redirect hub for full or limits,  and  !redirect where i can set on or off the redirect for hub full, thanks at all [only for MASTER]!!! BYE BYE
Title:
Post by: bastya_elvtars on 13 September, 2004, 20:44:06
-- Redirect Bot by bastya_elvtars (the rock n' roll doctor)
-- written for 6Marilyn6Manson6
-- usual: cmds can be main or in PM
-- set if u want the bot in userlist or not
-- cmds can be customised
-- only MASTER profile can use it
-- based on channelbot 0.9h by Nathanos

cmd1="!chred" -- changing default redir addy

cmd2="!setredirectall" -- setting redirect all newly coming users (on/off)

cmd3="!setredirectfull" -- setting redirect all when hub full (on/off)

Bot="RedirectBot" -- no need 2 explain

BotInUserList=1 -- set to 1 if u wanna see bot in userlist

function Main()
if BotInUserList==1 then
frmHub:RegBot(Bot)
end
end

-- dont edit below

function ChRed(user, data,env)
if user.iProfile==0 then
local _,_,newaddy=strfind(data,"%b<>%s+%S+%s+(%S+)")
if newaddy then
frmHub:SetRedirectAddress(newaddy)
SendToOps(Bot, user.sName.." changed the hub redirect address to: "..newaddy.." |")
user:SendData(parseenv(user,env,Bot).."You changed the hub redirect address to: "..newaddy.." |")
else
user:SendData(parseenv(user,env,Bot).. "It would be so nice to type the redirect address, don't  you think? |")
end
else
user:SendData(parseenv(user,env,Bot).."You do not have sufficient rights to run that command! |")
end
end

function SetRedirectAll(user, data,env)
if user.iProfile==0 then
local _,_,arg=strfind(data,"%b<>%s+%S+%s+(%S+)")
if arg ~= nil then
if (arg=="on") then
frmHub:SetRedirectFull(0)
frmHub:SetRedirectAll(1)
SendToOps(Bot, user.sName.." changed the redirect all new connections to: "..arg.." |")
user:SendData(parseenv(user,env,Bot).."You changed the redirect all new connections to: "..arg.." |")
elseif (arg=="off") then
frmHub:SetRedirectAll(0)
SendToOps(Bot, user.sName.." changed the redirect all new connections to: "..arg.." |")
user:SendData(parseenv(user,env,Bot).."You changed the redirect all new connections to: "..arg.." |")
else
user:SendData(parseenv(user,env,Bot).."The value can only be: on or off.  It cannot be "..arg.." |")
end
else
user:SendData(parseenv(user,env,Bot).. "Damn, don't be so lazy, type the switch after the comand too! |")
end
else
user:SendData(parseenv(user,env,Bot).."You do not have sufficient rights to run that command! |")
end
end

function SetRedirectFull(user, data,env)
if user.iProfile==0 then
local _,_,arg=strfind(data,"%b<>%s+%S+%s+(%S+)")
if arg ~= nil then
if (arg=="on") then
frmHub:SetRedirectAll(0)
frmHub:SetRedirectFull(1)
SendToOps(Bot, user.sName.." has enabled the redirect all new connections when maximum connections reached feature. |")
user:SendData(parseenv(user,env,Bot).."You have enabled the redirect all new connections when maximum connections reached feature.|")
elseif (arg=="off") then
frmHub:SetRedirectFull(0)
SendToOps(Bot, user.sName.." has disabled the redirect all new connections when maximum connections reached feature. |")
user:SendData(parseenv(user,env,Bot).."You have disabled the redirect all new connections when maximum connections reached feature.|")
else
user:SendData(parseenv(user,env,Bot).."The value can only be: on or off.  It cannot be "..arg.." |")
end
else
user:SendData(parseenv(user,env,Bot).. "Damn, don't be so lazy, type the switch after the comand too! |")
end
else
user:SendData(parseenv(user,env,Bot).."You do not have sufficient rights to run that command! |")
end
end


function DataArrival(user,data)
returndata=0
if strsub(data, 1, 1) == "<" then
data=strsub(data,1,strlen(data)-1)
local _,_,cmd = strfind(data,"%b<>%s+(%S+)")
if cmd then
returndata=parsecmds(user,data,strlower(cmd),"MAIN")
end
elseif strsub(data, 1, 4) == "$To:" then
data=strsub(data,1,strlen(data)-1)
local _,_,whoTo = strfind(data,"$To:%s+(%S+)")
if (whoTo == Bot) then
local _,_,cmd = strfind(data,"$To:%s+%S+%s+From:%s+%S+%s+$%b<>%s+(%S+)")
cmd=strlower(cmd)
returndata=parsecmds(user,data,cmd,"PM")
end
end return returndata
end

function parsecmds(user,data,cmd,env)
if cmd==cmd1 then
ChRed(user,data,env) returndata=1
elseif cmd==cmd2 then
SetRedirectAll(user,data,env) returndata=1
elseif cmd==cmd3 then
SetRedirectFull(user,data,env) returndata=1
end
return returndata
end

function parseenv(user,env,bot)
if env=="PM" then
return "$To: "..user.sName.." From: "..bot.." $<"..bot.."> "
elseif env=="MAIN" then
return "<"..bot.."> "
end
end
Title:
Post by: bastya_elvtars on 14 September, 2004, 00:07:32
above post edited, there was a little error. Next time request scripts in the request scripts thread! ;)
Title:
Post by: 6Marilyn6Manson6 on 14 September, 2004, 09:55:53
Hello. The script doesn't work. I am master but: [09:41] You do not have sufficient rights to run that command! . Besides I asked as I command  !setredirect
 that is a command to change the hub of redirect and not  !setredirect . Thanks a lot. ^__^


MY HUB: planetarium.no-ip.org


This is my profile:
0|Master|11111111111111111111111000000001
1|Operator|11111100011001111111111000000001
2|VIP|10000000000001111100000000000000
3|Reg|10000000000000000100000000000000
4|Moderator|11111110011101111111110000000001


I forgot... this command has to work that is only with the Master with the profile 0 .  Thanksssssssssssssss
Title:
Post by: bastya_elvtars on 14 September, 2004, 10:50:57
i was an idiot. i set it that only regular ops can use it :D

edited of course