mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2025-06-28 12:19:54 +00:00
apps: update chat bots, readme (#1928)
* apps: update chat bots, readme * CLI readme * broadcast bot * delete messages from non-publishers, better replies, support forwarding low-res images and links * typo Co-authored-by: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com> * change --------- Co-authored-by: spaced4ndy <8711996+spaced4ndy@users.noreply.github.com>
This commit is contained in:
parent
6f68840b3a
commit
a0351d6f99
16 changed files with 332 additions and 17 deletions
|
@ -14,11 +14,14 @@ main :: IO ()
|
|||
main = do
|
||||
opts <- welcomeGetOpts
|
||||
simplexChatCore terminalChatConfig opts Nothing $
|
||||
chatBotRepl "Hello! I am a simple squaring bot - if you send me a number, I will calculate its square" $ \msg ->
|
||||
case readMaybe msg :: Maybe Integer of
|
||||
chatBotRepl welcomeMessage $ \_contact msg ->
|
||||
pure $ case readMaybe msg :: Maybe Integer of
|
||||
Just n -> msg <> " * " <> msg <> " = " <> show (n * n)
|
||||
_ -> "\"" <> msg <> "\" is not a number"
|
||||
|
||||
welcomeMessage :: String
|
||||
welcomeMessage = "Hello! I am a simple squaring bot.\nIf you send me a number, I will calculate its square"
|
||||
|
||||
welcomeGetOpts :: IO ChatOpts
|
||||
welcomeGetOpts = do
|
||||
appDir <- getAppUserDataDirectory "simplex"
|
||||
|
|
17
apps/simplex-bot/README.md
Normal file
17
apps/simplex-bot/README.md
Normal file
|
@ -0,0 +1,17 @@
|
|||
# Simple SimpleX Chat bot example
|
||||
|
||||
This chat bot is a Haskell implementation of a REPL chat bot.
|
||||
|
||||
All you have to do to create your bot based on this example is to provide a welcome message for connecting users and a function of type `Contact -> String -> IO String`. This function should transform the sent message into a reply message, ignoring any system messages related to preferences and user profile changes.
|
||||
|
||||
This bot example calculates the square of the number that is sent to it, but you can program it to do other things, simply by changing REPL function:
|
||||
|
||||
- a more advanced calculator (e.g., based on [this one](https://github.com/jonathanknowles/haskell-calculator)).
|
||||
- translation to/from any language.
|
||||
- lookup of market quotes.
|
||||
- search of the information.
|
||||
- AI-powered dialogue – the bot can maintain any conversation state based on the contact.
|
||||
- provide any other online service via chat UI.
|
||||
- etc.
|
||||
|
||||
Please share any bots you create with us, we will add to this page and can host them if you like!
|
Loading…
Add table
Add a link
Reference in a new issue