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.

Auto Ban certain host

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
g
gamble27
Halfop
Posts: 71
Joined: Tue Aug 05, 2008 7:51 am

Auto Ban certain host

Post by gamble27 »

im looking for a small tcl which enables the owner to ban a host permanently using normal ban instead of using sticky function in eggdrop. Reason being is that i want to only ban (no kick), tht is why i cant use newchanban function in eggdrop. I jus want to ban certain host without kicking them ie :

!ipban *!*@test <-- eggdrop will ban it permanently and it will not be affected by dynamic bans too ( only ban no kick ). Even if any ops removes it, it will auto ban it.

Any help will be greatly appreciated.Thanks
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Code: Select all

namespace eval ownerbans {
  setudef str ownerbans

  bind pub n|n !ipban [namespace current]::banAdd
  bind pub n|n !ipunban [namespace current]::banDel
  bind pub n|n !iplist [namespace current]::banList
  bind mode - "% -b" [namespace current]::checkBan

  proc banAdd {nick uhost handle chan text} {
    if {[scan $text %s ban] != 1} {
      putsev "NOTICE $nick :Usage: !ipban <mask>"
      } else {
      if {[string match -nocase $ban $::botname]} {
        putsev "NOTICE $nick :Sorry, can't ban $ban cos it matches my host."
        } else {
        if {$ban ni [channel get $chan ownerbans]} {
          set tmp [channel get $chan ownerbans]
          lappend tmp $ban
          channel set $chan ownerbans $tmp
          pushmode $chan +b $ban
          putserv "NOTICE $nick :Mask $ban has been added to the owner bans list."
          } else {
          putserv "NOTICE $nick :Sorry, mask $ban already exists in the owner bans list."
        }
      }
    }
  }

  proc checkBan {nick host handle chan mode ban} {
    if {[isbotnick $nick]} return
    if {$ban in [channel get $chan ownerbans]} {
      if {![botisop $chan]} return
      pushmode $chan +b $ban
    }
  }

  proc banList {nick uhost handle chan text} {
    set bans [channel get $chan ownerbans]
    if {![llength $bans]} {
      putserv "NOTICE $nick :Sorry, owner bans list is empty."
      } else {
      # Show only 15 bans per line.
      while {[llength $bans] != 0} {
        putserv "NOTICE $nick :Owner bans: [join [lrange $bans 0 14]]"
        set bans [lrange $bans 15 end]
      }
    }
  }

  proc banDel {nick uhost handle chan text} {
    if {[scan $text %s ban] != 1} {
      putserv "NOTICE $nick :Usage: !ipunban <mask>"
      } else {
      set bans [channel get $chan ownerbans]
      if {$ban in $bans} {
        set pos [lsearch $bans $ban]
        channel set $chan ownerbans [lreplace $bans $pos $pos]
        putserv "NOTICE $nick :Removed $ban ban from the owner bans list."
        } else {
        putserv "NOTICE $nick :Sorry, couldn't find $ban ban in the owner bans list."
      }
    }
  }
}

putlog "ownerbans.tcl loaded.." 
* caesar sets mode: +b *!*@another.com
<@caesar> !ipban *!*@foo.com
-bot- Mask *!*@foo.com has been added to the owner bans list.
* bot sets mode: +b *!*@foo.com
<@caesar> !ipban *!*@test.com
-bot- Mask *!*@test.com has been added to the owner bans list.
* bot sets mode: +b *!*@test.com
* caesar sets mode: -bbb *!*@another.com *!*@foo.com *!*@test.com
* bot sets mode: +bb *!*@foo.com *!*@test.com

<@caesar> !ipunban *!*@foo.com
-bot- Removed *!*@foo.com ban from the owner bans list.
* caesar sets mode: -b *!*@foo.com
... nothing happens.

<@caesar> !ipunban *!*@foo.com
-bot- Sorry, couldn't find *!*@foo.com ban in the owner bans list.

I had set two bans per line:
<@caesar> !iplist
-bot- Owner bans: *!*@test.com *!*@foo.com
-bot- Owner bans: *!*@another.com
You will need TCL 8.5+ for this to work.

Edit: Fixed typos. :)
Last edited by caesar on Fri Mar 09, 2012 4:31 pm, edited 2 times in total.
Once the game is over, the king and the pawn go back in the same box.
g
gamble27
Halfop
Posts: 71
Joined: Tue Aug 05, 2008 7:51 am

Post by gamble27 »

Thank you for your prompt response, i tested the above code and got following error :
[11:05:28] invalid command name " "
while executing
"   setudef str ownerbans "
(in namespace eval "::ownerbans" script line 2)
invoked from within
"namespace eval ownerbans {
   setudef str ownerbans

   bind pub n|n !ipban [namespace current]::banAdd
   bind pub n|n !ipunban [namespace c..."
(file "scripts/ban.tcl" line 1)
eggdrop could not start as there was such error in the code.

Thanks :)
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

That's weird.. I guess is due to my way of aligning the code, meaning inserted a TAB. Anyway, I've updated the above code. Give it a try again.
Once the game is over, the king and the pawn go back in the same box.
g
gamble27
Halfop
Posts: 71
Joined: Tue Aug 05, 2008 7:51 am

Post by gamble27 »

Thanks again caesar, however the same error persist :<
User avatar
Fire-Fox
Master
Posts: 299
Joined: Sat Sep 23, 2006 9:01 pm
Location: /dev/null

Post by Fire-Fox »

is it not

setudef flag ownerban ?
GreatZ
Fire-Fox | Denmark

Scripts: Relay | Store Text | TvMaze
g
gamble27
Halfop
Posts: 71
Joined: Tue Aug 05, 2008 7:51 am

Post by gamble27 »

plz assist with the above problem, each time i load the tcl, the eggdrops gets disconnected.Thanks
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

@Fire-Fox : no, is str as in string.

@gamble27 : I copy/pasted the above code in a text editor then loaded file that on my bot without any issues. What version of eggdrop do you have?
Once the game is over, the king and the pawn go back in the same box.
g
gamble27
Halfop
Posts: 71
Joined: Tue Aug 05, 2008 7:51 am

Post by gamble27 »

hey caesar, thanks for ure help. im on eggdrop 1.6.20 i loaded the tcl and when i tried to add ip i received following error.

[09:42:37] Tcl error [::ownerbans::banAdd]: syntax error in expression "$ban ni [channel get $chan ownerbans]": extra tokens at end of expression
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Do you have TCL version 8.5 or above?
Once the game is over, the king and the pawn go back in the same box.
g
gamble27
Halfop
Posts: 71
Joined: Tue Aug 05, 2008 7:51 am

Post by gamble27 »

Sorry caesar i dont think i have it,never heard abt it before, where do i get that from mate ? Thanks for ure assistances.
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

If you are on a dcc chat/telnet with your eggdrop just type .status in there and you should see a line like mine:
Tcl version: 8.5.8 (header version 8.5.8)
Once the game is over, the king and the pawn go back in the same box.
User avatar
Fire-Fox
Master
Posts: 299
Joined: Sat Sep 23, 2006 9:01 pm
Location: /dev/null

Post by Fire-Fox »

GreatZ
Fire-Fox | Denmark

Scripts: Relay | Store Text | TvMaze
g
gamble27
Halfop
Posts: 71
Joined: Tue Aug 05, 2008 7:51 am

Post by gamble27 »

hey caesar and firefox, thanks for the help. my status shows im on Tcl version: 8.5.9 (header version 8.5.9) so i meet the requirement,however i still can use the ip ban and the same error as above reflects.thanks
g
gamble27
Halfop
Posts: 71
Joined: Tue Aug 05, 2008 7:51 am

Post by gamble27 »

Ok its working now its banning however its not keepin it sticky, an aop removes the ban and it doesnt enforce it again.i receive following error in dcc

Tcl error [::ownerbans::banAdd]: invalid command name "putsev"
Tcl error [::ownerbans::checkBan]: can't read "target": no such variable

when i type !ipban it does ban but error no 1 appears. when the ban is removed from ban list the eggdrop doesnt enforce it again.

Thanks again for the help :)
Post Reply