File: userinfo1.0.tcl

package info (click to toggle)
eggdrop 1.3.19-1
  • links: PTS
  • area: main
  • in suites: slink
  • size: 2,248 kB
  • ctags: 3,501
  • sloc: ansic: 38,705; tcl: 1,411; makefile: 524; sh: 487
file content (218 lines) | stat: -rwxr-xr-x 6,305 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
#
# userinfo.tcl v1.02 for Eggdrop 1.1.6 and higher 
#			Scott G. Taylor -- ButchBub!staylor@mrynet.com
#
# V1.00	     ButchBub	  14 July      1997  Original release.  Based on
#						whois.tcl "URL" commands.
# v1.01      Beldin       11 November  1997  1.3 only version
# v1.02      Kirk         19 June      1998  extremely small fixes
#
# TO USE:  o	Set the desired userinfo field keywords to the 
#		`userinfo-fields' line below where indicated.
#	   o	Load this script on a 1.1.6 or later Eggdrop bot.
#	   o	Begin having users save the desired information.  If you
#		chose to add the default "IRL" field, they just use
#		the IRC command: /MSG <botnick> irl Joe Blow.
#	   o	See the new information now appear with the whois command.
#
# This script enhances the `whois' output utilising the `whois-fields'
# option of eggdrop 1.1-grant and later versions.  It adds the functionality
# of whois.tcl used in pre-1.1-grant versions.
#
# The fields desired to be maintained in the userfile `xtra' information
# should be put in `userinfo-fields'.  This is different than the Eggdrop
# configuration variable `whois-fields' in that this script will add the
# commands to change these fields.   It will also add these desired fields
# to the `whois-fields' itself, so do not define them there as well.  The
# fields added in `userinfo-fields' will be converted to upper case for
# aesthetics in the `whois' command output.
#
# The commands that will be added to the running eggdrop are:
#  (<info> will be the respective userfile field added in `userinfo-fields')
#
#	TYPE	COMMAND		USAGE
#	======	==============	========================================
#	msg	<info>		To change your <info> via /MSG.
#	dcc	.<info>		To change your <info> via DCC.
#	dcc	.ch<info>	To change someone else's <info> via DCC.
#
# Currently supported fields and commands:
#
#	FIELD	USAGE
#	=====	=====================
#	URL	WWW page URL
#	IRL	In Real Life name
#	BF	Boyfriend
#	GF	Girlfriend
#	DOB     Birthday (Date Of Birth)
#       EMAIL   Email address

################################
# Set your desired fields here #
################################

set userinfo-fields "URL BF GF IRL EMAIL DOB"

# This script's identification

set userinfover "Userinfo v1.02"

# This script is NOT for pre-1.3.0 versions.

if {![info exists numversion] || ($numversion < 1030000)} {
    if {[string range $version 0 2] != "1.3"} {
    putlog "*** Can't load $userinfover -- At least Eggdrop v1.3.0 required"
    return 0
  }
}

# Make sure we don't bail because whois-fields isn't set

if {![info exists whois-fields]} {
  set whois-fields ""
}

# Add only the user-xtra fields not already in the whois-fields list

foreach f1 [split ${userinfo-fields}] {
  set ffound 0
  foreach f2 [split ${whois-fields}] {
    if {[string tolower $f1] == [string tolower $f2]} { 
      set ffound 1
      break
    }
  }
  if {$ffound == 0} {
    append whois-fields " " $f1
  }
}

# Run through the list of user info fields and bind their commands

foreach field [split ${userinfo-fields}] {
  bind msg - $field msg_setuserinfo
  bind dcc - $field dcc_setuserinfo
  bind dcc m ch$field dcc_chuserinfo
}

# This is the `/msg <info>' procedure

proc msg_setuserinfo {nick uhost hand arg} {
  global lastbind quiet-reject

  set userinfo [string toupper $lastbind]

  set arg [cleanarg $arg]
  set ignore 1
  foreach channel [channels] {
    if {[onchan $nick $channel]} {
      set ignore 0
    }
  }
  if {$ignore} {
    return 0
  }   
   if {$hand != "*"} {
      if {$arg != ""} {
         if {[string tolower $arg] == "none"} {
            putserv "NOTICE $nick :Removed your $userinfo line."
            setuser $hand XTRA $userinfo ""
         } {
            putserv "NOTICE $nick :Now: $arg"
            setuser $hand XTRA $userinfo "[string range $arg 0 159]"
         }
      } {
         if {[getuser $hand XTRA $userinfo] == ""} {
            putserv "NOTICE $nick :You have no $userinfo set."
         } {
            putserv "NOTICE $nick :Now: [getuser $hand XTRA $userinfo]"
         }
      }
   } else {
      if {${quiet-reject} != 1} {
        putserv 
          "NOTICE $nick :Ymust be a registered user to use this feature."
      }
   }
   return 1
}

# This is the dcc '.<info>' procedure.

proc dcc_setuserinfo {hand idx arg} {
global lastbind
  set userinfo [string toupper $lastbind]
  set arg [cleanarg $arg]
  if {$arg != ""} {
    if {[string tolower $arg] == "none"} {
      putdcc $idx "Removed your $userinfo line."
      setuser $hand XTRA $userinfo ""
    } {
      putdcc $idx "Now: $arg"
      setuser $hand XTRA $userinfo "[string range $arg 0 159]"
    }
  } {
    if {[getuser $hand XTRA $userinfo] == ""} {
      putdcc $idx "You have no $userinfo set."
    } {
      putdcc $idx "Currently: [getuser $hand XTRA $userinfo]"
    }
  }
  return 1
}

# This is the DCC `.ch<info>' procedure

proc dcc_chuserinfo {hand idx arg} {
global lastbind
  set userinfo [string toupper [string range $lastbind 2 end]]
  set arg [cleanarg $arg]
  if {[llength $arg] == 0} {
    putdcc $idx "syntax: .ch[string tolower $userinfo] <who> \[<[string tolower $userinfo]>|NONE\]"
    return 0
  }
  set who [lindex $arg 0]
  if {![validuser $who]} {
    putdcc $idx "$who is not a valid user."
    return 0
  }
  if {[llength $arg] == 1} {
    set info ""
  } {
    set info [lindex $arg 1]
  }
  if {$info != ""} {
    if {[string tolower $info] == "none"} {
      putdcc $idx "Removed $who's $userinfo line."
      setuser $who XTRA $userinfo ""
      putcmdlog "$userinfo for $who removed by $hand"
    } {
      putdcc $idx "Now: $info"
      setuser $who XTRA $userinfo "$info"
      putcmdlog "$userinfo for $who set to \"$info\" by $hand"
    }
  } {
    if {[getuser $who $userinfo] == ""} {
      putdcc $idx "$who has no $userinfo set."
    } {
      putdcc $idx "Currently: [getuser $who $userinfo]"
    }
  }
  return 0
}

proc cleanarg {arg} {
  set response ""
  for {set i 0} {$i < [string length $arg]} {incr i} {
    set char [string index $arg $i]
    if {($char != "\12") && ($char != "\15")} {
      append response $char
    }
  }
  return $response
}

# Announce that we've loaded the script.

putlog "$userinfover by ButchBub loaded for: ${userinfo-fields}."
putlog "use '.help userinfo' for comands."