EPIC is an IRC client has been under active development for 25+ years. It started life as a fork of ircii and while it has retained the spirit of ircii it has continued on into the modern age. Some of the modern features it has adopted includes UTF-8 support, modularity, and the ability to use scripting languages other than ircII. EPIC is not a polished client out of the box, it’s more like an erector set that lets you build exactly the irc client you want.
I have worked extensively with EPIC’s author, Jeremy Nelson, to help implement “Python support that doesn’t suck.”
EPIC has long support calling into Perl and TCL by using the $perl()
and $tcl()
functions. While these are useful for executing single statements, and can be used to import more complex functionality, the text-only interface and one-way nature of these functions meant they largely went unused.
Sometime in 2015 Jeremy was challenged to learn Python by someone he respected, and as he did so he explored integrating it into EPIC. I expressed to him my opinions about why Perl and TCL were never really used in EPIC, and suggested that Python was different enough that simply adding a $python()
function and calling it a day were not enough. Over the next few months we worked on and off on what “Python support that doesn’t suck” will look like.
Since EPIC is already a full-featured TUI with its own event loop and handlers we embedded Python into EPIC. This is the inverse of what most programs do when Python and C are integrated into the same program. This means that EPIC owns main()
and is responsible for dispatching to Python as needed.
EPIC provides a low-level C module to Python called _epic
that has interfaces for registering Commands, Event Handlers, and FD Callbacks, as well as commands for printing to the user’s screen and executing raw ircii
commands. On top of that I built a high-level Python module that exposes that functionality to Python modules at a high level. The high level epic
module provides the following facilities:
logging
supportSocketServerMixin
to allow most Python SocketServers to work with EPIC/set
so users can control the behavior of your moduleI wrote a practical script that demonstrates the facilities the Python support has. That script registers the function url_handler(args)
as an event handler for various message types as well as an alias the user can type at the command line. It creates an HTTP server that listens on port 8080 and will redirect you to any URLs that are detected in your chats.