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.

badjoin

Old posts that have not been replied to for several years.
Locked
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

badjoin

Post by caesar »

Code: Select all

proc my:bad:join {nick uhost handle channel} {
  if {![file exists $::badfile]} {
    putlog "Error: $::badfile dose not exist."
    return 0
  }
  if {![botisop $channel]} {
    return
  }
  if {$nick == $::botnick} {
    foreach luser [chanlist $channel] {
      if {$luser == $::botnick} {
        continue
      }
      set file [open "$::badfile" r]
      while {![eof $file]} {
        set line [gets $file]
        if {![string match "$uhost" "$line"]} {
          set mask "*!*@[lindex [split $uhost @] 1]"
          newchanban $channel $mask BadJoin "$::badreas" $::badtime
        }
      }
      catch {close $file}
    }
    return
  }
  set file [open "$::badfile" r]
  while {![eof $file]} {
    set lines [gets $file]
    foreach line $lines {
      if {$line == ""} {
        continue
      }
      set mask "*!*@[lindex [split $uhost @] 1]"
      putlog "$mask vs. $line"
      if {[string match "$mask" "$line"] || [string equal "$mask" "$line"]} {
        return
      }
      set mask "*!*@[lindex [split $uhost @] 1]"
      # newchanban $channel $mask BadJoin "$::badreas" $::badtime
      putserv "PRIVMSG $channel :banning $nick with $mask"
    }
  }
  catch {close $file}
}
When I have in list this masks *!*@somehting.com *!*@bla.com *!*@I.Have.Killed.The.Devil.So.God.Made.Me.An.Angel.org he "bans" me no matter if I have the *!*@I.Have.Killed.The.Devil.So.God.Made.Me.An.Angel.org hostmask. But if *!*@I.Have.Killed.The.Devil.So.God.Made.Me.An.Angel.org is the first mask in the list he dosen't ban me anymore. Any sugestions on what may be wrong in here?
Once the game is over, the king and the pawn go back in the same box.
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

well.. as a start.. :)

1.gets only return one line at the time, so you don't need the foreach loop inside the while loop

2.You might want to add the -nocase options to the string match/equal checks(you only need the string match)

3.no need to set the mask twice in the while-loop :)
Elen sila lúmenn' omentielvo
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

1. Thanks for the loop vs. foreach tip. Removed it.
2. Added the -nocase and no result. Same story..
3. Removed it. Added the first one just to see the $mask vs. $line result.

Now it's:

Code: Select all

if {[string match -nocase "$mask" "$line"]} {
I see it comparing: *!*@I.Have.Killed.The.Devil.So.God.Made.Me.An.Angel.org vs. *!*@I.Have.Killed.The.Devil.So.God.Made.Me.An.Angel.org and should return but it dosen't..
Once the game is over, the king and the pawn go back in the same box.
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

well, just a single space at the end of *!*@I.Have.Killed.The.Devil.So.God.Made.Me.An.Angel.org will make it return 0, just add another vildcard to the match, like this:

Code: Select all

if {[string match -nocase "$mask*" $line]} {
Elen sila lúmenn' omentielvo
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Nope. Same result..
on dcc:
(13:27:12) ::: <bot> [13:27] *!*@I.Have.Killed.The.Devil.So.God.Made.Me.An.Angel.org vs. *!*@I.Have.Killed.The.Devil.So.God.Made.Me.An.Angel.org

on channel:
(13:27:13) ::: <@bot> banning caesar with *!*@I.Have.Killed.The.Devil.So.God.Made.Me.An.Angel.org
Once the game is over, the king and the pawn go back in the same box.
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

Code: Select all

proc my:bad:join {nick uhost handle channel} { 
  if {![file exists $::badfile]} { 
    putlog "Error: $::badfile dose not exist." 
    return 0 
  } 
  if {![botisop $channel]} { 
    return 
  } 
  set mask "*!*@[lindex [split $uhost @] 1]" 
  if {$nick == $::botnick} { 
    foreach luser [chanlist $channel] { 
      if {$luser == $::botnick} { 
        continue 
      } 
      set file [open "$::badfile" r] 
      while {![eof $file]} { 
        set line [gets $file] 
        if {![string match "$uhost" "$line"]} { 
          newchanban $channel $mask BadJoin "$::badreas" $::badtime 
        } 
      } 
      catch {close $file} 
    } 
    return 
  } 
  set file [open "$::badfile" r] 
  while {![eof $file]} { 
    gets $file line
    if {$line == ""} { 
      continue 
    } 
    putlog "$mask vs. $line"
    if {[string match $mask* $line]} { 
      set found 1; break 
    }  
  } 
  if {![info exists found]} {
    # newchanban $channel $mask BadJoin "$::badreas" $::badtime 
    putserv "PRIVMSG $channel :banning $nick with $mask"
  }
  catch {close $file} 
} 
I modified it a littlebit ;) it works now
Elen sila lúmenn' omentielvo
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Humm.. now it's working. I'll read up and see where I've screwed it up. Thanks. :)
Once the game is over, the king and the pawn go back in the same box.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Now I need to figure out a way I can match other hostmask with the $mask, some masks like *!*bla@* or *!*@*.something.com .. etc..
Once the game is over, the king and the pawn go back in the same box.
Locked