--------------------------------------------------------------------------------
storeHook :: Irc ()
storeHook = onCommand "PRIVMSG" $ do
    host         <- getHost
    channel      <- getChannel
    sender       <- toLower <$> getSender
    IrcTime time <- liftIO getTime
    text         <- getMessageText
    withDatabase $ \db -> do
        r <- Sqlite.query db
            "SELECT id FROM seen  \
            \WHERE host = ? AND channel = ? AND sender = ?"
            (host, channel, sender)
        case r of
            -- In the database: update
            [Sqlite.Only id'] -> Sqlite.execute db
                "UPDATE seen SET time = ?, text = ? WHERE id = ?"
                (time, text, id' :: Integer)
            -- Not yet in the database: insert
            _ -> Sqlite.execute db
                "INSERT INTO seen (host, channel, sender, time, text)  \
                \VALUES (?, ?, ?, ?, ?)"
                (host, channel, sender, time, text)
    return ()


--------------------------------------------------------------------------------
storeHook :: Irc ()
storeHook = onCommand "PRIVMSG" $ do
    host         <- getHost
    channel      <- getChannel
    sender       <- toLower <$> getSender
    IrcTime time <- liftIO getTime
    text         <- getMessageText
    withDatabase $ \db -> do
        r <- Sqlite.query db
            "SELECT id FROM seen  \
            \WHERE host = ? AND channel = ? AND sender = ?"
            (host, channel, sender)
        case r of
            -- In the database: update
            [Sqlite.Only id'] -> Sqlite.execute db
                "UPDATE seen SET time = ?, text = ? WHERE id = ?"
                (time, text, id' :: Integer)
            -- Not yet in the database: insert
            _ -> Sqlite.execute db
                "INSERT INTO seen (host, channel, sender, time, text)  \
                \VALUES (?, ?, ?, ?, ?)"
                (host, channel, sender, time, text)
    return ()


--------------------------------------------------------------------------------
storeHook = onCommand "PRIVMSG" $ do
    host         <- getHost
    channel      <- getChannel
    sender       <- toLower <$> getSender
    IrcTime time <- liftIO getTime
    text         <- getMessageText
    withDatabase $ \db -> do
        r <- Sqlite.query db
            "SELECT id FROM seen  \
            \WHERE host = ? AND channel = ? AND sender = ?"
            (host, channel, sender)
        case r of
            -- In the database: update
            [Sqlite.Only id'] -> Sqlite.execute db
                "UPDATE seen SET time = ?, text = ? WHERE id = ?"
                (time, text, id' :: Integer)
            -- Not yet in the database: insert
            _ -> Sqlite.execute db
                "INSERT INTO seen (host, channel, sender, time, text)  \
                \VALUES (?, ?, ?, ?, ?)"
                (host, channel, sender, time, text)
    return ()


--------------------------------------------------------------------------------