1 ;;; riece-irc.el --- IRC protocol
2 ;; Copyright (C) 1998-2004 Daiki Ueno
4 ;; Author: Daiki Ueno <ueno@unixuser.org>
6 ;; Keywords: IRC, riece
8 ;; This file is part of Riece.
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)
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.
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.
27 (require 'riece-filter)
28 (require 'riece-server)
30 (defun riece-irc-open-server (server server-name)
31 (riece-server-keyword-bind server
32 (let (selective-display
33 (coding-system-for-read 'binary)
34 (coding-system-for-write 'binary)
36 (if (equal server-name "")
37 (message "Connecting to IRC server...")
38 (message "Connecting to %s..." server-name))
41 (funcall function (riece-server-process-name server-name)
42 (concat " *IRC*" server-name)
45 (if (equal server-name "")
46 (message "Connecting to IRC server...failed: %S" error)
47 (message "Connecting to %s...failed: %S" server-name error))
48 (signal (car error) (cdr error))))
49 (if (equal server-name "")
50 (message "Connecting to IRC server...done")
51 (message "Connecting to %s...done" server-name))
52 (riece-reset-process-buffer process)
53 (with-current-buffer (process-buffer process)
54 (setq riece-server-name server-name))
55 (set-process-sentinel process 'riece-sentinel)
56 (set-process-filter process 'riece-filter)
57 (if (equal server-name "")
58 (message "Logging in to IRC server...")
59 (message "Logging in to %s..." server-name))
60 (if riece-reconnect-with-password ;password incorrect or not set.
65 (if (equal server-name "")
66 (riece-read-passwd "Password: ")
67 (riece-read-passwd (format "Password for %s: "
70 (if (equal server-name "")
71 (message "Password: Quit")
72 (message (format "Password for %s: Quit"
75 (setq riece-reconnect-with-password nil)))
76 (if (eq password 'quit)
77 (delete-process process)
79 (riece-process-send-string process
80 (format "PASS %s\r\n" password)))
81 (riece-process-send-string process
82 (format "USER %s * * :%s\r\n"
88 (user-real-login-name))
91 "No information given")))
92 (riece-process-send-string process (format "NICK %s\r\n" nickname))
93 (with-current-buffer (process-buffer process)
94 (setq riece-last-nickname riece-real-nickname
95 riece-nick-accepted 'sent
96 riece-coding-system coding))
99 (defun riece-irc-quit-server-process (process &optional message)
100 (if riece-quit-timeout
101 (riece-run-at-time riece-quit-timeout nil
103 (if (rassq process riece-server-process-alist)
104 (delete-process process)))
106 (riece-process-send-string process
108 (format "QUIT :%s\r\n" message)