egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Ban masks

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
nsrafk
Halfop


Joined: 11 May 2007
Posts: 73

PostPosted: Thu May 24, 2007 7:32 am    Post subject: Ban masks Reply with quote

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
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Thu May 24, 2007 7:48 am    Post subject: Reply with quote

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
View user's profile Send private message
nsrafk
Halfop


Joined: 11 May 2007
Posts: 73

PostPosted: Thu May 24, 2007 9:04 am    Post subject: Reply with quote

Ok, thanks. Ill try it and see if it works Smile
Back to top
View user's profile Send private message
nsrafk
Halfop


Joined: 11 May 2007
Posts: 73

PostPosted: Thu May 24, 2007 9:11 am    Post subject: Reply with quote

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
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Thu May 24, 2007 10:04 am    Post subject: Reply with quote

Code:
proc getmask {nick chan} {
  return *!*[string trimleft [getchanhost $nick $chan] "~"]
}

_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
nsrafk
Halfop


Joined: 11 May 2007
Posts: 73

PostPosted: Thu May 24, 2007 10:23 am    Post subject: Reply with quote

Thanks mate. Works perfect.
Back to top
View user's profile Send private message
nsrafk
Halfop


Joined: 11 May 2007
Posts: 73

PostPosted: Thu May 24, 2007 10:34 am    Post subject: Reply with quote

One last thing - how would the proc look like if i would set bans like *!*@host.com ? Smile
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Thu May 24, 2007 10:46 am    Post subject: Reply with quote

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
View user's profile Send private message
nsrafk
Halfop


Joined: 11 May 2007
Posts: 73

PostPosted: Thu May 24, 2007 11:10 am    Post subject: Reply with quote

ok, it seems that i really need to read now.. cos that i have no clue on hwo to do.. Smile

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 Smile
Back to top
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Thu May 24, 2007 1:21 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
nsrafk
Halfop


Joined: 11 May 2007
Posts: 73

PostPosted: Thu May 24, 2007 2:41 pm    Post subject: Reply with quote

Oh, thanks so much! That was very helpful! You're good at explaining man. Thanks!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber