TGSimpleLib 1.2.0

dotnet add package TGSimpleLib --version 1.2.0
                    
NuGet\Install-Package TGSimpleLib -Version 1.2.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="TGSimpleLib" Version="1.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TGSimpleLib" Version="1.2.0" />
                    
Directory.Packages.props
<PackageReference Include="TGSimpleLib" />
                    
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 TGSimpleLib --version 1.2.0
                    
#r "nuget: TGSimpleLib, 1.2.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 TGSimpleLib@1.2.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=TGSimpleLib&version=1.2.0
                    
Install as a Cake Addin
#tool nuget:?package=TGSimpleLib&version=1.2.0
                    
Install as a Cake Tool

TGSimpleLib 🤖

NuGet Downloads GitHub

English | Русский


English

TGSimpleLib by MPST-Studio is a high-level C# wrapper for Telegram bots. It's designed for developers who need professional monitoring tools (notifications, files, commands, progress bars, and logs) with zero boilerplate.

What's new in v1.2.0:

  • Command Handling: Register commands like /start or /status in one line.
  • Progress Bars: Visual feedback for long-running tasks without spamming the chat.
  • Logging System: Built-in OnLog event to track every action and response.
  • Branding: Officially moved to MPST-Studio organization with a new icon.

Full Usage Example:

using TGSimpleLib;

// 1. Initialization (Token, Timeout, Admin IDs)
var bot = new SimpleTG("YOUR_TOKEN", 30, 12345678, 87654321);

// 2. Logging (Capture every action into a file or console)
bot.OnLog += (sender, logMessage) => File.AppendAllText("bot.log", logMessage + Environment.NewLine);

// 3. Command Handling (Bot is listening to admins)
bot.OnCommand("/status", async () => {
    await bot.NotifyAsync("✅ All systems are running normally.");
});

// 4. Simple Notification
await bot.NotifyAsync("🚀 Bot is now online!");

// 5. Send Files (Logs or Documents)
await bot.SendFileAsync("app_log.txt", "Current server log");

// 6. Progress Bar (Updates one message)
var pb = await bot.CreateProgressBarAsync("Long Task");
for (int i = 0; i <= 100; i += 25) {
    await Task.Delay(1000);
    await pb.UpdateAsync(i); // Updates to [■■■□□] 50%
}
await pb.CompleteAsync("Task finished!");

// 7. Interactive Questions (Yes/No)
bool deploy = await bot.AskBoolAsync("Run deployment?");

// 8. Custom Choice Buttons
string mode = await bot.AskChoiceAsync("Select mode:", new[] { "Eco", "Normal", "Turbo" });

// 9. Wait for Text Input
string comment = await bot.AskStringAsync("Please enter your feedback:");

// 10. Error Reporting (Formats exception with stack trace)
try {
    int x = 0; int y = 5 / x;
} catch (Exception ex) {
    await bot.ReportErrorAsync("Main Calculation Loop", ex);
}

Русский

TGSimpleLib от MPST-Studio — это высокоуровневая библиотека-обертка для Telegram ботов на C#. Создана для разработчиков, которым нужны профессиональные инструменты мониторинга (уведомления, файлы, команды, прогресс-бары и логи) без лишнего кода.

Что нового в v1.2.0:

  • Обработка команд: Регистрация команд вроде /start или /stop одной строкой.
  • Прогресс-бары: Визуальное отображение хода выполнения задач без спама в чате.
  • Система логирования: Событие OnLog для фиксации каждого действия бота и ответов админов.
  • Брендинг: Библиотека официально перенесена в организацию MPST-Studio и получила иконку.

Полный пример всех функций:

using TGSimpleLib;

// 1. Инициализация (Токен, Таймаут, ID админов через запятую)
var bot = new SimpleTG("ВАШ_ТОКЕН", 30, 12345678, 87654321);

// 2. Логирование (сохранение всех действий бота и ответов в файл)
bot.OnLog += (s, log) => File.AppendAllText("actions.log", log + Environment.NewLine);

// 3. Обработка команд (Бот реагирует на сообщения админов)
bot.OnCommand("/restart", async () => {
    await bot.NotifyAsync("🔄 Перезагрузка системы инициирована...");
});

// 4. Простая отправка сообщения
await bot.NotifyAsync("🚀 Бот запущен и готов к работе!");

// 5. Отправка файлов (логи или документы)
await bot.SendFileAsync("server.log", "Лог-файл сервера");

// 6. Прогресс-бар (динамическое обновление одного сообщения)
var pb = await bot.CreateProgressBarAsync("Резервное копирование");
for (int i = 0; i <= 100; i += 25) {
    await Task.Delay(1000);
    await pb.UpdateAsync(i); // Сообщение изменится на [■■■■□□□□□□] 40%
}
await pb.CompleteAsync("Копирование завершено!");

// 7. Вопрос Да/Нет (возвращает bool)
bool result = await bot.AskBoolAsync("Выполнить обновление?");

// 8. Выбор из ваших вариантов (возвращает строку)
string selection = await bot.AskChoiceAsync("Выберите режим:", new[] { "Тихий", "Обычный", "Турбо" });

// 9. Ожидание текстового ответа (возвращает string)
string feedback = await bot.AskStringAsync("Введите комментарий к отчету:");

// 10. Отчет об ошибке (красивый формат со стек-трейсом)
try {
    throw new Exception("Пример ошибки базы данных");
} catch (Exception ex) {
    await bot.ReportErrorAsync("Модуль базы данных", ex);
}
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.  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. 
.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
1.2.0 98 3/6/2026
1.1.0 87 3/5/2026
1.0.0 92 3/3/2026