aboutsummaryrefslogtreecommitdiffstats
path: root/src/Lib.hs
diff options
context:
space:
mode:
authorTeddy Wing2017-08-16 01:04:28 +0200
committerTeddy Wing2017-08-16 01:04:28 +0200
commita0d21d9aed3a38e98e622fbae5fcab3e91c5ddee (patch)
tree4142d51a8d443153a2e86dd460e40d0e897c0fd6 /src/Lib.hs
parent5f157d66a001224fd623b63e92505aa058599942 (diff)
downloadsorbot-a0d21d9aed3a38e98e622fbae5fcab3e91c5ddee.tar.bz2
Connect plugins to IRC
Instead of sending a hard-coded string message over IRC, now invoke our plugin list. Now, IRC messages get matched against our plugin list, and if any plugin matches, its return string gets posted to the appropriate channel. Move the database connection inside the plugin so that we can continue to access it without having to pass in the DB connection. I didn't want to connect to the database in the IRC code because it doesn't relate, and I don't have a good enough grasp of monads to know if I can create the connection in "Lib.hs" and "pass" it to the IRC message handler to then pass it into the plugins. Moving the database connection inside the plugins means that it no longer takes a database connection as an argument. The IRC message handler now has a lot of duplication, but it basically works, which is super exciting! Took a _long_ time to figure out the proper way to get the types to line up and get this compiling, but really glad it's working now! The magic function turned out to be `liftIO` to extract the `Either String String` out of its `IO` monad wrapper to be fed to the `IRC.send` function. Not a fan of the type conversion between `String` and `Data.Text`, so we'll eventually have to convert our plugins to use `Data.Text`.
Diffstat (limited to 'src/Lib.hs')
-rw-r--r--src/Lib.hs2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/Lib.hs b/src/Lib.hs
index f72729e..b23bf78 100644
--- a/src/Lib.hs
+++ b/src/Lib.hs
@@ -20,7 +20,7 @@ someFunc = do
-- }
-- Just plugin = matchPlugin message
-- dbConn <- open "db/sorbot_development.sqlite3"
- -- response <- performPlugin plugin message dbConn
+ -- response <- performPlugin plugin message
-- putStrLn $ case response of
-- Left e -> e
-- Right r -> r