Skip to content

Commit bc039b0

Browse files
committed
Introduce builtin urlencode function
1 parent a57eb40 commit bc039b0

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/Bot/CustomCommand.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import Property
2828
import Reaction
2929
import Text.InterpolatedString.QM
3030
import Transport
31+
import qualified Network.URI.Encode as URI
3132

3233
data CustomCommand = CustomCommand
3334
{ customCommandName :: T.Text
@@ -174,6 +175,8 @@ evalExpr :: M.Map T.Text T.Text -> Expr -> T.Text
174175
evalExpr _ (TextExpr t) = t
175176
evalExpr 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
177180
evalExpr vars (FunCallExpr funame _) = fromMaybe "" $ M.lookup funame vars
178181

179182
expandVars :: M.Map T.Text T.Text -> [Expr] -> T.Text

0 commit comments

Comments
 (0)