annotate lisp/erc/erc-capab.el @ 77076:9bc027540c27

Describe problems on Windows with ClearType enabled.
author Eli Zaretskii <eliz@gnu.org>
date Mon, 09 Apr 2007 08:42:03 +0000
parents 2fae574a2382
children 85d67fae9a94
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
75259
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
1 ;;; erc-capab.el --- support for dancer-ircd and hyperion's CAPAB
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
2
75346
7a3f13e2dd57 Add 2007 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 75259
diff changeset
3 ;; Copyright (C) 2006, 2007 Free Software Foundation, Inc.
75259
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
4
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
5 ;; GNU Emacs is free software; you can redistribute it and/or modify
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
6 ;; it under the terms of the GNU General Public License as published by
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
7 ;; the Free Software Foundation; either version 2, or (at your option)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
8 ;; any later version.
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
9
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
10 ;; GNU Emacs is distributed in the hope that it will be useful,
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
11 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
12 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
13 ;; GNU General Public License for more details.
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
14
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
15 ;; You should have received a copy of the GNU General Public License
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
16 ;; along with GNU Emacs; see the file COPYING. If not, write to the
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
17 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
18 ;; Boston, MA 02110-1301, USA.
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
19
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
20 ;;; Commentary:
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
21
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
22 ;; This file defines the ERC module `erc-capab-identify', which allows
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
23 ;; flagging of unidentified users on servers running dancer-ircd or
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
24 ;; hyperion. freenode.net supports this capability, for example.
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
25
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
26 ;; With CAPAB IDENTIFY-MSG and IDENTIFY-CTCP enabled, messages from
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
27 ;; users who have identified themselves to NickServ will have a plus
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
28 ;; sign and messages from unidentified users will have a minus sign
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
29 ;; added as a prefix. Note that it is not necessary for your nickname
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
30 ;; to be identified in order to receive these marked messages.
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
31
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
32 ;; The plus or minus sign is removed from the message, and a prefix,
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
33 ;; `erc-capab-identify-prefix', is inserted in the front of the user's
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
34 ;; nickname if the nickname is not identified.
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
35
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
36 ;; Please note that once this has been enabled on a server, there is no
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
37 ;; way to tell the server to stop sending marked messages. If you
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
38 ;; disable this module, it will continue removing message flags, but the
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
39 ;; unidentified nickname prefix will not be added to messages.
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
40
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
41 ;; Visit <http://freenode.net/faq.shtml#spoofing> and
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
42 ;; <http://freenode.net/faq.shtml#registering> to find further
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
43 ;; explanations of this capability.
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
44
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
45 ;; From freenode.net's web site (not there anymore) on how to mark
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
46 ;; unidentified users:
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
47 ;; "We recommend that you add an asterisk before the nick, and
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
48 ;; optionally either highlight or colourize the line in some
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
49 ;; appropriate fashion, if the user is not identified."
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
50
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
51 ;;; Usage:
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
52
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
53 ;; Put the following in your ~/.emacs file.
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
54
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
55 ;; (require 'erc-capab)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
56 ;; (erc-capab-identify-mode 1)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
57
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
58 ;; `erc-capab-identify-prefix' will now be added to the beginning of
76856
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
59 ;; unidentified users' nicknames. The default is an asterisk, "*".
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
60 ;; You can customize the prefix and the face used to display it,
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
61 ;; `erc-capab-identify-unidentified'. If the value of
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
62 ;; `erc-capab-identify-prefix' is nil or you disable this module (see
75259
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
63 ;; `erc-capab-identify-disable'), no prefix will be inserted, but the
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
64 ;; flag sent by the server will still be stripped.
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
65
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
66 ;;; Code:
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
67
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
68 (require 'erc)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
69 (eval-when-compile (require 'cl))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
70
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
71 ;;; Customization:
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
72
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
73 (defgroup erc-capab nil
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
74 "Support for dancer-ircd's CAPAB settings."
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
75 :group 'erc)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
76
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
77 (defcustom erc-capab-identify-prefix "*"
76856
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
78 "The prefix used for unidentified users.
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
79
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
80 If you change this from the default \"*\", be sure to use a
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
81 character not found in IRC nicknames to avoid confusion."
75259
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
82 :group 'erc-capab
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
83 :type '(choice string (const nil)))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
84
76856
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
85 (defface erc-capab-identify-unidentified '((t)) ; same as `erc-default-face'
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
86 "Face to use for `erc-capab-identify-prefix'."
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
87 :group 'erc-capab
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
88 :group 'erc-faces)
75259
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
89
76856
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
90 ;;; Define module:
75259
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
91
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
92 ;;;###autoload (autoload 'erc-capab-identify-mode "erc-capab" nil t)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
93 (define-erc-module capab-identify nil
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
94 "Handle dancer-ircd's CAPAB IDENTIFY-MSG and IDENTIFY-CTCP."
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
95 ;; append so that `erc-server-parameters' is already set by `erc-server-005'
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
96 ((add-hook 'erc-server-005-functions 'erc-capab-identify-setup t)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
97 (add-hook 'erc-server-290-functions 'erc-capab-identify-activate)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
98 (add-hook 'erc-server-PRIVMSG-functions
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
99 'erc-capab-identify-remove/set-identified-flag)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
100 (add-hook 'erc-server-NOTICE-functions
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
101 'erc-capab-identify-remove/set-identified-flag)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
102 (add-hook 'erc-insert-modify-hook 'erc-capab-identify-add-prefix t)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
103 (mapc (lambda (buffer)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
104 (when buffer
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
105 (with-current-buffer buffer (erc-capab-identify-setup))))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
106 (erc-buffer-list 'erc-open-server-buffer-p)))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
107 ((remove-hook 'erc-server-005-functions 'erc-capab-identify-setup)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
108 (remove-hook 'erc-server-290-functions 'erc-capab-identify-activate)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
109 ;; we don't remove the `erc-capab-identify-remove/set-identified-flag' hooks
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
110 ;; because there doesn't seem to be a way to tell the server to turn it off
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
111 (remove-hook 'erc-insert-modify-hook 'erc-capab-identify-add-prefix)))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
112
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
113 ;;; Variables:
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
114
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
115 (defvar erc-capab-identify-activated nil
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
116 "CAPAB IDENTIFY-MSG has been activated.")
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
117 (make-variable-buffer-local 'erc-capab-identify-activated)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
118
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
119 (defvar erc-capab-identify-sent nil
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
120 "CAPAB IDENTIFY-MSG and IDENTIFY-CTCP messages have been sent.")
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
121 (make-variable-buffer-local 'erc-capab-identify-sent)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
122
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
123 ;;; Functions:
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
124
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
125 (defun erc-capab-identify-setup (&optional proc parsed)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
126 "Set up CAPAB IDENTIFY on the current server.
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
127
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
128 Optional argument PROC is the current server's process.
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
129 Optional argument PARSED is the current message, a response struct.
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
130
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
131 These arguments are sent to this function when called as a hook in
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
132 `erc-server-005-functions'."
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
133 (unless erc-capab-identify-sent
76856
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
134 (erc-capab-identify-send-messages)))
75259
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
135
76856
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
136 (defun erc-capab-identify-send-messages ()
75259
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
137 "Send CAPAB IDENTIFY messages if the server supports it."
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
138 (when (and (stringp erc-server-version)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
139 (string-match "^\\(dancer-ircd\\|hyperion\\)" erc-server-version)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
140 ;; could possibly check for '("IRCD" . "dancer") in
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
141 ;; `erc-server-parameters' instead of looking for a specific name
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
142 ;; in `erc-server-version'
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
143 (assoc "CAPAB" erc-server-parameters))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
144 (erc-log "Sending CAPAB IDENTIFY-MSG and IDENTIFY-CTCP")
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
145 (erc-server-send "CAPAB IDENTIFY-MSG")
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
146 (erc-server-send "CAPAB IDENTIFY-CTCP")
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
147 (setq erc-capab-identify-sent t)))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
148
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
149
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
150 (defun erc-capab-identify-activate (proc parsed)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
151 "Set `erc-capab-identify-activated' and display an activation message.
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
152
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
153 PROC is the current server's process.
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
154 PARSED is an `erc-parsed' response struct."
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
155 (when (or (string= "IDENTIFY-MSG" (erc-response.contents parsed))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
156 (string= "IDENTIFY-CTCP" (erc-response.contents parsed)))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
157 (setq erc-capab-identify-activated t)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
158 (erc-display-message
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
159 parsed 'notice 'active (format "%s activated"
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
160 (erc-response.contents parsed)))))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
161
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
162 (defun erc-capab-identify-remove/set-identified-flag (proc parsed)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
163 "Remove PARSED message's id flag and add the `erc-identified' text property.
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
164
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
165 PROC is the current server's process.
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
166 PARSED is an `erc-parsed' response struct."
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
167 (let ((msg (erc-response.contents parsed)))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
168 (when (and erc-capab-identify-activated
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
169 (string-match "^\\([-\\+]\\)\\(.+\\)$" msg))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
170 (setf (erc-response.contents parsed)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
171 (if erc-capab-identify-mode
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
172 (erc-propertize (match-string 2 msg)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
173 'erc-identified
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
174 (if (string= (match-string 1 msg) "+")
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
175 1
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
176 0))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
177 (match-string 2 msg)))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
178 nil)))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
179
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
180 (defun erc-capab-identify-add-prefix ()
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
181 "Add `erc-capab-identify-prefix' to nickname if user is unidentified."
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
182 (when (and erc-capab-identify-prefix
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
183 (erc-with-server-buffer erc-capab-identify-activated))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
184 (goto-char (or (erc-find-parsed-property) (point-min)))
76856
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
185 (let ((nickname (erc-capab-identify-get-unidentified-nickname
75259
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
186 (erc-get-parsed-vector (point)))))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
187 (when (and nickname
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
188 (goto-char (point-min))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
189 ;; assuming the first use of `nickname' is the sender's nick
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
190 (re-search-forward (regexp-quote nickname) nil t))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
191 (goto-char (match-beginning 0))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
192 (insert (erc-propertize erc-capab-identify-prefix
76856
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
193 'face 'erc-capab-identify-unidentified))))))
75259
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
194
76856
2fae574a2382 Release ERC 5.2.
Miles Bader <miles@gnu.org>
parents: 75346
diff changeset
195 (defun erc-capab-identify-get-unidentified-nickname (parsed)
75259
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
196 "Return the nickname of the user if unidentified.
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
197 PARSED is an `erc-parsed' response struct."
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
198 (when (and (erc-response-p parsed)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
199 (equal 0 (get-text-property 0 'erc-identified
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
200 (erc-response.contents parsed))))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
201 (let ((nickuserhost (erc-get-parsed-vector-nick parsed)))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
202 (when nickuserhost
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
203 (nth 0 (erc-parse-user nickuserhost))))))
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
204
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
205 (provide 'erc-capab)
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
206
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
207 ;; arch-tag: 27b6d668-7ee5-4e47-b9f0-27d7a4362062
f45c5edf0be4 Merge from erc--main--0
Miles Bader <miles@gnu.org>
parents:
diff changeset
208 ;;; erc-capab.el ends here