/[cvs]/eggdrop1.6/scripts/dccwhois.tcl
ViewVC logotype

Annotation of /eggdrop1.6/scripts/dccwhois.tcl

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (hide annotations) (download) (as text)
Thu Jan 22 03:12:45 2009 UTC (10 years, 8 months ago) by tothwolf
Branch: MAIN
CVS Tags: HEAD
File MIME type: application/x-tcl
Added scripts/dccwhois.tcl Tcl script. This script enhances the built-in dcc
'.whois' command to allow all users to '.whois' their own handle.

1 tothwolf 1.1 ###############################################################################
2     ##
3     ## dccwhois.tcl - Enhanced '.whois' dcc command for Eggdrop
4     ## Copyright (C) 2009 Tothwolf <tothwolf@techmonkeys.org>
5     ##
6     ## This program is free software; you can redistribute it and/or modify
7     ## it under the terms of the GNU General Public License as published by
8     ## the Free Software Foundation; either version 2 of the License, or
9     ## (at your option) any later version.
10     ##
11     ## This program is distributed in the hope that it will be useful,
12     ## but WITHOUT ANY WARRANTY; without even the implied warranty of
13     ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14     ## GNU General Public License for more details.
15     ##
16     ## You should have received a copy of the GNU General Public License
17     ## along with this program; if not, write to the Free Software
18     ## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19     ##
20     ###############################################################################
21     ##
22     ## $Id$
23     ##
24     ###############################################################################
25     ##
26     ## Description:
27     ##
28     ## This script enhances Eggdrop's built-in dcc '.whois' command to allow all
29     ## users to '.whois' their own handle.
30     ##
31     ## Users without the correct flags who attempt to '.whois' other users will
32     ## instead see the message: "You do not have access to whois handles other
33     ## than your own."
34     ##
35     ## To load this script, add a source command to your bot's config file:
36     ##
37     ## source scripts/dccwhois.tcl
38     ##
39     ## This script stores and checks against the flags that are used for
40     ## Eggdrop's built-in dcc '.whois' command at load time. If you wish to use
41     ## flags other than the default "to|o", etc, you should unbind and rebind
42     ## the built-in '.whois' command in your bot's config file before loading
43     ## this script.
44     ##
45     ## Example of how to rebind Eggdrop's built-in '.whois' command:
46     ##
47     ## unbind dcc to|o whois *dcc:whois
48     ## bind dcc to|m whois *dcc:whois
49     ##
50     ## Note: if you modify the default flags for '.whois' you may also wish to
51     ## modify the defaults for '.match'.
52     ##
53     ###############################################################################
54     ##
55     ## This script has no settings and does not require any configuration.
56     ## You should not need to edit anything below.
57     ##
58     ###############################################################################
59    
60    
61     # This script should not be used with Eggdrop versions 1.6.16 - 1.6.19.
62     catch {set numversion}
63     if {([info exists numversion]) &&
64     ($numversion >= 1061600) && ($numversion <= 1061900)} then {
65     putlog "Error: dccwhois.tcl is not compatible with Eggdrop version [lindex $version 0]. Please upgrade to 1.6.20 or later."
66     return
67     }
68    
69    
70     #
71     # dcc:whois --
72     #
73     # Wrapper proc command for Eggdrop's built-in *dcc:whois
74     #
75     # Arguments:
76     # hand - handle of user who used this command
77     # idx - dcc idx of user who used this command
78     # arg - arguments passed to this command
79     #
80     # Results:
81     # Calls Eggdrop's built-in *dcc:whois with the given arguments if user has
82     # access, otherwise tells the user they don't have access.
83     #
84     proc dcc:whois {hand idx arg} {
85     global dccwhois_flags
86    
87     set arg [split [string trimright $arg]]
88     set who [lindex $arg 0]
89    
90     # Did user gave a handle other than their own?
91     if {([string compare "" $who]) &&
92     ([string compare [string toupper $hand] [string toupper $who]])} then {
93    
94     # Get user's current .console channel; check the same way Eggdrop does.
95     set chan [lindex [console $idx] 0]
96    
97     # User isn't allowed to '.whois' handles other than their own.
98     if {![matchattr $hand $dccwhois_flags $chan]} then {
99     putdcc $idx "You do not have access to whois handles other than your own."
100    
101     return 0
102     }
103     }
104    
105     # Call built-in whois command.
106     *dcc:whois $hand $idx $arg
107    
108     # Return 0 so we don't log command twice.
109     return 0
110     }
111    
112    
113     #
114     # init_dccwhois --
115     #
116     # Initialize dccwhois script-specific code when script is loaded
117     #
118     # Arguments:
119     # (none)
120     #
121     # Results:
122     # Set up command bindings and store command access flags.
123     #
124     proc init_dccwhois {} {
125     global dccwhois_flags
126    
127     putlog "Loading dccwhois.tcl..."
128    
129     # Sanity check...
130     if {[array exists dccwhois_flags]} then {
131     array unset dccwhois_flags
132     }
133    
134     # Search binds for built-in '*dcc:whois' and loop over each bind in list
135     foreach bind [binds "\\*dcc:whois"] {
136    
137     # dcc to|o whois 0 *dcc:whois
138     foreach {type flags name count command} $bind {break}
139    
140     # We only want to unbind dcc '.whois'
141     if {[string compare $name "whois"]} then {
142     continue
143     }
144    
145     # Store $flags so we can reuse them later
146     set dccwhois_flags $flags
147    
148     # Unbind built-in *dcc:whois
149     unbind $type $flags $name $command
150     }
151    
152     # Make sure $dccwhois_flags exists and isn't empty,
153     # otherwise set to Eggdrop's default "to|o"
154     if {(![info exists dccwhois_flags]) ||
155     (![string compare "" $dccwhois_flags])} then {
156     set dccwhois_flags "to|o"
157     }
158    
159     # Add bind for dcc:whois wrapper proc
160     bind dcc -|- whois dcc:whois
161    
162     putlog "Loaded dccwhois.tcl"
163    
164     return
165     }
166    
167     init_dccwhois

webmaster@eggheads.org
ViewVC Help
Powered by ViewVC 1.1.23