CameraBot.Telegram 2.2.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package CameraBot.Telegram --version 2.2.2                
NuGet\Install-Package CameraBot.Telegram -Version 2.2.2                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CameraBot.Telegram" Version="2.2.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CameraBot.Telegram --version 2.2.2                
#r "nuget: CameraBot.Telegram, 2.2.2"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install CameraBot.Telegram as a Cake Addin
#addin nuget:?package=CameraBot.Telegram&version=2.2.2

// Install CameraBot.Telegram as a Cake Tool
#tool nuget:?package=CameraBot.Telegram&version=2.2.2                

CI Nuget Docker Pulls GitHub

Camera bot

A Telegram bot for HTTP web cameras.

Description

  1. A user sends a /snapshot command to the bot.
  2. The bot responds with a list of cameras to select.
  3. The user selects a camera.
  4. The bot sends a snapshot from that camera in response.

Supported messengers

  • Telegram

Running

An example for docker run with environment variables:

docker run andeadlier/camera-bot \
  -e Bot__Telegram__ApiToken=123456789:ABCDEFGH \
  -e Bot__Cameras__root__children__0__Name=Garden \
  -e Bot__Cameras__root__children__0__SnapshotUrl=http://12.34.56.78/snapshot.jpg

Adding to an existing ASP.NET Core application

Install the NuGet package:

dotnet add package CameraBot.Telegram

Update Startup.cs as follows:

public void ConfigureServices(IServiceCollection services)
{
  // the bot core logic and Telegram implementation
  services
    .AddCameraBot(Configuration.GetSection("Bot"))
    .AddTelegram(Configuration.GetSection("Bot:Telegram"));

  // ...
}

public void Configure(IApplicationBuilder app, IWebHostEnvironment environment)
{
  // ...

  // required if you need the webhooks mode
  app.UseCameraBot();
}

Describe cameras and set up Telegram in appsettings.json:

{
  "Bot": {
    "Root": {
      "Name": "42nd Street",
      "SnapshotUrl": "https://static.skylinewebcams.com/_9784192001.jpg",
      "Url": "https://www.skylinewebcams.com/en/webcam/united-states/new-york/new-york/nyc-42th-street.html",
      "Website": "https://www.skylinewebcams.com"
    },
    "Telegram": {
      "ApiToken": "<YOUR_API_TOKEN>",
      "Webhook": {
        "Url": "<YOUR_WEBHOOK_URL>"
      }
    }
  }
}

Features

Webhooks

The mode is selected upon startup based on presence of the webhook URL in the app configuration. If Bot__Telegram__Webhook__Url is set, the server will set up the webhook in Telegram and wait for incoming HTTPS requests.

It is required that the Url is accessible from the Internet so that Telegram servers can send requests to it. It is recommended that you append a secret token to the URL (see here for details).

NOTE: The webhook registration is not removed in Telegram upon shutdown. This is crucial for other replicas of the same bot to be able to continue receiving messages when one replica is scaled down.

Long polling

If the webhook URL is not set, the server will assume the long-polling mode and begin polling updates from Telegram until shut down.

When using long-polling you don't have to expose any ports to the Internet. However, you cannot launch multiple bot replicas.

Proxy servers

SOCKS5 proxy is supported for the outgoing connections from the bot to Telegram via Bot__Telegram__Socks5__Hostname and Bot__Telegram__Socks5__Port environment variables.

Usernames white lists

Set Bot__Telegram__AllowedUsernames__0 to the first username, Bot__Telegram__AllowedUsernames__1 to the second, and so on. The bot will discard any updates that came from users having usernames other than in the AllowedUsernames list.

When no white list specified, the bot answers everyone.

Error handling

  • Bot__RetryCount sets the number of times to retry downloading a snapshot, the default is 3;
  • Bot__TimeoutMilliseconds sets the max number in milliseconds for the snapshot downloading to complete, the default is 1000 ms.

Feedback

For the /feedback command, the configuration options are:

  • Bot__Telegram__Feedback__ChatId - the id of the chat where to forward the feedback messages;
  • Bot__Telegram__Feedback__Header - an optional header to prepend to the messages.
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.0.0 597 11/20/2020
2.2.2 494 3/14/2020
2.2.1 458 3/14/2020