| View previous topic :: View next topic |
| Author |
Message |
nsrafk Halfop
Joined: 11 May 2007 Posts: 73
|
Posted: Thu May 24, 2007 7:32 am Post subject: Ban masks |
|
|
Hi all. I've downloaded 'CCAS Netbots Edition' by Loki. (Complete Channel Administration System)
I have a question, to change to banmask the script uses.
In the script i see:
| Code: | # The following proc makes a proper hostmask for use with banning, etc..
#------------------------------------------------------------------------------------------------------------
proc getmask {nick chan} {
set mask [string trimleft [maskhost [getchanhost $nick $chan]] *!]
set mask *!*$mask
return $mask
}
#------------------------------------------------------------------------------------------------------------
# The following proc makes a proper hostmask for use with banning, etc..
#------------------------------------------------------------------------------------------------------------
proc warnban {nick mask chan bantime warn rest} {
global color1loki rulebreaker pbannounce
if {$warn == 0} { set rulebreaker($mask) "0 [unixtime]" }
if {![info exists rulebreaker($mask)]} {
set rulebreaker($mask) "$warn [unixtime]"
}
if {[expr [unixtime] - [lindex $rulebreaker($mask) 1]] > 259200} {
set rulebreaker($mask) "$warn [unixtime]"
}
if {[lindex $rulebreaker($mask) 0] < 1} {
foreach activeban [banlist $chan] {
if {[lindex $activeban 0] == $mask} {return 1}
}
puthelp "PRIVMSG $nick :$color1loki You have triggered an AutoBan: $rest \(Perm Ban\)"
putlog "\0033 4 $nick \($mask\) has been Auto Perm Banned"
puthelp "PRIVMSG $pbannounce :4 $nick \($mask\) has been Auto Perm Banned from $chan \(5 Reason: $rest\) Type !override to undo"
set rulebreaker(overmask) "$mask"
newban $mask "Autoban" $rest 20000
unset rulebreaker($mask)
putkick $chan $nick "AutoBan: $rest \(Perm Banned\)"
} elseif {[lindex $rulebreaker($mask) 0] == 1} {
foreach activeban [banlist $chan] {
if {[lindex $activeban 0] == $mask} {
set rulebreaker($mask) "[expr [lindex $rulebreaker($mask) 0] - 1] [lindex $rulebreaker($mask) 1]"
return 1
}
}
if {$bantime != 0} {
puthelp "PRIVMSG $nick :$color1loki You have triggered an AutoBan: $rest \[Last Warning\] \($bantime min ban\)"
newchanban $chan $mask "Autoban" $rest $bantime
}
set rulebreaker($mask) "[expr [lindex $rulebreaker($mask) 0] - 1] [lindex $rulebreaker($mask) 1]"
putkick $chan $nick "AutoBan: $rest !-Last Warning-! \($bantime min ban\)"
} else {
foreach activeban [banlist $chan] {
if {[lindex $activeban 0] == $mask} {
set rulebreaker($mask) "[expr [lindex $rulebreaker($mask) 0] - 1] [lindex $rulebreaker($mask) 1]"
return 1
}
}
if {$bantime != 0} {
puthelp "PRIVMSG $nick :$color1loki You have triggered an AutoBan: $rest \[1st Warning\] \($bantime min ban\)"
newchanban $chan $mask "Autoban" $rest $bantime
}
set rulebreaker($mask) "[expr [lindex $rulebreaker($mask) 0] - 1] [lindex $rulebreaker($mask) 1]"
putkick $chan $nick "AutoBan: $rest !-Warning-! \($bantime min ban\)"
}
return 1
}
|
When using this my eggdrop sets a ban like this:
*!*Love@*.quakenet.org
I want the ban to look something like:
*!*Love@GeRbeNsEn.users.quakenet.org
I've tried to mess around with this, but im too stupid to make it work lol.
Thanks for any help! |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Thu May 24, 2007 7:48 am Post subject: |
|
|
Changing the "getmask" proc to something like this should work;
| Code: | proc getmask {nick chan} {
return *!*[getchanhost $nick $chan]
} |
_________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
nsrafk Halfop
Joined: 11 May 2007 Posts: 73
|
Posted: Thu May 24, 2007 9:04 am Post subject: |
|
|
Ok, thanks. Ill try it and see if it works  |
|
| Back to top |
|
 |
nsrafk Halfop
Joined: 11 May 2007 Posts: 73
|
Posted: Thu May 24, 2007 9:11 am Post subject: |
|
|
It works, thanks. There's just one problem though. It sets bane like this:
*!*~ident@host.com
is there a way to strip the ~ ? |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Thu May 24, 2007 10:04 am Post subject: |
|
|
| Code: | proc getmask {nick chan} {
return *!*[string trimleft [getchanhost $nick $chan] "~"]
} |
_________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
nsrafk Halfop
Joined: 11 May 2007 Posts: 73
|
Posted: Thu May 24, 2007 10:23 am Post subject: |
|
|
| Thanks mate. Works perfect. |
|
| Back to top |
|
 |
nsrafk Halfop
Joined: 11 May 2007 Posts: 73
|
Posted: Thu May 24, 2007 10:34 am Post subject: |
|
|
One last thing - how would the proc look like if i would set bans like *!*@host.com ?  |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Thu May 24, 2007 10:46 am Post subject: |
|
|
For this, there are several options. Two most common would be to either split the hostmask into a list (using split with "@" as split-character), and then, using lindex, select the last list-element; or, using string first to find the location of the @, and then use "string range" to select a substring..
In either case you would have no further need for the "string trimleft". _________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
nsrafk Halfop
Joined: 11 May 2007 Posts: 73
|
Posted: Thu May 24, 2007 11:10 am Post subject: |
|
|
ok, it seems that i really need to read now.. cos that i have no clue on hwo to do..
EDIT:
seems like the first way to do it with split is the easiest way to do it. How would i put it then? Something like;
| Code: | | [strip [getchanhost $nick $chan] "@"] |
And then im lost with the lindex stuff. Can u please show me a working example of this? Sorry for being stupid at this hehe  |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Thu May 24, 2007 1:21 pm Post subject: |
|
|
| Code: | | getchanhost $nick $chan |
returns user@host
| Code: | | split [getchanhost $nick $chan] @ |
returns a list containing 'user' and 'host' {user host}.
The index of 'user' is 0 and the index of 'host' is 1. Since you want the host, you use:
| Code: | | lindex [split [getchanhost $nick $chan] @] 1 |
so, to get *!*@host:
| Code: | | set mask *!*@[lindex [split [getchanhost $nick $chan] @] 1] |
_________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
nsrafk Halfop
Joined: 11 May 2007 Posts: 73
|
Posted: Thu May 24, 2007 2:41 pm Post subject: |
|
|
| Oh, thanks so much! That was very helpful! You're good at explaining man. Thanks! |
|
| Back to top |
|
 |
|