All Projects → Dolfik1 → Funogram

Dolfik1 / Funogram

Licence: mit
F# Telegram Bot Api library

Programming Languages

fsharp
127 projects

Projects that are alternatives of or similar to Funogram

checkmk-telegram-notify
Get alerted by Check_MK via Telegram bash script
Stars: ✭ 28 (-50.88%)
Mutual labels:  telegram-bot-api
Informer
A Telegram Mass Surveillance Bot in Python
Stars: ✭ 745 (+1207.02%)
Mutual labels:  telegram-bot-api
Spytrojan keylogger
[Solo para programadores] Troyano espía | Keylogger solo para Windows, se replica en el sistema y se inicia automaticamente al iniciar sesión. | Envío de registro mediante [Base de Datos], [Gmail] o [BotTelegram].
Stars: ✭ 32 (-43.86%)
Mutual labels:  telegram-bot-api
Telegram.bot.examples
Examples for the Telegram.Bot C# Library
Stars: ✭ 290 (+408.77%)
Mutual labels:  telegram-bot-api
Pytelegrambotapi
Python Telegram bot api.
Stars: ✭ 4,986 (+8647.37%)
Mutual labels:  telegram-bot-api
Telegraphist
🤖 Telegram Bot API on Go
Stars: ✭ 16 (-71.93%)
Mutual labels:  telegram-bot-api
MT4-Telegram-Bot-Recon
Building a Telegram Chat with a MT4 Forex Trading Expert Advisor
Stars: ✭ 71 (+24.56%)
Mutual labels:  telegram-bot-api
University News Notifier
📚 University news notifier
Stars: ✭ 56 (-1.75%)
Mutual labels:  telegram-bot-api
Teloxide
📮 An elegant Telegram bots framework for Rust
Stars: ✭ 604 (+959.65%)
Mutual labels:  telegram-bot-api
Logger Telegram Backend
A logger backend for Telegram
Stars: ✭ 13 (-77.19%)
Mutual labels:  telegram-bot-api
Laravel Social Auto Posting
🌈Laravel social auto posting
Stars: ✭ 306 (+436.84%)
Mutual labels:  telegram-bot-api
Kotlin Telegram Bot
🤖 A wrapper for the Telegram Bot API written in Kotlin
Stars: ✭ 337 (+491.23%)
Mutual labels:  telegram-bot-api
Mypackbot
🤖 Your own unlimited pack of Telegram-stickers
Stars: ✭ 18 (-68.42%)
Mutual labels:  telegram-bot-api
Telegram Bot Swift
Telegram Bot SDK for Swift (unofficial)
Stars: ✭ 275 (+382.46%)
Mutual labels:  telegram-bot-api
Instalator Telegram
Telegram Bot для автоматизации массфаловинга и управления Instagram аккаунтами
Stars: ✭ 46 (-19.3%)
Mutual labels:  telegram-bot-api
telegram menu
A python library to generate navigation menus using Telegram Bot API
Stars: ✭ 19 (-66.67%)
Mutual labels:  telegram-bot-api
Java Telegram Bot Api
Telegram Bot API for Java
Stars: ✭ 819 (+1336.84%)
Mutual labels:  telegram-bot-api
Telebot
The easy way to write Telegram bots in Node.js
Stars: ✭ 1,096 (+1822.81%)
Mutual labels:  telegram-bot-api
Bot Telegram
Exemplo de como criar um BOT para o melhor app de mensagens do mundo: Telegram.
Stars: ✭ 53 (-7.02%)
Mutual labels:  telegram-bot-api
Lulzbot Telegram Bot
Moved to https://gitlab.com/bhavyanshu/lulzbot-telegram-bot
Stars: ✭ 18 (-68.42%)
Mutual labels:  telegram-bot-api

.NET Core NuGet

Funogram

F# Telegram Bot Api library!

Breaking changes

Funogram 2.0 has breaking changes. You should add two nuget packages: Funogram and Funogram.Telegram.

Getting Started

Firstly you need to install Funogram. Installation for .NET Core users:

dotnet add package Funogram

Installation for .NET Framework users:

Install-Package Funogram

Writing a Bot

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

Getting updates via webhooks

If you want to use webhooks, you should start application with admin privileges.

To get updates via webhooks you need send your endpoint address to Telegram server:

let! hook = setWebhookBase webSocketEndpoint None None None |> api config

You can use (ngrok)[https://ngrok.com/] service to test webhooks on your local machine that no have public address.

Then you should set WebHook field in BotConfig. WebHook field have BotWebHook type that contains two fields: Listener and ValidateRequest:

let apiPath = sprintf "/%s" config.Token
let webSocketEndpoint = sprintf "https://1c0860ec2320.ngrok.io/%s" webSocketEndpoint apiPath
let! hook = setWebhookBase webSocketEndpoint None None None |> api config
match hook with
| Ok ->
  use listener = new HttpListener()
  listener.Prefixes.Add("http://*:4444/")
  listener.Start()

  let webhook = { Listener = listener; ValidateRequest = (fun req -> req.Url.LocalPath = apiPath) }
  return! startBot { config with WebHook = Some webhook } updateArrived None

| Error e -> 
  printf "Can't set webhook: %A" e
  return ()

Telegram (recommend)[https://core.telegram.org/bots/api#setwebhook] using a secret path in URL with your bot's token. You can validate telegram request in ValidateRequest function.

Articles

Funogram: Writing Telegram Bots In F#

Funogram.Keyboard: How to reserve seats on an airplane using F # and telegram

Plugins and Extensions

Funogram.Keyboard

Work in Progress

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).

Completed 👍:

  • 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)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].