| View previous topic :: View next topic |
| Author |
Message |
gamble27 Halfop
Joined: 05 Aug 2008 Posts: 71
|
Posted: Wed Mar 07, 2012 4:49 am Post subject: Auto Ban certain host |
|
|
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 |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Wed Mar 07, 2012 10:20 am Post subject: |
|
|
| Code: |
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.."
|
| Quote: |
* 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.  _________________ Once the game is over, the king and the pawn go back in the same box.
Last edited by caesar on Fri Mar 09, 2012 4:31 pm; edited 2 times in total |
|
| Back to top |
|
 |
gamble27 Halfop
Joined: 05 Aug 2008 Posts: 71
|
Posted: Wed Mar 07, 2012 12:07 pm Post subject: |
|
|
Thank you for your prompt response, i tested the above code and got following error :
| Quote: |
[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  |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Wed Mar 07, 2012 12:19 pm Post subject: |
|
|
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. |
|
| Back to top |
|
 |
gamble27 Halfop
Joined: 05 Aug 2008 Posts: 71
|
Posted: Wed Mar 07, 2012 12:57 pm Post subject: |
|
|
| Thanks again caesar, however the same error persist :< |
|
| Back to top |
|
 |
Fire-Fox Master

Joined: 23 Sep 2006 Posts: 270 Location: /dev/null
|
Posted: Wed Mar 07, 2012 8:06 pm Post subject: |
|
|
is it not
setudef flag ownerban ? _________________ GreatZ
Fire-Fox | Denmark
Scripts: Relay | Store Text | TvMaze |
|
| Back to top |
|
 |
gamble27 Halfop
Joined: 05 Aug 2008 Posts: 71
|
Posted: Thu Mar 08, 2012 2:44 am Post subject: |
|
|
| plz assist with the above problem, each time i load the tcl, the eggdrops gets disconnected.Thanks |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Thu Mar 08, 2012 6:09 am Post subject: |
|
|
@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. |
|
| Back to top |
|
 |
gamble27 Halfop
Joined: 05 Aug 2008 Posts: 71
|
Posted: Fri Mar 09, 2012 2:46 am Post subject: |
|
|
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 |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Fri Mar 09, 2012 3:54 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
gamble27 Halfop
Joined: 05 Aug 2008 Posts: 71
|
Posted: Fri Mar 09, 2012 7:56 am Post subject: |
|
|
| Sorry caesar i dont think i have it,never heard abt it before, where do i get that from mate ? Thanks for ure assistances. |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Fri Mar 09, 2012 8:41 am Post subject: |
|
|
If you are on a dcc chat/telnet with your eggdrop just type .status in there and you should see a line like mine:
| Quote: |
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. |
|
| Back to top |
|
 |
Fire-Fox Master

Joined: 23 Sep 2006 Posts: 270 Location: /dev/null
|
|
| Back to top |
|
 |
gamble27 Halfop
Joined: 05 Aug 2008 Posts: 71
|
Posted: Fri Mar 09, 2012 1:57 pm Post subject: |
|
|
| 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 |
|
| Back to top |
|
 |
gamble27 Halfop
Joined: 05 Aug 2008 Posts: 71
|
Posted: Fri Mar 09, 2012 2:11 pm Post subject: |
|
|
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  |
|
| Back to top |
|
 |
|