source: tags/mode_tracking/variable.lisp

Last change on this file was 88, checked in by Erik Huelsmann, 20 years ago

Implement MODE tracking.

  • TODO: Remove MODE updating item.
  • doc/user-guide.txt: Add section about modes.
  • package.lisp: Export new symbols.
  • variable.lisp (*default-isupport-CHANMODES*, *default-isupport-PREFIX*): New. (*default-isupport-values*): Add modes described by the RFC and declare them the default (minimal set). (mode-description): New. Structure to describe characteristics of mode arguments sent by the server. (*default-char-to-channel-modes-map*,

*char-to-user-modes-map*): New. Assoc lists to map characters to names.

  • utility.lisp (parse-isupport-prefix-argument): New. Returns the prefix and mode argument parts of the PREFIX RPL_ISUPPORT parameter. (nick-prefixes-from-isupport): New. Returns a plist associating mode prefixes with mode character designations. (chanmode-descs-from-isupport): New. Returns a list of mode-description structures for use with auto-creation of mode objects. (do-property-list): New. Macro to walk a property list like dolist. (parse-mode-arguments): New. Parses mode arguments given a connection object and target and translates those into a list of mode change instructions.
  • protocol.lisp (irc-mode): New. Abstract super class. Derivatives used to store mode values. (set-mode-value, unset-mode-value, reset-mode-value, has-value-p): New. Methods for irc-mode and its derivatives. (single-value-mode, list-value-mode): New. Classes implementing two types of value-holding mode-storage. (connection:channel-mode-descriptions): New. Slot in which the channel mode descriptions for the connection get stored. (connection:nick-prefixes): New. Slot which stores a plist associating RPL_NAMREPLY prefixes with mode characters. (connection:user-mode-descriptions): New. Slot which stores user modes like channel-mode-descriptions does for channels. (add-default-hooks): Add hook for irc-mode-message. (channel:modes): Change initialization to signal the value held will be of LIST type. (mode-name-from-char): New. Translates a mode character into an internal 'name': symbol. (mode-description): New. Retrieves a mode-description record from the given connection of a given mode name. (get-mode, set-mode, unset-mode, remove-mode): New. These provide operations on both channel and user modes. (has-mode-p, has-mode-value-p): New. This must be obvious. (remove-users): Also remove references to all users from any properties which carry the :user value-type. (make-mode): New. Automatically create mode object for the given mode to be added to the given target (user/channel). (user:modes): New. Slot to hold modes just like there is one on the channel class. (remove-user): Same as remove-user, but for the given user only.
  • event.lisp (default-hook [irc-rpl_isupport-message]): Set new channel-mode-descriptions and nick-prefixes slots. (default-hook [irc-rpl_namreply-message]): Set mode fields based on prefixes passed in the reply. (default-hook [irc-mode-message]): Set or unset channel and user modes upon reception of server notification.
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 8.8 KB
Line 
1;;;; $Id: variable.lisp 88 2005-03-20 16:55:43Z ehuelsmann $
2;;;; $Source$
3
4;;;; See the LICENSE file for licensing information.
5
6(in-package :irc)
7
8(defvar *debug-p* nil)
9(defvar *debug-stream* t)
10
11(defconstant +soh+ #.(code-char 1))
12
13(defparameter *version* "0.1.0")
14(defparameter *ctcp-version*
15  (format nil "CL IRC library, cl-irc:~A:~A ~A"
16          *version* (machine-type) (machine-version)))
17
18(defparameter *download-host* "ftp://common-lisp.net/")
19(defparameter *download-directory* "/pub/project/cl-irc/")
20(defparameter *download-file*
21  (format nil "cl-irc-~A.tar.gz" *version*))
22
23(defvar *default-nickname* "cl-irc")
24(defvar *default-irc-server* "irc.freenode.net")
25(defvar *default-irc-server-port* 6667)
26(defvar *default-quit-message*
27  "Common Lisp IRC library - http://common-lisp.net/project/cl-irc")
28
29(defparameter *default-isupport-CHANMODES*
30  "beI,kO,l,aimnpqsrt")
31(defparameter *default-isupport-PREFIX*
32  "(ov)@+")
33
34(defparameter *default-isupport-values*
35  `(("CASEMAPPING" "rfc1459")
36    ("CHANMODES" ,*default-isupport-CHANMODES*)
37    ("CHANNELLEN" "200")
38    ("CHANTYPES" "#&")
39    ("MODES" "3")
40    ("NICKLEN" "9")
41    ("PREFIX" ,*default-isupport-PREFIX*)
42    ("TARGMAX")))
43
44
45(defvar *dcc-connections* nil)
46
47(defstruct (mode-description (:conc-name "MODE-DESC-"))
48  (char nil)
49  (symbol nil)
50  (param-on-set-p nil)
51  (param-on-unset-p nil)
52  (nick-param-p nil)
53  (class 'single-value-mode))
54
55
56(defparameter *default-char-to-channel-modes-map*
57  '(
58    ;; these modes don't take parameters
59    (#\a . :anonymous)
60    (#\i . :invite-only)
61    (#\m . :moderated)
62    (#\n . :no-external)
63    (#\q . :quiet)
64    (#\s . :secret)
65    (#\r . :reop)
66    (#\t . :op-only-topic)
67
68    ;; these modes take a user parameter
69    (#\O . :channel-creator)
70    (#\o . :channel-operator)
71    (#\v . :voice)
72
73    ;; these modes take a parameter other than a user
74    (#\l . :limit)
75    (#\k . :key)
76    (#\b . :ban)
77    (#\e . :ban-except)
78    (#\I . :invite-except)))
79
80(defparameter *char-to-user-modes-map*
81  '((#\a . :away)
82    (#\i . :invisible)
83    (#\w . :receive-wallops)
84    (#\s . :server-notices)
85    (#\r . :restricted-connection)
86    (#\o . :remote-operator)
87    (#\O . :local-operator)))
88
89(defparameter *reply-names*
90  '((1 :rpl_welcome)
91    (2 :rpl_yourhost)
92    (3 :rpl_created)
93    (4 :rpl_myinfo)
94    (5 :rpl_isupport) ;; The RFC was wrong to define RPL_BOUNCE here,
95     ;; see http://www.irc.org/tech_docs/draft-brocklesby-irc-isupport-03.txt
96    (10 :rpl_bounce)
97    (15 :rpl_map) ; From ircd 2.11 source
98    (17 :rpl_mapend) ; From ircd 2.11 source
99    (18 :rpl_mapstart) ; From ircd 2.11 source
100    (20 :rpl_hello) ; From ircd 2.11 source
101    (42 :rpl_yourid) ; From ircd 2.11 source
102    (43 :rpl_savenick) ; From ircd 2.11 source
103    (200 :rpl_tracelink)
104    (201 :rpl_traceconnecting)
105    (202 :rpl_tracehandshake)
106    (203 :rpl_traceunknown)
107    (204 :rpl_traceoperator)
108    (205 :rpl_traceuser)
109    (206 :rpl_traceserver)
110    (207 :rpl_traceservice)
111    (208 :rpl_tracenewtype)
112    (209 :rpl_traceclass)
113    (210 :rpl_tracereconnect)
114    (211 :rpl_statslinkinfo)
115    (212 :rpl_statscommands)
116    (213 :rpl_statscline)
117    (214 :rpl_statsnline)
118    (215 :rpl_statsiline)
119    (216 :rpl_statskline)
120    (217 :rpl_statsqline)
121    (218 :rpl_statsyline)
122    (219 :rpl_endofstats)
123    (221 :rpl_umodeis)
124    (225 :rpl_statsdline) ; Seen in dancer ircd source
125    (227 :rpl_option) ; Seen in dancer ircd source
126    (228 :rpl_endoptions) ; Seen in dancer ircd source
127    (231 :rpl_serviceinfo)
128    (232 :rpl_endofservices)
129    (233 :rpl_service)
130    (234 :rpl_servlist)
131    (235 :rpl_servlistend)
132    (240 :rpl_statsvline)
133    (241 :rpl_statslline)
134    (242 :rpl_statsuptime)
135    (243 :rpl_statsonline)
136    (244 :rpl_statshline)
137    (245 :rpl_statssline) ; The RFC says 244 but I believe that was a typo.
138    (246 :rpl_statsping)
139    (247 :rpl_statsbline)
140    (248 :rpl_statsuline) ; Seen in dancer ircd source
141    (249 :rpl_statsdebug) ; Seen in dancer ircd source
142    (250 :rpl_statsdline)
143    (251 :rpl_luserclient)
144    (252 :rpl_luserop)
145    (253 :rpl_luserunknown)
146    (254 :rpl_luserchannels)
147    (255 :rpl_luserme)
148    (256 :rpl_adminme)
149    (257 :rpl_adminloc1)
150    (258 :rpl_adminloc2)
151    (259 :rpl_adminemail)
152    (261 :rpl_tracelog)
153    (262 :rpl_traceend)
154    (263 :rpl_tryagain)
155    (265 :rpl_localusers) ; Seen in dancer ircd source
156    (266 :rpl_globalusers) ; Seen in dancer ircd source
157    (268 :rpl_mode) ; Seen in dancer ircd source
158    (269 :rpl_endmode) ; Seen in dancer ircd source
159    (271 :rpl_sitelist) ; Seen in dancer ircd source
160    (272 :rpl_endsitelist) ; Seen in dancer ircd source
161    (290 :rpl_clientcapab) ; Seen in dancer ircd source
162    (292 :rpl_noservicehost)
163    (300 :rpl_none)
164    (301 :rpl_away)
165    (302 :rpl_userhost)
166    (303 :rpl_ison)
167    (304 :rpl_away)
168    (305 :rpl_unaway)
169    (306 :rpl_noaway)
170    (311 :rpl_whoisuser)
171    (312 :rpl_whoisserver)
172    (313 :rpl_whoisoperator)
173    (314 :rpl_whowasuser)
174    (315 :rpl_endofwho)
175    (316 :rpl_whoischanop)
176    (317 :rpl_whoisidle)
177    (318 :rpl_endofwhois)
178    (319 :rpl_whoischannels)
179    (320 :rpl_whoisidentified) ; Seen in dancer ircd source
180    (321 :rpl_liststart)
181    (322 :rpl_list)
182    (323 :rpl_listend)
183    (324 :rpl_channelmodeis)
184    (325 :rpl_uniqopis)
185    (326 :rpl_whoisoperprivs) ; Seen in dancer ircd source
186    (327 :rpl_whoisrealhost) ; Seen in dancer ircd source
187    (329 :rpl_creationtime) ; Seen in dancer ircd source
188    (331 :rpl_notopic)
189    (332 :rpl_topic)
190    (333 :rpl_topicwhotime) ; Seen in dancer ircd source
191    (341 :rpl_inviting)
192    (342 :rpl_summoning)
193    (346 :rpl_invitelist)
194    (347 :rpl_endofinvitelist)
195    (348 :rpl_exceptlist)
196    (349 :rpl_endofexceptlist)
197    (351 :rpl_version)
198    (352 :rpl_whoreply)
199    (353 :rpl_namreply)
200    (361 :rpl_killdone)
201    (362 :rpl_closing)
202    (363 :rpl_closeend)
203    (366 :rpl_endofnames)
204    (364 :rpl_links)
205    (365 :rpl_endoflinks)
206    (367 :rpl_banlist)
207    (368 :rpl_endofbanlist)
208    (369 :rpl_endofwhowas)
209    (371 :rpl_info)
210    (372 :rpl_motd)
211    (373 :rpl_infostart)
212    (374 :rpl_endofinfo)
213    (375 :rpl_motdstart)
214    (376 :rpl_endofmotd)
215    (377 :rpl_map) ; Seen in dancer ircd source
216    (378 :rpl_endofmap) ; Seen in dancer ircd source
217    (379 :rpl_forward) ; Seen in dancer ircd source
218    (381 :rpl_youreoper)
219    (382 :rpl_rehashing)
220    (383 :rpl_yourservice)
221    (384 :rpl_myportis)
222    (391 :rpl_time)
223    (392 :rpl_usersstart)
224    (393 :rpl_users)
225    (394 :rpl_endofusers)
226    (395 :rpl_nousers)
227    (399 :rpl_message) ; Seen in dancer ircd source
228    (401 :err_nosuchnick)
229    (402 :err_nosuchserver)
230    (403 :err_nosuchchannel)
231    (404 :err_cannotsendtochan)
232    (405 :err_toomanychannels)
233    (406 :err_wasnosuchnick)
234    (407 :err_toomanytargets)
235    (408 :err_nosuchservice)
236    (409 :err_noorigin)
237    (410 :err_services_offline) ; Seen in dancer ircd source
238    (411 :err_norecipient)
239    (412 :err_notexttosend)
240    (413 :err_notoplevel)
241    (414 :err_wildtoplevel)
242    (415 :err_badmask)
243    (421 :err_unknowncommand)
244    (422 :err_nomotd)
245    (423 :err_noadmininfo)
246    (424 :err_fileerror)
247    (431 :err_nonicknamegiven)
248    (432 :err_erroneusnickname)
249    (433 :err_nicknameinuse)
250    (436 :err_nickcollision)
251    (437 :err_unavailresource)
252    (438 :err_bannickchange) ; Seen in dancer ircd source
253    (441 :err_usernotinchannel)
254    (442 :err_notonchannel)
255    (443 :err_useronchannel)
256    (444 :err_nologin)
257    (445 :err_summondisabled)
258    (446 :err_userdisabled)
259    (447 :err_targetninvite) ; Seen in dancer ircd source
260    (448 :err_sourceninvite) ; Seen in dancer ircd source
261    (451 :err_notregistered)
262    (461 :err_needmoreparams)
263    (462 :err_alreadyregistered)
264    (463 :err_nopermforhost)
265    (464 :err_passwdmismatch)
266    (465 :err_yourebannedcreep)
267    (466 :err_youwillbebanned)
268    (467 :err_keyset)
269    (471 :err_channelisfull)
270    (472 :err_unknownmode)
271    (473 :err_inviteonlychan)
272    (474 :err_bannedfromchan)
273    (475 :err_badchannelkey)
274    (476 :err_badchanmask)
275    (477 :err_nochanmodes)
276    (478 :err_banlistfull)
277    (479 :err_badchanname) ; Seen in dancer ircd source
278    (480 :err_throttled) ; Seen in dancer ircd source
279    (481 :err_noprivileges)
280    (482 :err_chanoprivsneeded)
281    (483 :err_cantkillserver)
282    (484 :err_restricted)
283    (485 :err_uniqopprivsneeded)
284    (486 :err_restricted) ; Seen in dancer ircd source
285    (487 :err_no_op_split) ; Seen in dancer ircd source
286    (488 :err_need_umode) ; Seen in dancer ircd source
287    (491 :err_nooperhost)
288    (501 :err_umodeunknownflag)
289    (502 :err_usersdontmatch)
290    (503 :err_ghostedclient) ; Seen in dancer ircd source
291    (505 :err_blocking_notid) ; Seen in dancer ircd source
292    (511 :err_sitelistfull) ; Seen in dancer ircd source
293    (512 :err_maxmapnodes) ; Seen in dancer ircd source
294    (513 :err_maxforwarding) ; Seen in dancer ircd source
295    (514 :err_noforwarding) ; Seen in dancer ircd source
296    (515 :err_nounidentified) ; Seen in dancer ircd source
297    (516 :err_last_err_msg))) ; Seen in dancer ircd source
298
Note: See TracBrowser for help on using the repository browser.