Commit 51e6bac1 authored by Nicolas Lenz's avatar Nicolas Lenz

Use hash of input and style for InlineReply id

parent 716d2f5e
Pipeline #191 failed with stage
in 1 minute and 30 seconds
......@@ -17,6 +17,7 @@ import Telegram.Bot.API.InlineMode
import Control.Monad.Reader
import Text.Mock
import Text.Mock.Help (styleHelp)
import Crypto.Hash
import System.IO.Unsafe
......@@ -71,10 +72,14 @@ replyToInline = UpdateParser f where
f update = do
inlineQuery <- Telegram.updateInlineQuery update
let txt = Telegram.inlineQueryQuery inlineQuery
let id = Telegram.inlineQueryId inlineQuery
--let id = Telegram.inlineQueryId inlineQuery
if T.empty == txt
then return []
else return $ map (\(name, f) -> (name, f txt, name <> id)) styles
else return $ map (\(name, f) -> (
name,
f txt,
T.pack $ show (hash $ T.encodeUtf8 (name <> txt) :: Digest SHA256)
)) styles
-- |Concatenates a list of Maybe functions. Execution goes from left to right.
......@@ -121,7 +126,7 @@ run token = do
main :: IO ()
main = T.readFile "config/token" >>= run . T.dropWhileEnd isSpace
-- |Help string.
-- | Help string.
help :: T.Text
help = T.unlines [
"*Mock " <> version <> "*",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment