Function: erc-lurker-update-status

erc-lurker-update-status is a byte-compiled function defined in erc.el.gz.

Signature

(erc-lurker-update-status MESSAGE)

Documentation

Update erc-lurker-state if necessary.

This function is called from erc-insert-pre-hook. If the current message is a PRIVMSG, update erc-lurker-state to reflect the fact that its sender has issued a PRIVMSG at the current time. Otherwise, take no action.

This function depends on the fact that erc-display-message dynamically binds erc-message-parsed, which is used to check if the current message is a PRIVMSG and to determine its sender. See also erc-lurker-trim-nicks and erc-lurker-ignore-chars.

In order to limit memory consumption, this function also calls erc-lurker-cleanup once every erc-lurker-cleanup-interval updates of erc-lurker-state.

Source Code

;; Defined in /usr/src/emacs/lisp/erc/erc.el.gz
(defun erc-lurker-update-status (_message)
  "Update `erc-lurker-state' if necessary.

This function is called from `erc-insert-pre-hook'.  If the
current message is a PRIVMSG, update `erc-lurker-state' to
reflect the fact that its sender has issued a PRIVMSG at the
current time.  Otherwise, take no action.

This function depends on the fact that `erc-display-message'
dynamically binds `erc-message-parsed', which is used to check if
the current message is a PRIVMSG and to determine its sender.
See also `erc-lurker-trim-nicks' and `erc-lurker-ignore-chars'.

In order to limit memory consumption, this function also calls
`erc-lurker-cleanup' once every `erc-lurker-cleanup-interval'
updates of `erc-lurker-state'."
  (when (and (boundp 'erc-message-parsed)
             (erc-response-p erc-message-parsed))
    (let* ((command (erc-response.command erc-message-parsed))
           (sender
            (erc-lurker-maybe-trim
             (car (erc-parse-user
                   (erc-response.sender erc-message-parsed)))))
           (server
            (erc-canonicalize-server-name erc-server-announced-name)))
      (when (equal command "PRIVMSG")
        (when (>= (cl-incf erc-lurker-cleanup-count)
                  erc-lurker-cleanup-interval)
          (setq erc-lurker-cleanup-count 0)
          (erc-lurker-cleanup))
        (unless (gethash server erc-lurker-state)
          (puthash server (make-hash-table :test 'equal) erc-lurker-state))
        (puthash sender (current-time)
                 (gethash server erc-lurker-state))))))