-
Book Overview & Buying
-
Table Of Contents
Haskell Data Analysis cookbook
By :
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.
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.
Create a new file, which we call Main.hs, and do the following:
{-# LANGUAGE OverloadedStrings #-}
import Network.SimpleIRC
import Data.Maybe
import qualified Data.ByteString.Char8 as B
Change the font size
Change margin width
Change background colour