aboutsummaryrefslogtreecommitdiffstats
path: root/src/IRC.hs
diff options
context:
space:
mode:
authorTeddy Wing2017-08-17 00:35:24 +0200
committerTeddy Wing2017-08-17 00:35:24 +0200
commitf4028e21f8a138961927b8e794b349f209b00dc7 (patch)
treef1099c1cd6ebd511a0a6d52c99c0545238be1a21 /src/IRC.hs
parente9278eb0a1c0126e6903f333ed4efa5dd00ff5cc (diff)
downloadsorbot-f4028e21f8a138961927b8e794b349f209b00dc7.tar.bz2
Change `Plugin` and `Message` from `String` to `Data.Text`
Use the `Data.Text` type instead of `String` in most of the places we use it in `Plugin` and `Message`. This allows us to more easily pass data between the IRC package. No more kludgy `pack`s and `unpack`s in our IRC message handler. The one thing we couldn't convert was our regex. From what I understand (https://stackoverflow.com/questions/14922579/haskell-regular-expressions-and-data-text#14922626), the regex library I'm using doesn't support `Data.Text`, so use `String`s for that instead.
Diffstat (limited to 'src/IRC.hs')
-rw-r--r--src/IRC.hs20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/IRC.hs b/src/IRC.hs
index b941982..70bbc7d 100644
--- a/src/IRC.hs
+++ b/src/IRC.hs
@@ -32,9 +32,9 @@ handlePrivmsg = IRC.EventHandler
where
dispatchEvent (IRC.Event _ (IRC.User nick) (IRC.Privmsg _ (Right msg))) = do
let message = Message
- { text = T.unpack msg
- , channel = T.unpack nick
- , nick = T.unpack nick
+ { text = msg
+ , channel = nick
+ , nick = nick
}
response <- liftIO $ privmsgFromPlugin message
case response of
@@ -43,9 +43,9 @@ handlePrivmsg = IRC.EventHandler
dispatchEvent (IRC.Event
_ (IRC.Channel chan nick) (IRC.Privmsg _ (Right msg))) = do
let message = Message
- { text = T.unpack msg
- , channel = T.unpack chan
- , nick = T.unpack nick
+ { text = msg
+ , channel = chan
+ , nick = nick
}
response <- liftIO $ privmsgFromPlugin message
case response of
@@ -60,8 +60,8 @@ privmsgFromPlugin message = do
response <- liftIO $ performPlugin plugin message
return $ case response of
Left err -> Just $ IRC.send $ IRC.Privmsg
- (T.pack (channel message))
- (Right (T.pack err))
+ (channel message)
+ (Right err)
Right r -> Just $ IRC.send $ IRC.Privmsg
- (T.pack (channel message))
- (Right (T.pack r))
+ (channel message)
+ (Right r)