TelegramAsDatabase 2.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package TelegramAsDatabase --version 2.0.0
                    
NuGet\Install-Package TelegramAsDatabase -Version 2.0.0
                    
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="TelegramAsDatabase" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TelegramAsDatabase" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="TelegramAsDatabase" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add TelegramAsDatabase --version 2.0.0
                    
#r "nuget: TelegramAsDatabase, 2.0.0"
                    
#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.
#:package TelegramAsDatabase@2.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=TelegramAsDatabase&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=TelegramAsDatabase&version=2.0.0
                    
Install as a Cake Tool

TelegramAsDatabase

The official repository for telegram as database

Now telegram as database (TDB) is availabe on nuget.org: click here

Getting start

  1. Create a bot using bot father in telegram (Important: Dont Change the bot description at all)

    botfather

  2. Create a channel as a database source in telegram

    channel

  3. Now add your bot that created in the first step to the channel as an administrator and give all premissions to it.

    channel

  4. Goto your appsettings and add TDB config to it.:

    • The api key is key that you get from BotFather in the first step
    • The Channel Id is the id of the channel you can get it by forwarding a message of the channel to @userinfobot bot.
    "TDBConfig": {
        // The api key that you get from BotFather in the first step
        "ApiKey": "7753344678:AAFf4MIQSShxa4djp172DjhDe2_jqRsyOeU",
        // The Channel Id
        "ChannelId": "-1002378130994"
    }
    
  5. Now Add Tdb to your service container:

    var configurations = builder.Configuration;
    builder.Services.AddTDB(configurations);
    
  6. Done! now you can use the telegram free database

How to use

The example code of using the TDB:

internal class TestService
{
    private readonly ITDB _tdb;
    public TestService(ITDB tdb)
    {
        _tdb = tdb;
    }

    public async Task StartService(CancellationToken cancellationToken)
    {
        // This line clears all data from db
        //await _tdb.ClearAsync(cancellationToken);

        var id = Guid.NewGuid();

        var model = new MyTestModel()
        {
            Name = "FirstTest",
            Description = "FirstDescription",
            Type = "FuncTest"
        };

        var result = await _tdb.SaveAsync(new TDBData<MyTestModel>()
        {
            Id = id,
            Data = model
        }, cancellationToken);

        var exists = await _tdb.ExistsAsync<MyTestModel>(id, cancellationToken);
        Console.WriteLine($"ModelExists: {exists.Value}");
       
         modelResult = await _tdb.GetAsync<MyTestModel>(id, cancellationToken);
         var data = modelResult.Value.Data;

         Console.WriteLine(data.Name); // output: FirstTest
    }
}
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows 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 132 1/4/2025
2.2.0 114 12/21/2024
2.1.0 111 12/19/2024
2.0.0 103 12/19/2024

Initial Release