Skip to content

fade/harlie

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

721 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Harlie

With respect to David Gerrold’s When HARLIE Was One.

Harlie is a multi-channel IRC bot written in Common Lisp. It maintains persistent user state in PostgreSQL, shortens and annotates URLs, learns from conversation using a Markov chainer, and serves a small web interface per channel showing the URL archive and bot source.

Features

  • Connects to multiple IRC servers and channels simultaneously, each with its own nick and web port
  • Auto-reconnect with exponential backoff and keepalive PING
  • NickServ authentication and registration via an event-driven state machine
  • URL shortener with title fetching, UTM-parameter stripping, and a per-channel web archive
  • Markov-chain text generation (!babble, !haiku) with per-channel contexts
  • Memo system (!tell, !memos) for leaving messages for offline users
  • METAR weather lookups (!metar)
  • Wikipedia, dictionary, GitHub, and timezone lookups (!wiki, !define, !gh, !tz)
  • Channel quote database (!addquote, !quote)
  • Per-user and per-channel persistent state in PostgreSQL
  • Built-in web server (Hunchentoot) per context
  • Slynk REPL server for live inspection (slynky)
  • Cron-style scheduled tasks

Requirements

RequirementNotes
SBCLTested on current releases
QuicklispFor library loading
PostgreSQL14+ recommended; bot uses Unix socket auth
clatter-ircglenneth1/clatter-irc — clone to a path
visible to ASDF’s source registry

All other Lisp dependencies are fetched by Quicklisp.

Quickstart

1. Create the database

createdb botdb
sed 's/<bot_runner_uid>/YOUR_UNIX_USER/g' \
    database/bot-schema.sql.template > database/bot-schema.sql
psql botdb -f database/bot-schema.sql

2. Configure the bot

Copy config-template.lisp to config.lisp and edit it:

(defparameter *bot-config*
  (make-config
   :db-credentials  (list "botdb" (uiop:getenv "USER") nil :unix)
   :web-server-name "localhost"
   :connections
   (list
    (make-connection-spec
     :server  "irc.libera.chat" :ssl t
     :nick    "MyBot"
     :channel "#mychannel"
     :web-port 9000))))

NickServ credentials should come from the environment, never from literals:

(make-connection-spec
 ...
 :nickserv-password (uiop:getenv "HARLIE_NICKSERV_PASSWORD")
 :nickserv-email    (uiop:getenv "HARLIE_NICKSERV_EMAIL"))
export HARLIE_NICKSERV_PASSWORD="your-nickserv-password"
export HARLIE_NICKSERV_EMAIL="your@email.com"

3. Load and start the bot

(ql:quickload :harlie)
(in-package :harlie)
(run-bot)

To also open a Slynk REPL for live inspection:

(slynky :port 4007)

4. Stop the bot

(kill-bot)

Running the Tests

A test database is required. Create it once:

createdb harlie-test
pg_dump botdb --schema-only | psql harlie-test

Then from a Lisp image:

(asdf:test-system :harlie)

This runs the complete test suite: NickServ flow integration tests, pure-function unit tests, and database integration tests. All tests target harlie-test; the production botdb database is never touched.

See the Operator’s Manual, §Testing, for a full description of the test suite architecture.

Configuration Reference

make-config accepts:

KeyTypePurpose
:db-credentialslistPostmodern connection spec (db user pw host)
:web-server-namestringHostname for web server Location: headers
:connectionslistOne make-connection-spec per channel

make-connection-spec accepts:

KeyRequiredDefaultPurpose
:serveryesIRC server hostname
:nickyesBot nick
:channelyesChannel to join
:sslnonilUse TLS
:web-portnonilHunchentoot port for this context
:channel-keynonilChannel password
:nickserv-passwordnonilNickServ IDENTIFY password
:nickserv-emailnonilNickServ REGISTER email
:extra-channelsnonilList of additional channels to join

IRC Commands

CommandEffect
!helpList available commands
!help CMDShow help for a specific command
!babbleGenerate text via Markov chain
!haikuGenerate a haiku
!metar ICAOFetch weather for airport ICAO code
!statusShort status report
!status fullFull status including chainer phrase count
!tell USER MSGLeave a message for USER, delivered on return
!memosCheck your pending memos
!wiki TOPICWikipedia summary
!define WORDDictionary definition
!tz TIMEZONECurrent time in a timezone
!gh OWNER/REPOGitHub repository summary
!addquote TEXTSave a channel quote
!quoteRecall a random quote
!quote NRecall quote number N
!uptimeHow long the bot has been running
!seen USERWhen a user was last seen speaking
!remind TIME MSGSet a reminder (e.g. !remind 30m check build)
!rpn EXPRRPN calculator

License

See LICENSE.

About

An irc robot that chats using markov chains, and which exports several channel support functions.

Resources

License

Unknown, GPL-3.0 licenses found

Licenses found

Unknown
LICENSE
GPL-3.0
COPYING

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors