PtokaX forum

Archive => Archived 5.0 boards => Finished Scripts => Topic started by: 6Marilyn6Manson6 on 06 May, 2005, 15:04:56

Title: Redirect Bot
Post by: 6Marilyn6Manson6 on 06 May, 2005, 15:04:56
-- 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
-- Converted in LUA 5 by 6Marilyn6Manson6 at 06/05/2005

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=string.find(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=string.find(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=string.find(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 ChatArrival(user,data)
returndata=0
if string.sub(data, 1, 1) == "<" then
data=string.sub(data,1,string.len(data)-1)
local _,_,cmd = string.find(data,"%b<>%s+(%S+)")
if cmd then
returndata=parsecmds(user,data,string.lower(cmd),"MAIN")
end
elseif string.sub(data, 1, 4) == "$To:" then
data=string.sub(data,1,string.len(data)-1)
local _,_,whoTo = string.find(data,"$To:%s+(%S+)")
if (whoTo == Bot) then
local _,_,cmd = string.find(data,"$To:%s+%S+%s+From:%s+%S+%s+$%b<>%s+(%S+)")
cmd=string.lower(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

c ya
Title:
Post by: DorianG on 06 May, 2005, 19:27:23
Now these strings have stayed replaced from:
if string.sub(data,1,1) == "<" then  ---> function ChatArrival(user, data)
if string.sub(data,1,4) == "$To:" then ---> function ToArrival(user,data)
Title:
Post by: gOOfus on 15 July, 2005, 18:10:36
Hello, could it be possible to add the feature of redirecting by profile so you can redirect all but or Masters?
Title:
Post by: BeeR on 18 August, 2005, 16:08:47
QuoteOriginally posted by 6Marilyn6Manson6
-- 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
-- Converted in LUA 5 by 6Marilyn6Manson6 at 06/05/2005

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=string.find(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=string.find(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=string.find(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 ChatArrival(user,data)
returndata=0
if string.sub(data, 1, 1) == "<" then
data=string.sub(data,1,string.len(data)-1)
local _,_,cmd = string.find(data,"%b<>%s+(%S+)")
if cmd then
returndata=parsecmds(user,data,string.lower(cmd),"MAIN")
end
elseif string.sub(data, 1, 4) == "$To:" then
data=string.sub(data,1,string.len(data)-1)
local _,_,whoTo = string.find(data,"$To:%s+(%S+)")
if (whoTo == Bot) then
local _,_,cmd = string.find(data,"$To:%s+%S+%s+From:%s+%S+%s+$%b<>%s+(%S+)")
cmd=string.lower(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

c ya
Hello folks :]

nice rd-bot ,,
why not let netowners use the commands - not only the owner/master inda hub

Best Regards
Title:
Post by: Dessamator on 18 August, 2005, 16:37:42
Well, the script is editable aka DO it yourself .
Title:
Post by: BeeR on 18 August, 2005, 17:32:27
QuoteOriginally posted by Dessamator
Well, the script is editable aka DO it yourself .

Belive me - i have tried to solve it myself
i wouldnt ask if i did make it to work

function ChRed(user, data,env)
   if user.iProfile==0 or 1 then

function ChRed(user, data,env)
   if user.iProfile==0,1 then

just some changes i did test
Title:
Post by: bastya_elvtars on 18 August, 2005, 17:51:18
if user.iProfile==0 or user.iProfile== 1
Title:
Post by: BeeR on 18 August, 2005, 18:10:25
QuoteOriginally posted by bastya_elvtars
if user.iProfile==0 or user.iProfile== 1

it works :]
trying to learn something new every day

Thanks
Title:
Post by: BeeR on 20 August, 2005, 12:09:45
Hello alles

a litle request:

a command for showing what rd-adress the hub has (!shred)
my netowners complains - they cannot see hubs rdadress =(
Title:
Post by: gOOfus on 20 August, 2005, 19:37:22
And can you add the function of redirecting all but OPs?