1c302f21adb8ed02811482c19497594f25e4b1e1
[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., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
24
25 ;;; Code:
26
27 (require 'riece-globals)
28 (require 'riece-misc)
29
30 (eval-when-compile
31   (autoload 'riece-default-handle-numeric-reply "riece-filter"))
32 (defun riece-handle-default-400-message (prefix number name string)
33   (riece-default-handle-numeric-reply
34    riece-error-prefix prefix number name string))
35
36 (defun riece-handle-read-string (prompt)
37   (condition-case nil
38       (let (inhibit-quit)
39         (read-string prompt))
40     (quit)))
41   
42 (defun riece-handle-432-message (prefix number name string)
43   "ERR_ERRONEUSNICKNAME \"<nick> :Erroneous nickname\"."
44   (let ((nickname
45          (riece-handle-read-string
46           (format "Erroneous nickname \"%s\".  Choose a new one: "
47                   (car (riece-split-parameters string))))))
48     (if nickname
49         (riece-send-string (format "NICK %s\r\n" nickname)))))
50
51 (defun riece-handle-433-message (prefix number name string)
52   "ERR_NICKNAMEINUSE \"<nick> :Nickname is already in use\"."
53   (let ((nickname
54          (riece-handle-read-string
55           (format "Nickname \"%s\" already in use.  Choose a new one: "
56                   (car (riece-split-parameters string))))))
57     (if nickname
58         (riece-send-string (format "NICK %s\r\n" nickname)))))
59
60 (defun riece-handle-464-message (prefix number name string)
61   "ERR_PASSWDMISMATCH \":Password incorrect\"."
62   (message "Password incorrect from %s." prefix)
63   (setq riece-reconnect-with-password t))
64
65 (provide 'riece-400)
66
67 ;;; riece-400.el ends here