diff options
| author | Teddy Wing | 2017-08-20 17:28:18 +0200 | 
|---|---|---|
| committer | Teddy Wing | 2017-08-20 17:28:18 +0200 | 
| commit | 9307d2f5a1531f4a89264207be482cc23382908c (patch) | |
| tree | cf1a8a3501fd5b8ce5c7f671977f6d189b2c5352 /src | |
| parent | 3124acd6ae0328a8607d0807e4923f0dd75fe49e (diff) | |
| download | sorbot-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')
| -rw-r--r-- | src/IRC.hs | 43 | 
1 files changed, 22 insertions, 21 deletions
| @@ -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. | 
