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.

questions about a banmaskscript

Old posts that have not been replied to for several years.
Locked
B
Burke
Voice
Posts: 21
Joined: Mon Feb 07, 2005 9:33 pm

questions about a banmaskscript

Post by Burke »

hi

i tryed to make a little script.
this will be called in some other procs with
get:ban:mask "$BUZAin"
and $BUZAin will be always nick!ident@host.

Code: Select all

proc get:ban:mask { BUZAin } {
global ipbanhosts BUZAout botnick botname
	putlog "get:ban:mask -- eingangsmask -- $BUZAin"

	set BUZA [lindex [split $BUZAin "!"] 1]
	set ::BUZAout "*!$BUZA"

	if {[string match "*.users.quakenet.org*" $BUZAin]} { set BUZA [lindex [split $BUZAin "@"] 1] ; set ::BUZAout "*!*@$BUZA" }
	if {[string match "*@*proxad*" $BUZAin]} { set BUZA [lindex [split $BUZAin "@"] 1] ; set ::BUZAout "*!*@$BUZA" }
	if {[string match "*@*chello*" $BUZAin]} { set BUZA [lindex [split $BUZAin "@"] 1] ; set ::BUZAout "*!*@$BUZA" }
	if {[string match "*@*kabelbw*" $BUZAin]} { set BUZA [lindex [split $BUZAin "@"] 1] ; set ::BUZAout "*!*@$BUZA" }
	if {[string match "*@*mediaways*" $BUZAin]} { set BUZA [lindex [split $BUZAin "@"] 1] ; set ::BUZAout "*!*@$BUZA" }
[...........................much other.............]
	
	if {[string match $botnick $BUZAout]} { set BUZAout "error!*@*" ; putlog "proc get:ban:mask in: $BUZAin out: $BUZAout - botnick" }
	if {[string match $botname $BUZAout]} { set BUZAout "error!*@*" ; putlog "proc get:ban:mask in: $BUZAin out: $BUZAout - botname" }

	if { "*!" == $BUZAout } { set BUZAout "error!*@*" ; putlog "proc get:ban:mask in: $BUZAin out: $BUZAout - *!*@*" }
	if { "*!@*" == $BUZAout } { set BUZAout "error!*@*" ; putlog "proc get:ban:mask in: $BUZAin out: $BUZAout - *!*@*" }
	if { "*!*@*" == $BUZAout } { set BUZAout "error!*@*" ; putlog "proc get:ban:mask in: $BUZAin out: $BUZAout - *!*@*" }
	if { "*!*@" == $BUZAout } { set BUZAout "error!*@*" ; putlog "proc get:ban:mask in: $BUZAin out: $BUZAout - *!*@*" }
	if { "!*@*" == $BUZAout } { set BUZAout "error!*@*" ; putlog "proc get:ban:mask in: $BUZAin out: $BUZAout - *!*@*" }
	if { "*!@" == $BUZAout } { set BUZAout "error!*@*" ; putlog "proc get:ban:mask in: $BUZAin out: $BUZAout - *!*@*" }

	putlog "get:ban:mask -- ausgangsmask -- $BUZAout"

	return $BUZAout
}
That should if the user is in mode +x or use a dynamic host ban *!*@host. If not, it`s mosttimes a bnc/static host and it should ban *!ident@host. Because *!*@host will match to many users which should not be affected.

Those putlogs will be removed later, for sure. Just for tests.
I think i should make it smaller but no idea how.

Next point, i need to know how can i set that every nick!ident@134.345.454.43 will be masked with *!*@ip ?
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

you can probably save some code using switch and regexp, but it probably won't reduce execution time.
But I would recommned you to use || in the if expression, if the if-body will be the same anyway.
btw. you dont need :: before BUZAout, you already included the var in the global line.
oh yes, why do you want to use error!*@* as error ident? i would recommed using -1 for errors (read tcl man for how to "return" errors for more details).

PS: your bot might get into trouble when comparing the string ~ within a ban, I just wrote a script within I had to replace it with ? like [string map {~ ?} $uhost].
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
B
Burke
Voice
Posts: 21
Joined: Mon Feb 07, 2005 9:33 pm

Post by Burke »

you can probably save some code using switch and regexp, but it probably won't reduce execution time.
- mhh, ok.

But I would recommned you to use || in the if expression, if the if-body will be the same anyway.
- ok

btw. you dont need :: before BUZAout, you already included the var in the global line.
- right, my error.

oh yes, why do you want to use error!*@* as error ident? i would recommed using -1 for errors (read tcl man for how to "return" errors for more details).
- i know. this is only for my self. if 1 proc call those banmask proc with a wrong host because i don`t think about everthing (user not longer on channel) and i would never set +b *!*@ or something. just a little protection.

PS: your bot might get into trouble when comparing the string ~ within a ban, I just wrote a script within I had to replace it with ? like [string map {~ ?} $uhost].
- mhh. never heared about but thanks for the tip.

now just the question how can i detect ip`s?
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

Burke wrote:- mhh. never heared about but thanks for the tip.
this suggestion is because of this:
http://www.eggheads.org/bugzilla/show_bug.cgi?id=423
I dont know if there could be also problems just the other way with ~, but I believe it's best to avoid problems, before they even occur ;).
Burke wrote:now just the question how can i detect ip`s?
best done with a regular expression:
http://forum.egghelp.org/viewtopic.php?t=4319
http://www.tcl.tk/man/tcl8.4/TclCmd/re_syntax.htm
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

You might want to take a look at this as well, if you are trying to make a banmask selector:

http://forum.egghelp.org/viewtopic.php?t=8741
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
Locked