我有这个功能
(defun mention-notify (match-type nickuserhost msg)
(interactive)
(if (and (eq match-type 'current-nick)
(eq (string-match "^-NickServ-" msg) nil) ;this is probably not needed
(eq (string-match "^\\*\\*\\*" msg) nil))
(progn
(shell-command "mpg123 -q /home/kuba/Pobrane/beep-8.mp3")
(notify "ERC" msg))))
(add-hook 'erc-text-matched-hook 'mention-notify)
但即使它从***
开始,它也会执行命令。我在这里做错了什么?该功能应该如何?
我读了that page,但它只显示了如何发送所有提及的通知,甚至是服务器。像:
*** Users on #<chanel>: jcubic...
或
*** jcubic has changed mode for jcubic to +i
当我检查'current-nick
时,它接缝 - msg不是整个消息,而是包含我的缺口的子字符串,我尝试检查关键字而不是current-nick并检查我总是使用的缺口是否出现在文本但使用关键字根本不起作用。
答案 0 :(得分:3)
您可能还想看看Sauron:
答案 1 :(得分:1)
我将erc.el文件中的erc-match-message
函数复制到我的.emacs文件中,并添加了一个标记来挂钩
(run-hook-with-args
'erc-text-matched-hook
(intern match-type)
(or nickuserhost
(concat "Server:" (erc-get-parsed-vector-type vector)))
message
(string-match "^\\*\\*\\*"
(buffer-substring (point-min) (point-max)))))))
如果消息是erc系统消息,则设置最后一个标志 - 以***
开头,所以现在我可以在我的钩子中检查这个标志
(defun mention-notify (match-type nickuserhost msg notification)
(interactive)
(if (and (eq match-type 'current-nick)
(not notification))
(progn
(shell-command "mpg123 -q /home/kuba/Pobrane/beep-8.mp3")
(notify "ERC" msg))))
UPDATE 我也不想从-NickServ收到消息 - 所以我添加了这个
(run-hook-with-args
'erc-text-matched-hook
(intern match-type)
(or nickuserhost
(concat "Server:" (erc-get-parsed-vector-type vector)))
message
(let ((whole-msg (buffer-substring (point-min) (point-max))))
(or (string-match "^-NickServ-" whole-msg)
(string-match "^\\*\\*\\*" whole-msg)))))))
答案 2 :(得分:0)