File tree Expand file tree Collapse file tree 4 files changed +3
-19
lines changed Expand file tree Collapse file tree 4 files changed +3
-19
lines changed Original file line number Diff line number Diff line change @@ -459,11 +459,6 @@ builtinCommands =
459459 cmapR return $
460460 liftR (flip (liftM2 utcToLocalTime) now) $
461461 cmapR (T. pack . show ) $ Reaction replyMessage))
462- , ( " urlencode"
463- , mkBuiltinCommand
464- ( " !google URL encode"
465- , $ githubLinkLocationStr
466- , liftR (callFun " urlencode" . return ) $ ignoreNothing sayMessage))
467462 , ( " reloadmarkov"
468463 , mkBuiltinCommand
469464 ( " Reloads Markov model file"
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ import Data.Time
2424import Effect
2525import Entity
2626import HyperNerd.Parser
27+ import qualified Network.URI.Encode as URI
2728import Property
2829import Reaction
2930import Text.InterpolatedString.QM
@@ -174,6 +175,8 @@ evalExpr :: M.Map T.Text T.Text -> Expr -> T.Text
174175evalExpr _ (TextExpr t) = t
175176evalExpr vars (FunCallExpr " or" args) =
176177 fromMaybe " " $ listToMaybe $ dropWhile T. null $ map (evalExpr vars) args
178+ evalExpr vars (FunCallExpr " urlencode" args) =
179+ T. concat $ map (T. pack . URI. encode . T. unpack . evalExpr vars) args
177180evalExpr vars (FunCallExpr funame _) = fromMaybe " " $ M. lookup funame vars
178181
179182expandVars :: M. Map T. Text T. Text -> [Expr ] -> T. Text
Original file line number Diff line number Diff line change @@ -29,7 +29,6 @@ import Effect
2929import Free
3030import Markov
3131import Network.HTTP.Simple
32- import qualified Network.URI.Encode as URI
3332import qualified Sqlite.EntityPersistence as SEP
3433import System.IO
3534import System.Random
@@ -197,10 +196,6 @@ applyEffect (botState, Free (ReloadMarkov s)) = do
197196 markov <-
198197 runMaybeT (MaybeT (return $ bsMarkovPath botState) >>= lift . loadMarkov)
199198 return (botState {bsMarkov = markov}, s (" Reloaded the model" <$ markov))
200- applyEffect (botState, Free (GetVar _ s)) = return (botState, s Nothing )
201- applyEffect (botState, Free (CallFun " urlencode" [text] s)) =
202- return (botState, s $ Just $ T. pack $ URI. encode $ T. unpack text)
203- applyEffect (botState, Free (CallFun _ _ s)) = return (botState, s Nothing )
204199applyEffect (botState, Free (RandomEff range s)) = do
205200 v <- randomRIO range
206201 return (botState, s v)
Original file line number Diff line number Diff line change @@ -27,7 +27,6 @@ module Effect
2727 , twitchCommand
2828 , randomMarkov
2929 , reloadMarkov
30- , callFun
3130 , githubApiRequest
3231 , randomEff
3332 ) where
@@ -112,11 +111,6 @@ data EffectF s
112111 s
113112 | RandomMarkov (Maybe T. Text -> s )
114113 | ReloadMarkov (Maybe T. Text -> s )
115- | GetVar T. Text
116- (Maybe T. Text -> s )
117- | CallFun T. Text
118- [T. Text ]
119- (Maybe T. Text -> s )
120114 | RandomEff (Int , Int )
121115 (Int -> s )
122116 deriving (Functor )
@@ -204,8 +198,5 @@ randomMarkov = liftF $ RandomMarkov id
204198reloadMarkov :: Effect (Maybe T. Text )
205199reloadMarkov = liftF $ ReloadMarkov id
206200
207- callFun :: T. Text -> [T. Text ] -> Effect (Maybe T. Text )
208- callFun name args = liftF $ CallFun name args id
209-
210201randomEff :: (Int , Int ) -> Effect Int
211202randomEff range = liftF $ RandomEff range id
You can’t perform that action at this time.
0 commit comments