(defun liece-open-server-internal (host &optional service type)
"Open connection to chat server on HOST by SERVICE (default is irc).
Optional argument TYPE specifies connection types such as `program'."
- (condition-case err
+ ;; canonicalize host representation
+ (unless (string-match "^[^\\[]" host)
+ (setq host (substring host 1 (1- (length host)))))
+ (condition-case error
(save-excursion
- ;; Initialize communication buffer.
- (setq liece-server-buffer (liece-get-buffer-create " *IRC*"))
- (set-buffer liece-server-buffer)
- (set-buffer-multibyte nil)
- (kill-all-local-variables)
- (buffer-disable-undo)
- (erase-buffer)
- (cond
- ((string-match "^[^\\[]" host)
- (let ((liece-tcp-connection-type type))
- (as-binary-process
- (setq liece-server-process
- (liece-open-network-stream
- "IRC" (current-buffer) host (or service "irc"))))))
- ((not
- (or
- (string-match
- "^\\[\\([0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\\)\\]$" host)
- (string-match
- "^\\[\\([0-9A-Za-z]*:[0-9A-Za-z:]*\\)\\]$" host)
- (string-match
- "^\\[\\([0-9]+\\)\\]$" host)))
- (setq liece-status-message-string
- (_ "Use [nnn.nnn.nnn.nnn]")
- liece-server-process nil)))
- (setq liece-server-name host)
- (run-hooks 'liece-server-hook)
- ;; Return the server process.
- liece-server-process)
+ (let ((liece-tcp-connection-type type))
+ (as-binary-process
+ (setq liece-server-process
+ (liece-open-network-stream
+ "IRC" " *IRC*" host (or service "irc"))))
+ (setq liece-server-buffer (process-buffer liece-server-process))
+ (set-buffer liece-server-buffer)
+ (set-buffer-multibyte nil)
+ (kill-all-local-variables)
+ (buffer-disable-undo)
+ (erase-buffer)
+ (setq liece-server-name host)
+ (run-hooks 'liece-server-hook)
+ ;; return the server process
+ liece-server-process)
(error
- (setq liece-status-message-string (cadr err)) nil)))
+ (setq liece-status-message-string (cadr err)
+ liece-server-process nil)))))
(defun liece-initialize-timers ()
"Initialise internal timers."