[project @ 2005-06-28 03:16:45 by unknown_lamer]
[clinton/bobotpp.git] / scripts / log.scm
CommitLineData
07686d60 1;;; simple logging script
07686d60 2
3(use-modules (ice-9 rdelim))
4
5(define log-port (open-file "channels.log" "al"))
6
7(define (time-stamp)
8 (strftime "(%H:%M:%S) " (gmtime (current-time))))
9
10(display (str-app
11 "\n== STARTING LOG [ "
12 (strftime "%F " (gmtime (current-time)))
13 (time-stamp)
14 "] ==\n") log-port)
15
16(let ((pub-func
17 (lambda (f t p)
18 (write-line (str-app
19 (string-downcase! t) " "
20 (time-stamp)
21 "<" f "> " p)
22 log-port))))
23 (bot:addhook hooks/public ".*"
24 pub-func
25 10000 #t "log")
26 (bot:addhook hooks/send/public ".*"
27 pub-func 1000 #t "log"))
28
29(let ((act-hook
30 (lambda (f t p)
31 (write-line
32 (str-app
33 (string-downcase! t) " "
34 (time-stamp)
35 "* "
36 (car (string-split f #\!))
37 " " p)
38 log-port))))
39 (bot:addhook hooks/action ".*"
40 act-hook
41 10000 #t "log")
42 (bot:addhook hooks/send/action ".*"
43 act-hook 10000 #t "log"))
44
45(bot:addhook hooks/join ".*.*"
46 (lambda (name channel)
47 (write-line (str-app
48 (string-downcase! channel) " "
49 (time-stamp)
50 name " joined "
51 (string-downcase! channel))
52 log-port))
53 10000 #t "log")
54
55(bot:addhook hooks/kick ".*"
56 (lambda (who op channel reason)
57 (write-line
58 (str-app
59 (string-downcase! channel) " "
60 (time-stamp)
61 who " was kicked from " channel
62 " by " op " (" reason ")") log-port))
63 10000 #t "log")
64
65(bot:addhook hooks/mode ".*"
66 (lambda (who channel mode)
67 (write-line
68 (str-app
69 (string-downcase! channel) " "
70 (time-stamp)
71 who " set mode " mode
72 " on " (string-downcase! channel))
73 log-port))
74 10000 #t "log")
75
76(bot:addhook hooks/nickname ".*"
77 (lambda (orig new)
78 (write-line
79 (str-app
80 "--- "
81 (time-stamp)
82 orig " is now known as "
83 new) log-port))
84 10000 #t "log")
85
86(bot:addhook hooks/leave ".*"
87 (lambda (who channel)
88 (write-line
89 (str-app
90 (string-downcase! channel) " "
91 (time-stamp)
92 who " has left channel "
93 (string-downcase! channel))
94 log-port))
95 10000 #t "log")
96
97(bot:addhook hooks/signoff ".*"
98 (lambda (who rest)
99 (write-line
100 (str-app
101 "--- "
102 (time-stamp)
103 who " has left IRC ("
104 (substring rest 1 (string-length rest)) ")")
105 log-port))
106 10000 #t "log")
107
108(bot:addhook hooks/topic ".*"
109 (lambda (op channel new-topic)
110 (write-line
111 (str-app
112 (string-downcase! channel) " "
113 (time-stamp)
114 op " has changed the topic on "
115 (string-downcase! channel)
116 " to: " new-topic)
117 log-port ))
118 10000 #t "log")
119
120(add-hook! bot:exit-hook (lambda ()
121 (display (str-app
122 "== ENDING LOG [ "
123 (strftime "%F " (gmtime (current-time)))
124 (time-stamp)
125 "] ==\n") log-port)))