aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/quarg.1
blob: d397eaf5a75d0d30c4d9d2ffcd1007b44acc842a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
.Dd May 8, 2021
.Dt QUARG 1
.Os
.Sh NAME
.Nm quarg
.Nd search Quassel logs for matching messages and print them
.Sh SYNOPSIS
.Nm
.Op Fl de
.Op Fl l Ar num
.Op Fl o Ar order
.Op Fl b Ar buffer
.Op Fl B Ar buftype
.Op Fl f Ar msgflag
.Op Fl m Ar prefix
.Op Fl n Ar nick
.Op Fl N Ar network
.Op Fl Q Ar user
.Op Fl t Ar msgtype
.Op Fl -after Ar date
.Op Fl -around Ar date Ns Op / Ns Ar range
.Op Fl -before Ar date
.Op Fl -joined | -no-joined
.Op Ar keyword Op Ar keyword ...
.Nm
.Fl h | -help
.Sh DESCRIPTION
.Nm
searches Quassel logs for messages matching a set of conditions and
prints the results.
See
.Sx CONNECTING TO QUASSEL
for more information on how to set up the database connection.
.Pp
A condition is any option from the
.Sx CONDITIONS
section.
At least one condition needs to be specified.
If multiple different types of conditions are given, all of them must
match.
The same condition can be specified multiple times with different
arguments, in which case it matches any of the arguments.
.Pp
If there are any results,
.Nm
prints each match using Quassel's message format, prefixed with the
timestamp in local time and the origin buffer of the message separated
by the tab
character.
.Pp
The options are as follows:
.Bl -tag -width Ds
.It Fl d
Prints additional debug information.
This includes the
.Em SELECT
statements executed by SQL as well as an internal representation of the
conditions passed to
.Nm .
.It Fl e
Interprets any
.Ar keyword
as a
.Em LIKE
expression.
This allows the use of the
.Sq %
placeholder.
If no placeholders are given, matches the
.Ar keyword
exactly.
.Pp
To match
.Sq %
literally, escape it with a backslash character.
.It Fl l Ar num
Limits the number of matches to
.Ar num .
.It Fl o Ar order
Specifies in which order to sort the messages.
Matches are always sorted by timestamp.
.Ar order
can be
.Sy asc
for ascending order or
.Sy desc
for descending order.
The default is
.Sy asc .
.Pp
This option is useful in conjunction with
.Fl l Ar num ,
as it may be used to have
.Nm
limit output to the oldest
.Pq Sy asc
or most recent
.Pq Sy desc
.Ar num
matches.
.It Fl h | -help
Shows the integrated help page and exits.
.El
.Sh CONDITIONS
The conditions are as follows:
.Bl -tag -width Ds
.It Ar keyword
Matches messages containing
.Ar keyword .
.It Fl b Ar buffer
Matches messages in a specific buffer, given by its name as displayed in
the Quassel client.
.It Fl B Ar buftype
Matches messages in buffers of a specific type.
.Pp
.Ar buftype
can be one of
.Sy channel ,
.Sy query ,
or
.Sy status ,
for channels, queries, and the status (or
.Dq network )
buffers respectively.
.It Fl f Ar msgflag
Matches messages of a specific context, given by a flag name.
.Pp
The flag names are as follows:
.Bl -tag -width Ds
.It Sy highlight
Messages that triggered Quassel's
.Dq Remote Highlight
rules.
By default this includes messages containing the current nickname.
.It Sy none
Messages that do not have any flag set.
.It Sy self
Messages that were sent by Quassel users themselves.
.El
.It Fl m Ar prefix
Matches messages sent by nicknames that have a specific channel
membership prefix as defined in the
.Sy Channel Membership Prefix section Ns No [1]
of the Modern IRC Client Protocol specification.
.Pp
Common prefixes include
.Sq @
for operators,
.Sq %
for half-ops, and
.Sq +
for voiced users.
.Pp
Note that multiple prefixes may be set at the same time (for example a
voiced operator).
In this case, any prefix will match, but the printed message will only
show the
.Dq highest
one.
.It Fl n Ar nick
Matches messages sent by a specific user, given by nickname.
.It Fl N Ar network
Matches messages in a specific network, given by its name as displayed
in the Quassel client.
.It Fl Q Ar user
Matches messages relating to a specific Quassel user, given by their
user name.
.Pp
This condition is only useful if the Quassel database contains logs
for multiple Quassel users.
Without this condition,
.Nm
matches messages from any Quassel user.
.It Fl t Ar msgtype
Matches messages of a specific type.
.Pp
.Ar msgtype
can be one of the following, corresponding to IRC messages as defined
in
.Sy RFC 1459 Ns No [2] :
.Sy invite ,
.Sy join ,
.Sy kick ,
.Sy kill ,
.Sy mode ,
.Sy nick ,
.Sy notice ,
.Sy part ,
.Sy privmsg ,
.Sy quit ,
.Sy topic .
.Pp
In addition,
.Nm
supports the following message types:
.Bl -tag -width Ds
.It Sy action
The CTCP ACTION message.
.It Sy error
Error messages as reported to the user by Quassel.
.It Sy netsplit_join
Messages indicating the end of a netsplit, along with the users who
rejoined.
.It Sy netsplit_quit
Messages indicating an ongoing netsplit, along with the users who quit.
.It Sy server
Server messages as reported to the user by Quassel.
.El
.It Fl -joined
Matches messages in channels that are currently joined.
.It Fl -no-joined
Matches messages in channels that are currently not joined.
.Pp
Note that as a result of the implementation in Quassel, this condition
matches all query buffers.
If this is undesirable, combine this condition with
.Fl B No channel .
.El
.Pp
In addition,
.Nm
supports matching on message timestamps.
Wherever a date is passed as an argument to a condition,
.Nm
parses it according to the
.Sy ISO-8601
standard.
.Pp
A date may include a time element and a time zone offset.
If no time zone offset is given, the date is assumed to be in local
time.
Refer to
.Sy dateutil's isoparse documentation Ns No [3]
for detailed information.
.Pp
The conditions that match on message timestamps are as follows:
.Bl -tag -width Ds
.It Fl -after Ar date
Matches messages that were sent after
.Ar date .
.It Fl -around Ar date Ns Op / Ns Ar range
Matches messages sent after
.Ar date -
.Ar range
and before
.Ar date +
.Ar range .
If
.Ar range
is not given, defaults to 12 hours.
.Pp
.Ar range
consists of a number and an optional suffix
.Sq h
for hours or
.Sq m
for minutes.
If no suffix is given, defaults to hours.
.Pp
For example,
.Dq 2021-02-18 20:55Z/10m
matches messages sent between 20:45 and 21:05.
This is equivalent to the following:
.Bd -literal -offset indent
quarg --after '2021-02-18 20:45Z' --before '2021-02-18 21:05Z'
.Ed
.Pp
This option cannot be used with
.Fl -after
or
.Fl -before .
.It Fl -before Ar date
Matches messages that were sent before
.Ar date .
.El
.Sh CONNECTING TO QUASSEL
In order to access Quassel's logs,
.Nm
needs access to the Quassel database.
The easiest way to achieve this is to have it running on the database
host and remotely invoke it using
.Xr ssh 1 .
Alternatively, the database port (or socket) may be forwarded to a local
machine
via
.Xr ssh 1
and used with a local
.Nm
instance.
.Pp
.Nm
uses SQLAlchemy which supports both SQLite and PostgreSQL backends.
The psycopg2 backend is recommended for the latter.
.Pp
If Quassel uses the PostgreSQL backend,
it is highly recommended to set up a read-only database role
specifically for
.Nm .
Furthermore, consider using the
.Sy Peer Authentication Ns No [4]
method with a dedicated user.
This type of authentication removes the need for a password and
also works over a forwarded connection.
.Pp
.Nm
reads the database URL from an INI-style configuration file.
See
.Sx FILES
for the location of this file.
The URL is specified in the
.Em Database
section using the
.Em url
key.
See
.Sy Database URLs Ns No [5]
for details on the URL format.
.Pp
The following is a valid configuration file specifying a connection to a
local PostgreSQL instance via its default socket:
.Bd -literal -offset indent
[Database]
url = postgresql+psycopg2://quarg@/quassel?host=/run/postgresql
.Ed
.Sh FILES
.Bl -tag -width Ds
.It Em $XDG_CONFIG_HOME/quarg/config
The configuration file for
.Nm .
.El
.Pp
.Nm
adheres to the XDG Base Directory Specification.
If $XDG_CONFIG_HOME is unset or empty, it will default to
.Em ~/.config
.Sh NOTES
.Bl -enum
.It
.Sy Channel Membership Prefixes
.Pp
https://modern.ircdocs.horse/#channel-membership-prefixes
.It
.Sy RFC 1459
.Pp
https://tools.ietf.org/html/rfc1459
.It
.Sy dateutil isoparse
.Pp
https://dateutil.readthedocs.io/en/stable/parser.html#dateutil.parser.isoparse
.It
.Sy Peer Authentication
.Pp
https://www.postgresql.org/docs/13/auth-peer.html
.It
.Sy Database URLs
.Pp
https://docs.sqlalchemy.org/en/14/core/engines.html#database-urls
.El
.Sh AUTHORS
.An -nosplit
.Nm
was written by
.An Wolfgang Müller Aq Mt wolf@oriole.systems