Responding to IRC messages

Another way to interact with IRC in Haskell is by using the Network.SimpleIRC package. This package encapsulates much of the low-level networking and also provides useful IRC interfaces.

In this recipe, we will respond to messages in a channel. If any user types in the trigger phrase, in our case "host?", then we will reply to that user with their host address.

Getting ready

Install the Network.SimpleIRC package:

$ cabal install simpleirc

To test out the IRC bot, it is helpful to install an IRC client. A decent IRC client is Hexchat, which can be downloaded from http://hexchat.github.io. For a terminal-based IRC client, Irssi is one of the best: http://www.irssi.org.

How to do it…

Create a new file, which we call Main.hs ...

Get Haskell Data Analysis Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.