Add 5.0.0 changes.
[riece] / lisp / riece-400.el
1 ;;; riece-400.el --- handlers for 400 replies
2 ;; Copyright (C) 1998-2003 Daiki Ueno
3
4 ;; Author: Daiki Ueno <ueno@unixuser.org>
5 ;; Created: 1998-09-28
6 ;; Keywords: IRC, riece
7
8 ;; This file is part of Riece.
9
10 ;; This program is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
14
15 ;; This program is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 ;; GNU General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 ;; Boston, MA 02110-1301, USA.
24
25 ;;; Code:
26
27 (require 'riece-globals)
28 (require 'riece-misc)
29 (require 'riece-mcat)
30 (require 'riece-commands)
31
32 (eval-when-compile
33   (autoload 'riece-default-handle-numeric-reply "riece-handle"))
34 (defun riece-handle-default-400-message (prefix number name string)
35   (riece-default-handle-numeric-reply
36    riece-error-prefix prefix number name string))
37
38 (defun riece-handle-read-string (prompt)
39   (condition-case nil
40       (let (inhibit-quit)
41         (read-string prompt))
42     (quit
43      (ignore (message "%s" (concat prompt "Quit"))))))
44
45 (defun riece-handle-432-message (prefix number name string)
46   "ERR_ERRONEUSNICKNAME \"<nick> :Erroneous nickname\"."
47   (let ((nickname
48          (riece-handle-read-string
49           (format (riece-mcat "Erroneous nickname \"%s\".  Choose a new one: ")
50                   (car (riece-split-parameters string))))))
51     (if nickname
52         (riece-send-string (format "NICK %s\r\n" nickname)))))
53
54 (defun riece-handle-433-message (prefix number name string)
55   "ERR_NICKNAMEINUSE \"<nick> :Nickname is already in use\"."
56   (let ((nickname
57          (riece-handle-read-string
58           (format (riece-mcat "Nickname \"%s\" already in use.  Choose a new one: ")
59                   (car (riece-split-parameters string))))))
60     (if nickname
61         (riece-send-string (format "NICK %s\r\n" nickname)))))
62
63 (defun riece-handle-464-message (prefix number name string)
64   "ERR_PASSWDMISMATCH \":Password incorrect\"."
65   (message (riece-mcat "Password incorrect from %s.") prefix)
66   (setq riece-reconnect-with-password t))
67
68 (defun riece-handle-475-message (prefix number name string)
69   "ERR_BADCHANNELKEY \"<channel> :Cannot join channel (+k)\"."
70   (let* ((parameters (riece-split-parameters string))
71          (channel-identity (riece-make-identity (car parameters)
72                                                 riece-server-name))
73          key)
74     (setq key
75           (condition-case nil
76               (let (inhibit-quit)
77                 (riece-read-passwd
78                  (format (riece-mcat "Key for %s: ")
79                          (riece-format-identity channel-identity t))))
80             (quit
81              (message (riece-mcat "Key for %s: Quit")
82                       (riece-format-identity channel-identity t))
83              'quit)))
84     (unless (eq key 'quit)
85       (riece-command-join-channel channel-identity key))))
86
87 (provide 'riece-400)
88
89 ;;; riece-400.el ends here