all signers:
antecedents:
press order:
patch:
(1 . 17)(1 . 17)- DBC265A63C34C6B682694C8776AA4640C83BA92DCA5400F0BD393F6A9EB5D3672011C234C3D04A7AD074F3FCE560D71D78201F4BBCB506C12ED6CC90D3C59017
5 (in-package #:logbot)
6
7
8 (defun get-and-purge-outbox-messages (db)
9 (defun get-and-purge-outbox-messages (db target)
10 (postmodern:with-connection db
11 (postmodern:query
12 "with deleted as (
13 delete from outbox
14 returning target, message, queued_at
15 where target = $1
16 returning message, queued_at
17 )
18 select target,
19 message
20 select message
21 from deleted
22 order by queued_at"
23 order by queued_at" target
24 :rows)))
25
26 (defun make-log-entry (db target message host source user)
(57 . 18)(57 . 18)
28 (if (= 3 (length (arguments message)))
29 (destructuring-bind (channel mode nick) (arguments message)
30 (when (and (string= (host message) "services.")
31 (string= channel (ircbot-channel bot))
32 (member channel (ircbot-channels bot) :test #'string=)
33 (or (string= mode "+o") (string= mode "+v"))
34 (string= nick (ircbot-nick bot)))
35
36 (when (null (logbot-pg-thread bot))
37 (logbot-start-pg-thread bot)
38 (logbot-send-outbox bot))))))
39 (logbot-send-outbox bot channel))))))
40
41 (defmethod logbot-send-outbox ((bot logbot))
42 (defmethod logbot-send-outbox ((bot logbot) target)
43 (loop
44 for (target message)
45 in (get-and-purge-outbox-messages (logbot-db bot))
46 for (message)
47 in (get-and-purge-outbox-messages (logbot-db bot) target)
48 do (ircbot-send-message bot target message)))
49
50 (defmethod logbot-start-pg-thread ((bot logbot))
(78 . 16)(78 . 19)
52 (postmodern:with-connection (logbot-db bot)
53 (postmodern:execute "listen outbox_new_message")
54 (loop
55 (if (string= (cl-postgres:wait-for-notification postmodern:*database*)
56 "outbox_new_message")
57 (logbot-send-outbox bot)))))
58 (multiple-value-bind (channel payload pid)
59 (cl-postgres:wait-for-notification postmodern:*database*)
60 (declare (ignore pid))
61 (if (string= channel
62 "outbox_new_message")
63 (logbot-send-outbox bot payload))))))
64 :name "logbot-pg")))
65
66 (defun make-logbot (server port nick password channel db)
67 (defun make-logbot (server port nick password channels db)
68 (make-instance 'logbot
69 :server server
70 :port port
71 :nick nick
72 :password password
73 :channel channel
74 :channels channels
75 :db db))
(28 . 7)(28 . 7)- 29A3142E5A5A5B814921B49C16571B2D0359CDCA2DFDC9CA4463734F066B1E087A4ECECB6341F1667EF26F6A97B0B8CE326CEDAF2539D2CFD64CA4C3FB6551DF
80 create trigger log_insert_notify_trigger
81 after insert on log
82 for each row execute procedure log_insert_notify ();
83
84
85 create table outbox (
86 id serial primary key,
87 target text not null,
(38 . 7)(38 . 7)
89
90 create or replace function outbox_insert_notify () returns trigger as $$
91 begin
92 perform pg_notify('outbox_new_message', NEW.id::text);
93 perform pg_notify('outbox_new_message', NEW.target::text);
94 return NEW;
95 end;
96 $$ language plpgsql;
(11 . 10)(11 . 9)
101 :ircbot-disconnect
102 :ircbot-reconnect
103 :ircbot-connection
104 :ircbot-channel
105 :ircbot-channels
106 :ircbot-send-message
107 :ircbot-server
108 :ircbot-port
109 :ircbot-nick
110 :ircbot-lag))
111