F# Telegram Bot Api library!
Firstly you need to install Funogram. Installation for .NET Core users:
dotnet add package Funogram
Installation for .NET Framework users:
Install-Package Funogram
To get your first bot running just use startBot function from Funogram.Bot module. If you don't need any additional configuration, you can use defaultConfig constant that stores default settings. Note that you need to extend default config with your own bot token received from BotFather. Here you go:
open Funogram.Bot
startBot { defaultConfig with Token = "your token" } onUpdate None
Every update received from Telegram Bot API will be passed to onUpdate function. It should handle user input according to UpdateContext passed. Use processCommands function to process commands addressed to your Bot, cmd and cmdScan can help you.
let onUpdate (context: UpdateContext) =
processCommands context [
cmd "/start" onStart
cmd "/help" onHelp
]
Use Funogram.Api module to communicate with Telegram API with the help of request builders implemented using curried functions, for example sendMessage, sendPhoto and so on.
"Hello, world!"
|> sendMessage chatId
|> api accessToken
|> Async.RunSynchronously
|> ignore (* or process API response somehow *)
So, that is it! Use Intellisence-driven development approach to explore all Funogram features! For further learning you may take a look at sample Telegram bots built using this library: Test Bot, Memes Bot
Old methods moved in Funogram.Rest
module.
New more functional api available in Funogram.Api
module.
Not recommended to use functions who ends with Base
, because it's may be changed in future. If you want to use this functions, you need to minimize usage of it (write wrapper, for example).
- getUpdates
- getMe
- forwardMessage
- âť•sendMessage (not tested ForceReply)
- getUserProfilePhotos
- âť•getFile (not tested)
- âť•kickChatMember (not tested)
- âť•unbanChatMember (not tested)
- âť•leaveChat (not tested)
- getChat
- âť•getChatAdministrators (not tested)
- âť•getChatMembersCount (not tested)
- âť•getChatMember (not tested)
- âť•answerCallbackQuery (not tested)
- âť•editMessageText (not tested)
- âť•editMessageCaption (not tested)
- âť•editMessageReplyMarkup (not tested)
- âť•deleteMessage (not tested)
- âť•answerInlineQuery (not tested)
- âť•sendInvoice (not tested)
- âť•answerShippingQuery (not tested)
- âť•answerPreCheckoutQuery (not tested)
- sendPhoto
- âť•sendAudio (not tested)
- âť•sendDocument (not tested)
- âť•sendSticker (not tested)
- âť•sendVideo (not tested)
- âť•sendVoice (not tested)
- âť•sendVideoNote (not tested)
- âť•sendLocation (not tested)
- âť•sendVenue (not tested)
- âť•sendContact (not tested)
- âť•sendChatAction (not tested)
- âť•sendGame (not tested)
- âť•setGameScore (not tested)
- âť•getGameHighScores (not tested)
- âť•restrictChatMember (not tested)
- âť•promoteChatMember (not tested)
- âť•kickChatMember (not tested)
- âť•exportChatInviteLink (not tested)
- âť•setChatPhoto (not tested)
- âť•deleteChatPhoto (not tested)
- âť•setChatTitle (not tested)
- âť•setChatDescription (not tested)
- âť•pinChatMessage (not tested)
- âť•unpinChatMessage (not tested)