Commit 51e6bac1 authored by Nicolas Lenz's avatar Nicolas Lenz ❄️
Browse files

Use hash of input and style for InlineReply id

parent 716d2f5e
Loading
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -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.