连接到 Slack IRC 网关时出错

Error connecting to Slack IRC gateway

我正在使用 cl-irc 库通过 Slack 提供的 IRC 网关连接到 Slack。

但是,当我尝试使用 read-message-loop 启动消息循环时出现以下错误:

error while parsing arguments to DESTRUCTURING-BIND:
  invalid number of elements in
    ("duncan_bayne" "Welcome" "to" "Slack" "IRC" "Gateway"
     "server" "duncan_bayne!~duncan_bayne@1.2.3.4")
  to satisfy lambda list
    (CL-IRC:NICKNAME CL-IRC::WELCOME-MESSAGE):
  exactly 2 expected, but 8 found
   [Condition of type SB-KERNEL::ARG-COUNT-ERROR]

... 

Backtrace:
  0: ((:METHOD CL-IRC::DEFAULT-HOOK (CL-IRC:IRC-RPL_WELCOME-MESSAGE)) #<CL-IRC:IRC-RPL_WELCOME-MESSAGE irc.tinyspeck.com RPL_WELCOME {1007FC6293}>) [fast-method]
  1: ((:METHOD CL-IRC::APPLY-TO-HOOKS (T)) #<CL-IRC:IRC-RPL_WELCOME-MESSAGE irc.tinyspeck.com RPL_WELCOME {1007FC6293}>) [fast-method]
  2: ((:METHOD CL-IRC:IRC-MESSAGE-EVENT (T CL-IRC:IRC-MESSAGE)) #<unavailable argument> #<CL-IRC:IRC-RPL_WELCOME-MESSAGE irc.tinyspeck.com RPL_WELCOME {1007FC6293}>) [fast-method]
  3: ((:METHOD CL-IRC:READ-MESSAGE (CL-IRC:CONNECTION)) #<CL-IRC:CONNECTION myob.irc.slack.com {10068E8ED3}>) [fast-method]
  4: ((:METHOD CL-IRC:READ-MESSAGE-LOOP (T)) #<CL-IRC:CONNECTION myob.irc.slack.com {10068E8ED3}>) [fast-method]
  5: (SB-INT:SIMPLE-EVAL-IN-LEXENV (CL-IRC:READ-MESSAGE-LOOP *CONN*) #<NULL-LEXENV>)
  6: (EVAL (CL-IRC:READ-MESSAGE-LOOP *CONN*))

在 REPL 中我看到:

UNHANDLED-EVENT:3672562852: RPL_MYINFO: irc.tinyspeck.com duncan_bayne "IRC-SLACK gateway"

我不确定我做错了什么;我很确定这不是我的钩子,因为即使我将它们全部禁用,问题仍然存在。

此外,我可以按预期使用连接 - 例如,加入频道并发送消息 - 前提是我不尝试启动消息循环。

我猜,Slack 正在用意外消息响应连接?

@jkilski 建议的修复是修改 cl-irc 以接受来自 Slack 的稍微不寻常的(但可能符合标准?)响应:

(in-package #:cl-irc)
(defmethod default-hook ((message irc-rpl_welcome-message))
  (with-slots
        (connection host user arguments)
      message
    (destructuring-bind
          (nickname &rest welcome-message)
        arguments
      (setf (user connection)
            (make-user connection
                       :nickname nickname
                       :hostname host
                       :username user)))))

(in-package #:irc)
(defmethod default-hook ((message irc-rpl_namreply-message))
  (let* ((connection (connection message)))
    (destructuring-bind
          (nick chan-visibility channel &optional names)
        (arguments message)
      (declare (ignore nick))
      (let ((channel (find-channel connection channel)))
        (setf (visibility channel)
              (or (second (assoc chan-visibility
                                 '(("=" :public) ("*" :private) ("@" :secret))
                                 :test #'string=))
                  :unknown))
        (unless (has-mode-p channel 'namreply-in-progress)
          (add-mode channel 'namreply-in-progress
                    (make-instance 'list-value-mode :value-type :user)))
        (dolist (nickname (tokenize-string names))
          (let ((user (find-or-make-user connection
                                         (canonicalize-nickname connection
                                                                nickname))))
            (unless (equal user (user connection))
              (add-user connection user)
              (add-user channel user))
            (set-mode channel 'namreply-in-progress user)
            (let* ((mode-char (getf (nick-prefixes connection)
                                    (elt nickname 0)))
                   (mode-name (when mode-char
                                (mode-name-from-char connection
                                                     channel mode-char))))
              (when mode-name
                (if (has-mode-p channel mode-name)
                    (set-mode channel mode-name user)
                    (set-mode-value (add-mode channel mode-name
                                              (make-mode connection
                                                         channel mode-name))
                                    user))))))))))

我已经申请加入开发邮件列表,很快就会提交补丁。