glirc-2.15: Console IRC client

Copyright(c) Eric Mertens, 2016
Safe HaskellNone




This module is responsible for tracking the state of an individual IRC connection while the client is connected to it. This state includes user information, server settings, channel membership, and more.

This module is more complicated than many of the other modules in the client because it is responsible for interpreting each IRC message from the server and updating the connection state accordingly.


Connection state

data NetworkState Source #

State tracked for each IRC connection




newNetworkState Source #


:: NetworkId

unique network ID

-> Text

network name

-> ServerSettings

server settings

-> NetworkConnection

active network connection

-> PingStatus

initial ping status

-> NetworkState

new network state

Construct a new network state using the given settings and default values as specified by the IRC specification.


User information

data UserAndHost Source #

Pair of username and hostname. Empty strings represent missing information.


UserAndHost !Text !Text

username hostname

Cross-message state

Connection predicates

iHaveOp :: Identifier -> NetworkState -> Bool Source #

Predicate to test if the connection has op in a given channel.

Messages interactions

sendMsg :: NetworkState -> RawIrcMsg -> IO () Source #

Transmit a RawIrcMsg on the connection associated with the given network. For PRIVMSG and NOTICE overlong commands are detected and transmitted as multiple messages.

squelchIrcMsg :: IrcMsg -> Bool Source #

Return True for messages that should be hidden outside of full detail view. These messages are interpreted by the client so the user shouldn't need to see them directly to get the relevant information.

Timer information

data PingStatus Source #

Status of the ping timer


PingSent !UTCTime

ping sent waiting for pong

PingLatency !Double

latency in seconds for last ping


no ping sent

PingConnecting !Int !(Maybe UTCTime)

number of attempts, last known connection time

nextTimedAction :: NetworkState -> Maybe (UTCTime, TimedAction) Source #

Compute the earliest timed action for a connection, if any

applyTimedAction :: TimedAction -> NetworkState -> IO NetworkState Source #

Apply the given TimedAction to a connection state.