| View previous topic :: View next topic |
| Author |
Message |
mavericku Halfop

Joined: 12 Jun 2005 Posts: 62 Location: somewhere in the world
|
Posted: Fri Feb 23, 2007 4:56 am Post subject: .match *!*@ban.* as a pub command. [SOLVED] |
|
|
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 _________________ mavericku
Last edited by mavericku on Sat Feb 24, 2007 3:07 am; edited 1 time in total |
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
Posted: Fri Feb 23, 2007 7:19 am Post subject: |
|
|
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: |
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 |
|
| Back to top |
|
 |
user

Joined: 18 Mar 2003 Posts: 1452 Location: Norway
|
Posted: Fri Feb 23, 2007 9:06 am Post subject: |
|
|
| 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 ) _________________ Have you ever read "The Manual"? |
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
Posted: Fri Feb 23, 2007 3:24 pm Post subject: |
|
|
| 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 ) |
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. |
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
Posted: Fri Feb 23, 2007 3:29 pm Post subject: |
|
|
Hmm, I'm guessing you meant in the foreach vars, I should've used like:
foreach [list ban] $mybans and foreach [list match] $matches.
Is that what you mean? |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Fri Feb 23, 2007 3:34 pm Post subject: |
|
|
| 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). _________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
mavericku Halfop

Joined: 12 Jun 2005 Posts: 62 Location: somewhere in the world
|
Posted: Sat Feb 24, 2007 2:57 am Post subject: |
|
|
Thanks rosc2112 for this, it is exactly what i requested. I'll handle the rest
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 |
|
| Back to top |
|
 |
user

Joined: 18 Mar 2003 Posts: 1452 Location: Norway
|
Posted: Mon Feb 26, 2007 3:24 pm Post subject: |
|
|
| 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: |
# 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: | | foreach {ban by} {...} | or | Code: | | lappend matches [list [lindex $ban 0] [lindex $ban 5]] | and keep the rest like it is. _________________ Have you ever read "The Manual"? |
|
| Back to top |
|
 |
|