Skip to content

Instantly share code, notes, and snippets.

@thelissimus
Created June 27, 2024 16:12
Show Gist options
  • Save thelissimus/918ddbb5f33a045b51ab28a84d40d5a9 to your computer and use it in GitHub Desktop.
Save thelissimus/918ddbb5f33a045b51ab28a84d40d5a9 to your computer and use it in GitHub Desktop.
Example of telegram-bot-simple issue with sendMessageMessageEffectId
{-# LANGUAGE OverloadedStrings #-}
module Assistant (module Assistant) where
import Data.Kind (Type)
import Data.Text (Text)
import Telegram.Bot.API (Token (..), Update, defaultTelegramClientEnv)
import Telegram.Bot.Simple (BotApp (..), startBot_, (<#))
import Telegram.Bot.Simple qualified as TBS
import Telegram.Bot.Simple.Debug (traceBotDefault)
import Telegram.Bot.Simple.UpdateParser (updateMessageText)
type Model :: Type
type Model = ()
type Action :: Type
data Action
= ActionHoogleSearch Text
deriving stock (Show)
assistantBot :: BotApp Model Action
assistantBot =
BotApp
{ botInitialModel = ()
, botAction = updateToAction
, botHandler = handleAction
, botJobs = []
}
updateToAction :: Update -> Model -> Maybe Action
updateToAction update _ = ActionHoogleSearch <$> updateMessageText update
handleAction :: Action -> Model -> TBS.Eff Action Model
handleAction action model = case action of
ActionHoogleSearch str ->
model <# do
-- todo
pure str
run :: IO ()
run = do
env <- defaultTelegramClientEnv (Token "<hidden>")
startBot_ (traceBotDefault assistantBot) env
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment