[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Erc-discuss] mass idle function - help needed
From: |
Karl James Pestka |
Subject: |
[Erc-discuss] mass idle function - help needed |
Date: |
Mon, 8 Mar 2010 18:16:07 +0000 |
I'm trying to put together a function that returns the nicks / idle times of
everyone in the current channel. I'm not quite sure how to go about this but
I'm getting close. If anyone knows a little elisp and can figure out where
I've gone wrong, it would be greatly appreciated.
Basically I threw this together by plundering erc-cmd-MASSUNBAN and
erc-cmd-IDLE, as defined in erc.el. However it returns ALL whois information
for each user in the channel, rather than just their idle times.
First, I mod erc-cmd-WHOIS to always return full whois info regardless of
server.
(defun erc-cmd-WHOIS (nick &rest ignore)
"Display whois information for NICK, regardless of which server they are on."
(erc-send-command (mapconcat #'identity (list "WHOIS " nick " " nick) " ")))
And here is my MASSIDLE function in all its nooby glory. I've pasted the
original erc-cmd-IDLE at the bottom of this message for reference. I don't
know how to filter out the rest of the whois info, but somehow IDLE can do it
while MASSIDLE cannot. Any tips??
(defun erc-cmd-MASSIDLE (&rest ignore)
"Mass Idle.
Display idle time for all users in the current channel."
(let ((chnl (erc-default-target)))
(cond
((not (erc-channel-p chnl))
(erc-display-line
(erc-make-notice "You're not on a channel\n")
'active))
(t (let ((hash-table erc-channel-users)
users)
(progn
;; Glob the users into groups of three, and carry out the voicing.
;; eg. /mode #foo +vvv address@hidden address@hidden address@hidden
(maphash (lambda (k v)
(unless (equal k erc-nick)
(add-to-list 'users k)))
hash-table)
(let ((origbuf (current-buffer))
symlist)
(erc-with-server-buffer
(mapcar ;; instead of mapc?
(lambda (x)
(add-to-list 'symlist
(cons
(erc-once-with-server-event
317
`(let ((idleseconds
(string-to-number
(third
(erc-response.command-args
parsed)))))
(erc-display-line
(erc-make-notice
(format "%s has been idle for %s."
(erc-string-no-properties
,(mapconcat 'identity x " "))
(erc-seconds-to-string
idleseconds)))
,origbuf))
t)
'erc-server-317-functions))
;; Send the WHOIS command.
(erc-cmd-WHOIS (mapconcat 'identity x " ")))
(erc-group-list users 1))
;; Remove the uninterned symbols from the server hooks that did
not run.
(run-at-time 20 nil `(lambda ()
(with-current-buffer ,(current-buffer)
(dolist (sym ',symlist)
(let ((hooksym (cdr sym))
(funcsym (car sym)))
(remove-hook hooksym funcsym
t))))))
))))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;; original idle ;;;;;;;;;;;;;;;;;;;;;;;;;
(defun erc-cmd-IDLE (nick)
"Show the length of time NICK has been idle."
(let ((origbuf (current-buffer))
symlist)
(erc-with-server-buffer
(add-to-list 'symlist
(cons (erc-once-with-server-event
311 `(string= ,nick
(second
(erc-response.command-args parsed))))
'erc-server-311-functions))
(add-to-list 'symlist
(cons (erc-once-with-server-event
312 `(string= ,nick
(second
(erc-response.command-args parsed))))
'erc-server-312-functions))
(add-to-list 'symlist
(cons (erc-once-with-server-event
318 `(string= ,nick
(second
(erc-response.command-args parsed))))
'erc-server-318-functions))
(add-to-list 'symlist
(cons (erc-once-with-server-event
319 `(string= ,nick
(second
(erc-response.command-args parsed))))
'erc-server-319-functions))
(add-to-list 'symlist
(cons (erc-once-with-server-event
320 `(string= ,nick
(second
(erc-response.command-args parsed))))
'erc-server-320-functions))
(add-to-list 'symlist
(cons (erc-once-with-server-event
330 `(string= ,nick
(second
(erc-response.command-args parsed))))
'erc-server-330-functions))
(add-to-list 'symlist
(cons (erc-once-with-server-event
317
`(let ((idleseconds
(string-to-number
(third
(erc-response.command-args parsed)))))
(erc-display-line
(erc-make-notice
(format "%s has been idle for %s."
(erc-string-no-properties ,nick)
(erc-seconds-to-string idleseconds)))
,origbuf))
t)
'erc-server-317-functions))
;; Send the WHOIS command.
(erc-cmd-WHOIS nick)
;; Remove the uninterned symbols from the server hooks that did not run.
(run-at-time 20 nil `(lambda ()
(with-current-buffer ,(current-buffer)
(dolist (sym ',symlist)
(let ((hooksym (cdr sym))
(funcsym (car sym)))
(remove-hook hooksym funcsym t))))))))
t)
smime.p7s
Description: S/MIME cryptographic signature
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Erc-discuss] mass idle function - help needed,
Karl James Pestka <=