summaryrefslogtreecommitdiff
path: root/chess-irc.el
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2002-04-15 05:40:38 +0000
committerJohn Wiegley <johnw@newartisans.com>2002-04-15 05:40:38 +0000
commitef7c29d679c6aaf8dda55772e65800097c46f163 (patch)
tree543f39f09bfaa6d44606804c18babff26470d4f8 /chess-irc.el
parent6fbcc92505250d896b5d408483822b115bc614c7 (diff)
*** no comment ***
Diffstat (limited to 'chess-irc.el')
-rw-r--r--chess-irc.el81
1 files changed, 41 insertions, 40 deletions
diff --git a/chess-irc.el b/chess-irc.el
index c5ae5d0..b8dfa9e 100644
--- a/chess-irc.el
+++ b/chess-irc.el
@@ -56,47 +56,48 @@
(make-variable-buffer-local 'chess-irc-last-pos)
(make-variable-buffer-local 'chess-irc-use-ctcp)
-(defun chess-irc-handler (event &rest args)
+(defun chess-irc-handler (game event &rest args)
"This is an example of a generic transport engine."
- (cond
- ((eq event 'initialize)
- (chess-message 'irc-connecting chess-irc-server chess-irc-port)
- (let ((engine (current-buffer)) proc)
- (with-current-buffer (generate-new-buffer " *chess-irc*")
- (setq chess-irc-engine engine
- proc (open-network-stream "*chess-irc*" (current-buffer)
- chess-irc-server chess-irc-port))
- (chess-message 'irc-logging-in chess-irc-nick)
- (when (and proc (eq (process-status proc) 'open))
- (process-send-string proc (format "USER %s 0 * :%s\n"
- (user-login-name)
- chess-full-name))
- (process-send-string proc (format "NICK %s\n" chess-irc-nick))
- (set-process-filter proc 'chess-irc-filter)
- (set-process-buffer proc (current-buffer))
- (set-marker (process-mark proc) (point))
- (chess-message 'irc-waiting)))
- (setq chess-irc-process proc))
- t)
-
- ((eq event 'match)
- (setq chess-irc-opponent (read-string (chess-string 'irc-challenge)))
- (chess-network-handler 'match chess-irc-opponent))
-
- ((eq event 'shutdown)
- (chess-engine-send nil "quit")
- (process-send-string chess-irc-process "QUIT :Goodbye\n")
- (kill-buffer (process-buffer chess-irc-process)))
-
- ((eq event 'send)
- (process-send-string chess-irc-process
- (if chess-irc-use-ctcp
- (format "PRIVMSG %s :\C-aCHESS %s\C-a\n"
- chess-irc-opponent (car args))
- (format "PRIVMSG %s :%s\n"
- chess-irc-opponent (car args)))))
- (t
- (apply 'chess-network-handler event args))))
+ (unless chess-engine-handling-event
+ (cond
+ ((eq event 'initialize)
+ (chess-message 'irc-connecting chess-irc-server chess-irc-port)
+ (let ((engine (current-buffer)) proc)
+ (with-current-buffer (generate-new-buffer " *chess-irc*")
+ (setq chess-irc-engine engine
+ proc (open-network-stream "*chess-irc*" (current-buffer)
+ chess-irc-server chess-irc-port))
+ (chess-message 'irc-logging-in chess-irc-nick)
+ (when (and proc (eq (process-status proc) 'open))
+ (process-send-string proc (format "USER %s 0 * :%s\n"
+ (user-login-name)
+ chess-full-name))
+ (process-send-string proc (format "NICK %s\n" chess-irc-nick))
+ (set-process-filter proc 'chess-irc-filter)
+ (set-process-buffer proc (current-buffer))
+ (set-marker (process-mark proc) (point))
+ (chess-message 'irc-waiting)))
+ (setq chess-irc-process proc))
+ t)
+
+ ((eq event 'match)
+ (setq chess-irc-opponent (read-string (chess-string 'irc-challenge)))
+ (chess-network-handler 'match chess-irc-opponent))
+
+ ((eq event 'destroy)
+ (chess-engine-send nil "quit")
+ (process-send-string chess-irc-process "QUIT :Goodbye\n")
+ (kill-buffer (process-buffer chess-irc-process)))
+
+ ((eq event 'send)
+ (process-send-string chess-irc-process
+ (if chess-irc-use-ctcp
+ (format "PRIVMSG %s :\C-aCHESS %s\C-a\n"
+ chess-irc-opponent (car args))
+ (format "PRIVMSG %s :%s\n"
+ chess-irc-opponent (car args)))))
+ (t
+ (apply 'chess-network-handler event args)))))
;; This filter translates IRC syntax into basic chess-network protocol
(defun chess-irc-filter (proc string)