This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Ban masks

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
n
nsrafk
Halfop
Posts: 73
Joined: Fri May 11, 2007 12:25 am

Ban masks

Post by nsrafk »

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: Select all

# 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!
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Changing the "getmask" proc to something like this should work;

Code: Select all

proc getmask {nick chan} {
  return *!*[getchanhost $nick $chan]
}
NML_375
n
nsrafk
Halfop
Posts: 73
Joined: Fri May 11, 2007 12:25 am

Post by nsrafk »

Ok, thanks. Ill try it and see if it works :)
n
nsrafk
Halfop
Posts: 73
Joined: Fri May 11, 2007 12:25 am

Post by nsrafk »

It works, thanks. There's just one problem though. It sets bane like this:

*!*~ident@host.com

is there a way to strip the ~ ?
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Code: Select all

proc getmask {nick chan} {
  return *!*[string trimleft [getchanhost $nick $chan] "~"]
}
NML_375
n
nsrafk
Halfop
Posts: 73
Joined: Fri May 11, 2007 12:25 am

Post by nsrafk »

Thanks mate. Works perfect.
n
nsrafk
Halfop
Posts: 73
Joined: Fri May 11, 2007 12:25 am

Post by nsrafk »

One last thing - how would the proc look like if i would set bans like *!*@host.com ? :)
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

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
n
nsrafk
Halfop
Posts: 73
Joined: Fri May 11, 2007 12:25 am

Post by nsrafk »

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: Select all

[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 :)
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Code: Select all

getchanhost $nick $chan
returns user@host

Code: Select all

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: Select all

lindex [split [getchanhost $nick $chan] @] 1
so, to get *!*@host:

Code: Select all

set mask *!*@[lindex [split [getchanhost $nick $chan] @] 1]
n
nsrafk
Halfop
Posts: 73
Joined: Fri May 11, 2007 12:25 am

Post by nsrafk »

Oh, thanks so much! That was very helpful! You're good at explaining man. Thanks!
Post Reply