我使用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正在回应与意外消息的连接?
答案 0 :(得分:5)
@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))))))))))
我申请加入dev邮件列表,很快就会提交补丁。