From 80455d20ec46451b8501ace5ba7458a2d8632bcd Mon Sep 17 00:00:00 2001 From: Jon Doe Date: Sat, 26 Sep 2020 22:39:52 +0200 Subject: [PATCH] actually print the tcl results, remove dumb flood limit --- src/Carrion/Plugin/IO/IRC/Client.hs | 17 ++++++++++++++--- src/GypsFulvus.hs | 8 ++++++-- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/Carrion/Plugin/IO/IRC/Client.hs b/src/Carrion/Plugin/IO/IRC/Client.hs index 005e155..d6bee08 100644 --- a/src/Carrion/Plugin/IO/IRC/Client.hs +++ b/src/Carrion/Plugin/IO/IRC/Client.hs @@ -17,7 +17,7 @@ import Control.Lens import Control.Concurrent(threadDelay,forkIO) import qualified Data.Text as T import Control.Concurrent.STM -import Control.Monad(liftM) +import Control.Monad(liftM,forever) import Data.Monoid import qualified Data.Map as M import Data.ByteString(ByteString) @@ -175,11 +175,22 @@ initPlugin mh = do } detectCommandHandler' = detectCommandHandler mh - conn = tlsConnection $ WithClientConfig myClientConfig + conn = (tlsConnection $ WithClientConfig myClientConfig) & flood .~ 0 myNNS <- atomically $ newTMVar M.empty let namesReplyHandler' = namesReplyHandler mh myNNS rejoinOnKickHandler = fYourKickHandler myNNS mySpecialHandlers = [rejoinOnKickHandler,detectCommandHandler',joinHandler',namesReplyHandler',otherJoinHandler,otherPartHandler] cfg = defaultInstanceConfig myNickname & channels %~ (myChannels ++) & handlers %~ (++ mySpecialHandlers) - forkIO $ runClient conn cfg () + myIRCState <- newIRCState conn cfg () + forkIO $ runClientWith myIRCState + forkIO $ acceptExternalComms myIRCState mh return GoodInitStatus + +acceptExternalComms myIRCState manhole = + let inspectManhole = atomically . readTChan . getInputChan + regift g = atomically . (flip writeTChan g) . getOutputChan in + forever $ do + newGift <- liftIO $ inspectManhole manhole + runIRCAction (mapM (\fff -> send $ Privmsg "#exquisitebot" $ Right fff) (nlSplit $ getSewage newGift)) myIRCState + +nlSplit = T.splitOn "\n" diff --git a/src/GypsFulvus.hs b/src/GypsFulvus.hs index 37b0969..732ab82 100644 --- a/src/GypsFulvus.hs +++ b/src/GypsFulvus.hs @@ -68,7 +68,7 @@ lookupManholeInSewer s p = do corePlugName :: T.Text corePlugName = "core" - +mySignature = GenericStyleAutor corePlugName "local" "local" isIOPlugin :: Sewage -> TMVar IOPIDS -> IO Bool isIOPlugin sewage iopids = let pname = (hash . getName .nsAutorToGenericAutor . getSewageAutor $ sewage) @@ -90,7 +90,11 @@ runForever s cmap iopids = amIIO <- isIOPlugin someGarbage iopids if (amIIO) then trySendToWorker s someGarbage cmap - else return () + else do + pm <- atomically $ lookupManholeInSewer s "IRC-Simple" + case pm of + Just pm -> regiftToWorker someGarbage pm + Nothing -> return () putStrLn $ T.pack theAutor ++ " sez:" putStrLn $ theSewage