To monitor user access, I want to prevent users from dcc'ing any bot but the hubbot (or a bot set in the script itself). I'd like to be able to define a flag via the script, that would be allowed to dcc chat any bot.. (ie, global +o).
If a user tries to attempt to dcc any bot but the hub, and does not have the appropriate access level, they get a notice telling them 'Access Denied, please use the hub bot.'
Unfortunately, the +p flag won't work, due to the bots sharing userfiles. If I remove the flag, they can't dcc any bot.
ppslim, stdragon.. could either of you design a script like this please? I'm not sure how complicated or involved it would be, please let me know.
#Add the bots you wish to allow users access too
set accessbots {
bot1
bot2
}
#set the flag you wish to use for access no matter what
set accessflag P
bind ctcp - DCC test:access
proc test:access {nick uh hand dest key arg} {
global accessbots accessflag
if {![isbotnick $dest]} { return 1 }
if {[matchattr $hand $accessflag]} { return 0 }
set found 0
foreach _A $accessbots { if {[isbotnick $_A]} { set found 1 } }
if {!($found)} {
privmsg "NOTICE $nick :Access denied, use a hub bot"
return 1
}
}
Add the bots you wish to allow users access too
set accessbots {
bot1
bot2
}
#set the flag you wish to use for access no matter what
set accessflag P
bind ctcp - DCC test:access
proc test:access {nick uh hand dest key arg} {
global accessbots accessflag
if {![isbotnick $dest]} { return 1 }
if {[matchattr $hand $accessflag]} { return 0 }
set found 0
foreach _A $accessbots { if {[isbotnick $_A]} { set found 1 } }
if {!($found)} {
puthelp "NOTICE $nick :Access denied, use a hub bot"
return 1
}
return 0
}
## multiple hubs, uncomment to use
#set accessbots {
#Bot1
#Bot2
#}
set accessbots Bot1
#set the flag you wish to use for access no matter what
set accessflag m
bind ctcp - DCC test:access
proc test:access {nick uh hand dest key arg} {
global accessbots accessflag
if {![isbotnick $dest]} { return 1 }
if {[matchattr $hand $accessflag]} { return 0 }
set found 0
foreach _A $accessbots { if {[isbotnick $_A]} { set found 1 } }
if {!($found)} {
puthelp "NOTICE $nick :Access denied, use $accessbots please. Thanks!"
dccbroadcast "[Time!notice] $hand attempted to access the partyline via me! Denied."
return 1
}
return 0
}
How can this be modified so if Bot1 is offline, access will be allowed to everyone via Bot2, regardless of flag settings? IE, when main hub is down, to allow use of althub?
## multiple hubs, uncomment to use
#set accessbots {
#Bot1
#Bot2
#}
#anyway to check the userfile for +h and then assign it $hub (egg1.6.6)
set hub "Bot1"
#anyway to check the userfile for +a and then assign it $althub
set althub "Bot2"
#set the flag you wish to use for access no matter what
set accessflag m
bind ctcp - DCC test:access
proc test:access {nick uh hand dest key arg} {
global hub althub accessflag
if {![isbotnick $dest]} { return 1 }
if {[matchattr $hand $accessflag]} { return 0 }
#stops script, and should allow access? works on any bot tho if $hub is not linked... should only work on $althub
if {![islinked $hub==0]} { return 0 }
#continues script, $hub is linked
if {![islinked $hub==1]} { return 1 }
set found 0
#not sure on this line...
foreach _A $hub $althub { if {[isbotnick $_A]} { set found 1 } }
if {!($found)} {
puthelp "NOTICE $nick :Access denied, use $hub please. Thanks!"
dccbroadcast "[Time!notice] $hand attempted to access the partyline via me! Denied."
return 1
}
return 0
}
Getting error:
TCL error [test:access]: wrong # args: should be "foreach varList list ?varList list ...? command"
Any ideas? See my comments in code...
<font size=-1>[ This Message was edited by: jedis on 2001-10-29 22:02 ]</font>
If you are going to complain at that, complain at yourself. There was nothing in your original post about the user having to be in the userfile, nor did they have to have the +p flag. You should be more acurate in your discription, as forgettings to mention things will make this forum fill up very wuick, and make the coders give up very easy, as they feel being led around a mery dance, codeing for your pleasure.
#Set your hubs here
set accesshubs {
Hub1
}
#set you alt hubs here
set accessalt {
AltHub1
AltHub2
}
#set the flag required for access no matter what
set accessflag P
#NOTE THE CAPS ABOVE
bind ctcp - DCC test:access
proc test:access {nick uh hand dest arg} {
global accesshubs accessalt accessflag
if {![isbotnick $dest]} { return 1 }
if {[string tolower [lindex [split $arg]] 0] != "chat"} { retrun 1 }
if {(![validuser $hand]) || (![matchattr $hand p])} { return 0 }
if {[matchattr $hand $accessflag]} { return 1 }
set ho 0
set hf 0
foreach _A $accesshub {
if {[isbotnick $_A]} { set hf 1 }
if {[islinked $_A]} { set ho 1 }
}
if {$hf} { return 1 }
if {$ho} {
puthelp "NOTICE $nick :Access denied - try a hub bot"
return 0
}
foreach _A $accessalt {
if {[isbotnick $_A]} { set hf 1 }
}
if {$hf} { return 1 }
puthelp "NOTICE $nick :Access denied - Try a alt hub"
return 0
}
Note, that script won't prevent direct telnet access (eg /ctcp bot CHAT). a much better implementation is to bind to chon and killdcc if user has invalid flags.
ppslim: I had originally only thought I would need the script as I requested it, but once I saw it in action, I realized the few problems with it. I did not mean to lead you in circles. For that I apologize. I will try out the new version now. Thank you for your hard work.
Peterson: How would I go about doing that?
<font size=-1>[ This Message was edited by: jedis on 2001-10-30 19:05 ]</font>
You would also need to make sure this DCC is a CHAT not a "SEND". Also, as for the +p thing jedis found... Just do an if {[matchattr $hand p]} { .. etc.