aboutsummaryrefslogtreecommitdiffstats
path: root/src/IRC.hs
diff options
context:
space:
mode:
authorTeddy Wing2017-08-20 17:28:18 +0200
committerTeddy Wing2017-08-20 17:28:18 +0200
commit9307d2f5a1531f4a89264207be482cc23382908c (patch)
treecf1a8a3501fd5b8ce5c7f671977f6d189b2c5352 /src/IRC.hs
parent3124acd6ae0328a8607d0807e4923f0dd75fe49e (diff)
downloadsorbot-9307d2f5a1531f4a89264207be482cc23382908c.tar.bz2
IRC: Only require "sorbot: " prefix in channels
When talking with the bot in a private one-to-one query, there's no reason to use the "sorbot: " prefix because you're not talking to anyone else. In that case, just behave like we did before and allow users to send commands with no prefix.
Diffstat (limited to 'src/IRC.hs')
-rw-r--r--src/IRC.hs43
1 files changed, 22 insertions, 21 deletions
diff --git a/src/IRC.hs b/src/IRC.hs
index 53f6969..d67f28e 100644
--- a/src/IRC.hs
+++ b/src/IRC.hs
@@ -50,30 +50,31 @@ handlePrivmsg = IRC.EventHandler
, channel = chan
, nick = nick
}
- response <- liftIO $ privmsgFromPlugin message
- case response of
- Nothing -> return ()
- Just r -> sequence_ r
+ case messageForBot message of
+ Nothing -> return ()
+ Just message -> do
+ response <- liftIO $ privmsgFromPlugin message
+ case response of
+ Nothing -> return ()
+ Just r -> sequence_ r
privmsgFromPlugin :: Message -> IO (Maybe [IRC.StatefulIRC s ()])
privmsgFromPlugin message = do
- case messageForBot message of
- Nothing -> return Nothing
- Just message -> case matchPlugin message of
- Nothing -> return Nothing
- Just plugin -> do
- response <- liftIO $ performPlugin plugin message
- return $ case response of
- Left err -> Just $
- [IRC.send $ IRC.Privmsg
- (toChannel plugin message)
- (Right err)]
- Right r -> Just $
- map (\r ->
- IRC.send $ IRC.Privmsg
- (toChannel plugin message)
- (Right r) )
- (splitAtNewlines $ splitLongLines r)
+ case matchPlugin message of
+ Nothing -> return Nothing
+ Just plugin -> do
+ response <- liftIO $ performPlugin plugin message
+ return $ case response of
+ Left err -> Just $
+ [IRC.send $ IRC.Privmsg
+ (toChannel plugin message)
+ (Right err)]
+ Right r -> Just $
+ map (\r ->
+ IRC.send $ IRC.Privmsg
+ (toChannel plugin message)
+ (Right r) )
+ (splitAtNewlines $ splitLongLines r)
where
-- IRC only permits 512 bytes per line. Use less to allow for protocol
-- information that gets sent in addition to the message content.