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.

Who banned script [!whoban <mask>] - public cmd.

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
e
eXtremer
Op
Posts: 138
Joined: Wed May 07, 2008 5:33 am

Who banned script [!whoban <mask>] - public cmd.

Post by eXtremer »

Hi all.
I need a script that will find a ban in the banlist.
For example:

<Me> !whoban *!*@host.com
now the bot will msg me via notice
<Bot> *!*@host.com was banned by: Me Expire: expires in 2 days 3 hours 15 minutes. Reason: No Reason.

I have the !banlist cmd, but it shows me all the bans & if the banlist is big, it's really annoying !
Waiting for a reply.

P.S.: "banned by" must show the handle not the nick.

Thanks in advance.
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Code: Select all

# BanFIND by speechles
# no dolphins or walrus were harmed in the creation of this script ;)

bind pub - !bfind proc:banlist

proc proc:banlist {nick uhost hand chan text} {
   set text [lindex [split $text] 0]
   set mybans [banlist $chan]
   if {[llength $mybans] > 0} {
      set matches {}
      foreach ban $mybans {
         if {[string match -nocase $text [set bann [lindex $ban 0]]]} {
            set banby [lindex $ban 5]
            if {[set remain [expr [lindex $ban 2] - [unixtime]]] > 0} {
               set remain "in [duration $remain]"
            } else {
               set remain "Never."
            }
            if {[string match "" [set reason [lindex $ban 1]]]} {
               set reason "No reason given"
            }
            lappend matches [list "$bann" "$banby" "$remain" "$reason"]
         }
      }
      if {[llength $matches] > 0} {
         set i 1
         puthelp "NOTICE $nick :\002Matching bans\002: \037[llength $matches]\037 for $text on $chan:"
         foreach match $matches {
            puthelp "NOTICE $nick :\002$i\002\) [lindex $match 0] \002By:\002 [lindex $match 1] \002Expires:\002 [lindex $match 2] \002Reason:\002 [lindex $match 3]"
            incr i
         }
      } else {
         puthelp "NOTICE $nick :There are \002no bans\002 matching \037$text\037 found on $chan."
      }
   } else {
      puthelp "NOTICE $nick :There are \002no bans\002 placed for $chan. I cannot search for \037$text\037."
   }
}
Edited to correct minor problems mentioned below. Now functional 100% and elegantly ;)
Last edited by speechles on Fri Jul 18, 2008 9:05 pm, edited 8 times in total.
e
eXtremer
Op
Posts: 138
Joined: Wed May 07, 2008 5:33 am

Post by eXtremer »

speechles wrote:

Code: Select all

bind pub - !whoban proc:banlist

proc proc:banlist {nick uhost hand chan text} {
   set text [lindex [split $text] 0]
   set mybans [banlist $chan]
   if {[llength $mybans] > 0} {
      set matches {}
      foreach ban $mybans {
         if {[string match -nocase $text $ban]} {
            set bann [lindex $ban 0]
            set banby [nick2hand [lindex $ban 5] $chan]
            set remain [expr [lindex $ban 2] - [unixtime]]
            set reason [lindex $ban 1]
            if {$remain > 0} {
               set remain "in [duration $remain]."
            } {
               set remain "Never."
            }
            lappend matches [list "$bann" "$banby" "$remain" "$reason"]
         }
      }
      if {[llength $matches] > 0} {
         set i 1
         puthelp "NOTICE $nick :\002Matching bans\002: \037[llength $matches]\037 for $text on $chan:"
         foreach match $matches {
            puthelp "NOTICE $nick :\002$i\002\) [lindex $match 0] \002By:\002 [lindex $match 1] \002Expires:\002 [lindex $match 2] \002Reason:\002 [lindex $match 3]"
            incr i
         }
      } else {
         puthelp "NOTICE $nick :There are \002no bans\002 matching \037$text\037 found on $chan."
      }
   } else {
      puthelp "NOTICE $nick :There are \002no bans\002 placed for $chan. I cannot search for \037$text\037."
   }
}
thanks speechles, but the script is not working :(

Code: Select all

<eXtremer> !b *!*@test.com
*** Bot sets mode: +b *!*@test.com
-Bot- New mask added : *!*@test.com
<eXtremer> !find *!*@test.com
-Bot- There are no bans matching *!*@test.com found on #testbot.
What's wrong ?

P.S.: I replaced the "!whoban" cmd with "!find" command.
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

***dcc partyline***
<speechles> .+ban *!*@*host.com #test %365d0h0m year ban
<sp33chy> New #test ban: *!*@*host.com (year ban)
<speechles> .+ban nick!ident@host* #test goodbye
<sp33chy> New #test ban: nick!ident@host* (goodbye)

***in channel #test***
<speechles> !whoban *!*@*
-sp33chy- Matching bans: 2 for *!*@* on #test:
-sp33chy- 1) *!*@*host.com By: speechles Expires: in 52 weeks 23 hours 59 minutes 49 seconds. Reason: year ban
-sp33chy- 2) nick!ident@host* By: speechles Expires: Never. Reason: goodbye
Works just fine.. now. The problem stemmed from the fact I was trying to match against each ban sublist ([banlist $chan] is a list, with a sublist) with a string match (*slaps self hard*) which of course breaks a golden rule. You would've needed a * at the end of your query or it would've returned the no results found message. I've fixed this (USE THE EDITED CODE ABOVE I WROTE), it will work normally now and not under/over match as well as now obeys every golden rule of tcl. :)
Last edited by speechles on Fri Jul 18, 2008 3:48 pm, edited 1 time in total.
e
eXtremer
Op
Posts: 138
Joined: Wed May 07, 2008 5:33 am

Post by eXtremer »

speechles wrote:
***dcc partyline***
<speechles> .+ban *!*@*host.com #kangaroopocket %365d0h0m year ban
<sp33chy> New #test ban: *!*@*host.com (year ban)
<speechles> .+ban nick!ident@host* #test goodbye
<sp33chy> New #test ban: nick!ident@host* (goodbye)

***in channel #test***
<speechles> !whoban *!*@*
-sp33chy- Matching bans: 2 for *!*@* on #test:
-sp33chy- 1) *!*@*host.com By: speechles Expires: in 52 weeks 23 hours 59 minutes 49 seconds. Reason: year ban
-sp33chy- 2) nick!ident@host* By: speechles Expires: Never. Reason: goodbye
Works just fine. Don't know what you've done to break it. This will ONLY list eggdrop internal bans. If it's setting the ban in the channel, or via X/chanserv, yeah, this will not work. If for eggdrop's internal ban list ONLY.

Perhaps that ban script you have isn't using eggdrops internal ban system, and instead just placing bans onto the channel with no rhyme or reason?

Also "-Bot- There are no bans matching *!*@test.com found on #testbot."
This indicates there are bans on the channel, just none matching what your searching. Try instead !find *!*@* so you can see ALL bans for that channel. Then you can see that this indeed does work.
Look:

Channel:

Code: Select all

<eXtremer> !b *!*@host.com 0 bye 
*** Bot sets mode: +b *!*@host.com
-Bot- New mask added : *!*@test.com 

<eXtremer> !find *!*@host.com
-Bot- There are no bans matching *!*@host.com found on #testbot.
if *!*@* it works

Code: Select all

<eXtremer> !find *!*@*
-Bot- Matching bans: 1 for *!*@* on #testbot:
-Bot- 1) *!*@host.com By: eXtremer Expires: Never. Reason: bye 
DCC:

Code: Select all

.+ban *!*@mail.com #testbot 1 go
[17:26] #eXtremer# (#Clas) +ban *!*@mail.com #testbot (1 go)
New #testbot ban: *!*@mail.com (1 go)

Code: Select all

<eXtremer> !find *!*@mail.com
-Bot- There are no bans matching *!*@mail.com found on #testbot.
I don't really understand...
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

I edited that post too late I see. Do you see now? Use the edited code I originally posted. It will work correctly now. Enjoy. Long live dolphins and walruses.
Last edited by speechles on Fri Jul 18, 2008 3:48 pm, edited 1 time in total.
e
eXtremer
Op
Posts: 138
Joined: Wed May 07, 2008 5:33 am

Post by eXtremer »

speechles wrote:
speechles wrote:
***dcc partyline***
<speechles> .+ban *!*@*host.com #kangaroopocket %365d0h0m year ban
<sp33chy> New #test ban: *!*@*host.com (year ban)
<speechles> .+ban nick!ident@host* #test goodbye
<sp33chy> New #test ban: nick!ident@host* (goodbye)

***in channel #test***
<speechles> !whoban *!*@*
-sp33chy- Matching bans: 2 for *!*@* on #test:
-sp33chy- 1) *!*@*host.com By: speechles Expires: in 52 weeks 23 hours 59 minutes 49 seconds. Reason: year ban
-sp33chy- 2) nick!ident@host* By: speechles Expires: Never. Reason: goodbye
Works just fine.. now. The problem stemmed from the fact I was trying to match against each ban sublist ([banlist $chan] is a list, with a sublist) with a string match (*slaps self hard*) which of course breaks a golden rule. You would've needed a * at the end of your query or it would've returned the no results found message. I've fixed this (USE THE EDITED CODE ABOVE I WROTE), it will work normally now and not under/over match as well as now obeys every golden rule of tcl. :)
I edited that post too late I see. Do you see now? Use the edited code I originally posted. It will work correctly now. Enjoy. Long live dolphins and walruses.
Yes, ok speechles I'll overwrite the code, thanks again ;)_
Post Reply