1 ;;; zenirc-stamp.el --- timestamping for ZenIRC
3 ;; Copyright (C) 1993, 1994 Ben A. Mesander
5 ;; Author: Ben A. Mesander <ben@gnu.ai.mit.edu>
6 ;; Maintainer: ben@gnu.ai.mit.edu
7 ;; Keywords: extensions
10 ;; This program is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; This program is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with this program; if not, you can either send email to this
22 ;; program's maintainer or write to: The Free Software Foundation,
23 ;; Inc.; 675 Massachusetts Avenue; Cambridge, MA 02139, USA.
27 ;; This code is meant as a demonstration of how to use the ZenIRC
28 ;; hook mechanism and timer code to cause ZenIRC to do something at a
35 (defvar zenirc-timestamp-interval '(0 600)
36 "How often to insert timestamps into the ZenIRC buffer. The default
37 is 600 seconds or 10 minutes. The value of this variable is a 32 bit
38 integer, expressed as a list of two 16 bit values, ie, the default
39 value of 600 seconds is expressed as (0 600).")
41 (defvar zenirc-last-timestamp '(0 0)
42 "The time the last timestamp was inserted into the ZenIRC buffer.
43 You shouldn't have to frob this yourself.")
45 (defun zenirc-timestamp (proc now)
46 "Insert a timestamp into the the ZenIRC buffer specified by the
47 process PROC every zenirc-timestamp-interval seconds."
48 (if (zenirc-time< zenirc-timestamp-interval
49 (zenirc-time-diff now zenirc-last-timestamp))
51 (zenirc-message proc (concat "[time] " (current-time-string) "\n"))
52 (setq zenirc-last-timestamp now))))
54 (provide 'zenirc-stamp)
56 (zenirc-add-hook 'zenirc-timer-hook 'zenirc-timestamp)
58 ;; zenirc-stamp.el ends here