box.matto.nl
Enjoying Open Source Software

rcirc-sqlite - rcirc logging in SQLite

rcirc

rcirc is a default, simple IRC client in Emacs. It is included in GNU Emacs since release 22.1,

It allocates separate buffers for each server and channel, and includes tab completion and inbound message timestamps.

rcirc is a fine IRC client that is easy to configure and easy to work with.

Running an IRC client in your Emacs has several advantages, like the use of the standard Emacs buffer and window key bindings. Emacs copies from and pastes to the clipboard of your desktop system, so everything is neatly integrated.

Start rcirc with the command M-x irc.

When rcirc is not configured, it tries to connect to Libera Chat and to join the #rcirc channel on Libera Chat, using your username as nickname.

The normal IRC commands, like /join, /part, and /query will work, of course. However, rcirc comes with Emacsy key bindings that you can use to give that special Emacs feeling.

Join a channel with C-c C-j (rcirc-cmd-join) and leave a channel with C-c C-p (rcirc-cmd-part).

Start a private conversation with C-c C-q (rcirc-cmd-query).

To disconnect from the server use C-c C-x (rcirc-cmd-quit).

These are just a few examples of the commands. For a complete list of the available commands in rcirc, press C-h m in an rcirc buffer.

See the rcirc manual.

rcirc-sqlite

rcirc-sqlite is a minor mode that diverts the rcirc logs to a SQLite database.

rcirc-sqlite provides some options to run queries and to see some stats.

rcicq-sqlite makes use of the variable rcirc-log-time-format. This option is introduced in Emacs 30.

Install rcirc-sqlite from GNU ELPA

GNU ELPA provides rcirc-sqlite as a package.

Install it with use-package:

(use-package rcirc-sqlite
    :ensure t
    :config
    (add-hook 'rcirc-mode-hook #'rcirc-sqlite-log-mode))

The last line adds a hook to start rcirc-sqlite automatically when rcirc is started. The logs will be sent to the SQLite database. The default location for the SQLite database is ~/.emacs.d/rcirc-log.db.

Queries

Use the following commands to query the database.

  • M-x rcirc-sqlite-view-log: display the logs.
  • M-x rcirc-sqlite-text-search perform full text search in the logs.
  • M-x rcirc-sqlite-logs-from-nick display the logs from a specific nick.
  • M-x rcirc-sqlite-stats displays some stats.

rcirc-sqlite-view-log

Default this commands shows the last 200 messages, optionally narrowed to a specific channel, or month.

rcirc-sqlite-logs-from-nick

Display the logs from a specific nick.

Prompts:

  • for a nick
  • for a time range

Completion is used to choose a nick and a time range.

When a time range is chosen, only show the messages that were send in that specific range. Choose All channels to display everything.

rcirc-sqlite-text-search

Perform full text searches in the database.

Prompts:

  • for a search string
  • for a channel
  • for a time range
  • for a nick

Completion is used to choose a channel, a time range, or nick.

When a channel is chosen, the search is performed within the chat logs of that specific channel. Choose All channels to search everywhere.

When a time range is chosen, the search is performed within the messages that were send in that specific range. Choose Anytime to search everywhere.

When a nick is chosen, the search is performed within the chats of that specific nick. Choose All nicks to search independent of the sender.

The search string is used to do a full text search in the SQLite database. When the search string is foo, chat messages containing the word foo will be found, but chat messages containing the word foobar will not be found.

To search for both foo and foobar, use the search string foo*.

Likewise, to search for URLs, use something like "http://*" or "https://*" as search string, or for example "gopher://*". Because of the colon (:), the double quotes (") here are required.

rcirc-sqlite-stats

This command gives an overview of the number of messages in the database.

The user is prompted for a nick. Choose a nick through completion.

When a nick is chosen, the buffer *rcirc log* is opened where each channel with one or more chat messages from that nick is listed, together with the number of chat messages from that nick.

When All nicks is chosen, the buffer shows the row count for each channel in the database.

When Nicks per channel is chosen, the buffer shows for each channel the number of uniq nicks.

When Channels per nick is chosen, the buffer shows for each nick the number of channels with messages from this nick.

Use drill-down in the stats buffer to get more details, either by the "RET" key, or the left mouse button.

Key bindings in the buffer *rcirc log*

In the log buffer showing the channel, time, nick, and message a number of functions are available with the press of a single key.

First, select a message by moving point up or down. Next, use one of the following keys.

Key Action
RET Show logs of the channel and date of the selected message
> Same, but also include the next day
^ Same, but also include the previous day
a Same, but also include all following days
< Show logs of the channel,date, and nick of the selected message
c Copy the selected message, nicely formatted, to the kill-ring
R Insert the selected message, nicely formatted, into a register
r Same, but append to the register

The register to insert or append messages is default register r. A different register can be set as user option, with customize-group RET rcicq-sqlite.

Tags:

⇽ Shell script to create and sign certificates