aboutsummaryrefslogtreecommitdiffstats
path: root/src/Lib.hs
diff options
context:
space:
mode:
authorTeddy Wing2017-08-13 14:13:40 +0200
committerTeddy Wing2017-08-13 14:13:40 +0200
commit9d034f464797fd469053ba00ed28f571e0677a86 (patch)
treecf51e450889e128d3bec97c5c7fd464b72a99850 /src/Lib.hs
parentc32e5e1b8384c843ad750acff81f671d2b98777a (diff)
downloadsorbot-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/Lib.hs')
-rw-r--r--src/Lib.hs12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/Lib.hs b/src/Lib.hs
index 63b6367..06745ba 100644
--- a/src/Lib.hs
+++ b/src/Lib.hs
@@ -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")
+ }