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.

Banning problem. Bot applies wrong banmask.

Old posts that have not been replied to for several years.
Locked
User avatar
Aron
Halfop
Posts: 86
Joined: Sat Mar 15, 2003 8:35 am

Banning problem. Bot applies wrong banmask.

Post by Aron »

I wrote a script with 3 different userlevels (combined with some authentication script). These levels all have their different commands, including a !ban.

This is in the form om !ban Nickname/Hostmask [time] [reason]

It works fine, normally, but sometimes it refuses to work, but only adds a ban in the form of *!ident@*.host.com, instead of *!*ident. This causes the ban to fail if there is a ~ in the ident.

I already tried it on different users (with a ~ in their ident), and it worked fine. Just, with some users, the banmask gets applied incorrectly :(

I can't seem to find the problem..

Here is a piece of code from my ban process:

Code: Select all

proc academy:ban {nick host handle chan text} { 
  global botnick guardmethod 


  if {(![authed $handle])} {return 0}
  set userlevel [level $handle]
  
  if {$userlevel == "Knight"} {return 0}
  if {$chan != "#jedi-academy"} {return 0}


  set nickhost [lindex $text 0]
  set time [lindex $text 1]
  set reason [lrange $text 2 end]

  if {$time == "perm"} { 
    set time "0"
  }

  if {$nickhost == ""} {
    return 0
  }

  if {$reason == ""} {
    set reason "Banned via JAbot by $nick. No reason specified."
  }

  if {[nick2hand $nickhost] != "*"} {
    if {[matchattr [nick2hand $nickhost $chan] f|f $chan]} { return 0 } 
    #putserv "PRIVMSG $chan :Debug line 1"
  }

  if {[botisop $chan]} {
    if {[onchan $nick $chan]} {
      #putserv "PRIVMSG $chan :Debug line 2"
      if {[onchan $nickhost $chan]} {
        #putserv "PRIVMSG $chan :Debug line 3"
        set host [maskhost [getchanhost $nickhost $chan]] 
          if {[maskhost [getchanhost $botnick]] != $host && [maskhost $nickhost] != [maskhost [getchanhost $botnick $chan]]} {
          #putserv "PRIVMSG $chan :Debug line 4"
            newchanban $chan $host [nick2hand $nick] "$reason" $time
          #putserv "PRIVMSG $chan :Debug line 5. Variables: $chan - $host - $nick - $reason - $time"
            webbanlist_createhtml
          } else {
              putserv "$guardmethod $nick : $nick whats wrong with you?"
            }
      } else {
          if {[maskhost [getchanhost $botnick]] != $nickhost} {
            newchanban $chan $nickhost $handle "$reason" $time
            putserv "$guardmethod $nick : $nick, \002$nickhost\002 has been added to the $chan banlist, and will be banned when he enters."
            webbanlist_createhtml
          } else {
            putserv "$guardmethod $nick : $nick, quit messing around."
          }            
        }
    } else {
        putserv "$guardmethod $nick : You are not on $chan"
      }
  } else {
    putserv "$guardmethod $nick  : $botnick is not opped on $chan"
    } 
}
Any help would be greatly appreciated :)

The code is kind of messy, since i tried so many things to solve the problem, and didnt remove them yet.

edit: Ow, i forgat to mention:

Those debug lines were all messaged to the channel. The script just applied the wrong banmask. This seems to be the case for certain nicknames only. Over and over, the same people.


-Aron
Last edited by Aron on Mon Dec 29, 2003 6:53 am, edited 1 time in total.
The best way to start learning is to start helping.
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

set host [maskhost [getchanhost $nickhost $chan]]
use

Code: Select all

set host [maskhost *[getchanhost $nickhost $chan]]
this will add a * after ! (in ident)
User avatar
Aron
Halfop
Posts: 86
Joined: Sat Mar 15, 2003 8:35 am

thanks

Post by Aron »

thanks, its working now :)

One more problem:

It bans *!*~ident@host.com now... is there a way to strip the ~ if it's there?


edit: Nevermind, i found out (using [string trim] :D

Thanks for the great help man :)
The best way to start learning is to start helping.
User avatar
Dedan
Master
Posts: 260
Joined: Wed Jul 09, 2003 10:50 pm
Location: Memphis

Post by Dedan »

I hope this will help

Code: Select all

  set host [string trimleft $host "~"]
  set bmask *!*[lindex [split $host @] 0]@*"
  newchanban $chan $bmask $handle "$reason" $time 

8)
I once was an intelligent young man, now i am old and i can not remember who i was.
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

Dedan wrote:I hope this will help

Code: Select all

  set host [string trimleft $host "~"]
  set bmask *!*[lindex [split $host @] 0]@*"
  newchanban $chan $bmask $handle "$reason" $time 

8)
This bans *!*ident@*, he wanted to ban *!*ident@host and trim the "~".

AsoAron, you're welcome :)
Locked