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.

.match *!*@ban.* as a pub command. [SOLVED]

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
User avatar
mavericku
Halfop
Posts: 62
Joined: Sun Jun 12, 2005 11:32 pm
Location: somewhere in the world
Contact:

.match *!*@ban.* as a pub command. [SOLVED]

Post by mavericku »

Hi Guys,


as the title says i'd like your help .
I'd like to make a pub command that will search the bans list.

Example

.match *!*@172.21.*

Bot : Matching bans found 20, showing 5
bot : 1 . ban , banned by
bot : 2 . ban , banned by .
and so on.

Can you please lend me a hand here...

Mave
Last edited by mavericku on Sat Feb 24, 2007 3:07 am, edited 1 time in total.
mavericku
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

banlist [channel]
Returns: a list of global bans, or, if a channel is specified, a
list of channel-specific bans. Each entry is a sublist containing:
hostmask, comment, expiration timestamp, time added, last time
active, and creator. The three timestamps are in unixtime format.
Module: channels


Just filter the output of the banlist command to match your desired search mask. You know how to do the pub bind.
Something like:

Code: Select all

bind pub - test proc:banlist
proc proc:banlist {nick uhost hand chan text} {
        set text [split $text];#always split input for safety :P
        set mybans [banlist $chan];set matches ""
        if {$mybans != ""} {
                foreach ban $mybans {
                        if {[lsearch -start -6 $ban $text] != -1} {
                                lappend matches "[lindex $ban 0] [lindex $ban 5]"
                        }
                }
                if {$matches != ""} {
                        set i 0
                        puthelp "PRIVMSG $chan :Matching bans found: [llength $matches]"
                        foreach match $matches {
                                incr i
                                puthelp "PRIVMSG $chan :$i: [lindex $match 0] banned by [lindex $match 1]"
                        }
                } else {
                        puthelp "PRIVMSG $chan :No bans matching [join $text] found on channel $chan."
                }
        } else {
                puthelp "PRIVMSG $chan :No bans for channel $chan."
        }
}
putlog "test.tcl loaded"
#-I_Really_hate-Word-Wrap!-######################################################################################
I tested this, it worked for me. YMMV
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

rosc2112 wrote:I tested this, it worked for me. YMMV
Indeed :) It worked because your search pattern had the same case as your bans and the masks/handles did not contain any brackets and braces.
1) You do case sensitive GLOB matching with IRC BAN as a pattern. (brackets have a special meaning in glob matching - case doesn't matter on irc)
2) lindex used on strings is bad (and I know you know this :P)
Have you ever read "The Manual"?
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

user wrote:
rosc2112 wrote:I tested this, it worked for me. YMMV
1) You do case sensitive GLOB matching with IRC BAN as a pattern. (brackets have a special meaning in glob matching - case doesn't matter on irc)
2) lindex used on strings is bad (and I know you know this :P)
I made the script the way it way requested. Mav knows enough to modify it if he wants it case-insensitive. And yeah I know it's not tcl-special char safe, but again, that's an exercise for Maverick :)

The results are lists aren't they? According to the [banlist] documentation, they are, and I used lappend to make the 'matches' list.
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

Hmm, I'm guessing you meant in the foreach vars, I should've used like:

foreach
  • $mybans and foreach
    • $matches.

      Is that what you mean?
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

user wrote:1) You do case sensitive GLOB matching with IRC BAN as a pattern. (brackets have a special meaning in glob matching - case doesn't matter on irc)
i.e. [hi] will match either 'h' or 'i' and will not match '[hi]' (using string match).
User avatar
mavericku
Halfop
Posts: 62
Joined: Sun Jun 12, 2005 11:32 pm
Location: somewhere in the world
Contact:

Post by mavericku »

Thanks rosc2112 for this, it is exactly what i requested. I'll handle the rest :D

L.E.

Oh on more question ..i've tried the sendftp.tcl in the tcl archive but it doesn't work, i've searched the forum and i found another post with a dcc .sendfile command, tried that but same result ..

it just freezes, and i've tried it on 2 different servers.
mavericku
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

rosc2112 wrote:Hmm, I'm guessing you meant in the foreach vars, I should've used
Nope. They would never cause an error because the variable names contain no special characters...
rosc2112 wrote:

Code: Select all

# the elements you append to the matches list are strings...
lappend matches "[lindex $ban 0] [lindex $ban 5]"
# ...but later you treat them like lists...
foreach match $matches {
    ... [lindex $match 0] ... [lindex $match 1]"
}
To fix it, you could just lappend them both as separate elements and do

Code: Select all

foreach {ban by} {...}
or

Code: Select all

lappend matches [list [lindex $ban 0] [lindex $ban 5]]
and keep the rest like it is.
Have you ever read "The Manual"?
Post Reply