egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

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

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
mavericku
Halfop


Joined: 12 Jun 2005
Posts: 62
Location: somewhere in the world

PostPosted: Fri Feb 23, 2007 4:56 am    Post subject: .match *!*@ban.* as a pub command. [SOLVED] Reply with quote

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
View user's profile Send private message Visit poster's website MSN Messenger
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Fri Feb 23, 2007 7:19 am    Post subject: Reply with quote

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
View user's profile Send private message
user
 


Joined: 18 Mar 2003
Posts: 1452
Location: Norway

PostPosted: Fri Feb 23, 2007 9:06 am    Post subject: Reply with quote

rosc2112 wrote:
I tested this, it worked for me. YMMV

Indeed Smile 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 Razz)
_________________
Have you ever read "The Manual"?
Back to top
View user's profile Send private message
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Fri Feb 23, 2007 3:24 pm    Post subject: Reply with quote

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 Razz)

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 Smile

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
View user's profile Send private message
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Fri Feb 23, 2007 3:29 pm    Post subject: Reply with quote

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
View user's profile Send private message
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Fri Feb 23, 2007 3:34 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
mavericku
Halfop


Joined: 12 Jun 2005
Posts: 62
Location: somewhere in the world

PostPosted: Sat Feb 24, 2007 2:57 am    Post subject: Reply with quote

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

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
View user's profile Send private message Visit poster's website MSN Messenger
user
 


Joined: 18 Mar 2003
Posts: 1452
Location: Norway

PostPosted: Mon Feb 26, 2007 3:24 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber