diff options
| author | Teddy Wing | 2017-08-13 14:13:40 +0200 | 
|---|---|---|
| committer | Teddy Wing | 2017-08-13 14:13:40 +0200 | 
| commit | 9d034f464797fd469053ba00ed28f571e0677a86 (patch) | |
| tree | cf51e450889e128d3bec97c5c7fd464b72a99850 /src | |
| parent | c32e5e1b8384c843ad750acff81f671d2b98777a (diff) | |
| download | sorbot-9d034f464797fd469053ba00ed28f571e0677a86.tar.bz2 | |
Lib.hs: Test chat message listening and posting
Add an event handler that gets called when a message is posted to a
channel the bot is on. When a message is posted, the bot will send a
chat message containing the text "test".
This tests out the message handling and posting mechanism, and gives us
a place to build off of to allow the bot to communicate.
Diffstat (limited to 'src')
| -rw-r--r-- | src/Lib.hs | 12 | 
1 files changed, 10 insertions, 2 deletions
| @@ -33,8 +33,16 @@ connectIRC :: B.ByteString -> Int -> T.Text -> IO ()  connectIRC host port nick = do      conn <- IRC.connectWithTLS host port 1      let cfg = IRC.defaultIRCConf nick -    -- let cfg' = cfg { _eventHandlers = yourCustomEventHandlers : _eventHandlers cfg }      let cfg' = cfg { -          IRC._channels = ["#test-chan-13513"] +          IRC._eventHandlers = handlePrivmsg : IRC._eventHandlers cfg +        , IRC._channels = ["#test-chan-13513"]          }      IRC.start conn cfg' + +handlePrivmsg :: IRC.EventHandler s +handlePrivmsg = IRC.EventHandler +    { IRC._description = "" +    , IRC._matchType = IRC.EPrivmsg +    , IRC._eventFunc = \evt -> +        IRC.send $ IRC.Privmsg "#test-chan-13513" (Right "test") +    } | 
