SKitLs.Bots.Telegram.Core
3.1.2
Prefix Reserved
dotnet add package SKitLs.Bots.Telegram.Core --version 3.1.2
NuGet\Install-Package SKitLs.Bots.Telegram.Core -Version 3.1.2
<PackageReference Include="SKitLs.Bots.Telegram.Core" Version="3.1.2" />
paket add SKitLs.Bots.Telegram.Core --version 3.1.2
#r "nuget: SKitLs.Bots.Telegram.Core, 3.1.2"
// Install SKitLs.Bots.Telegram.Core as a Cake Addin #addin nuget:?package=SKitLs.Bots.Telegram.Core&version=3.1.2 // Install SKitLs.Bots.Telegram.Core as a Cake Tool #tool nuget:?package=SKitLs.Bots.Telegram.Core&version=3.1.2
SKitLs.Bots.Telegram.Core
README version: 2024.03.23
The core module of the SKitLs.Bots.Telegram Framework.
First time here? Jump to Quick Start!
Description
SKitLs.Bots.Telegram.Core is a central package of the SKitLs.Bots.Telegram framework, providing essential mechanics for interfacing with the Telegram API. Serving as a wrapper for the Telegram.Bot project, it acts as a core foundation for Telegram bot development.
At the heart of this package lies the BotManager
class, designed to streamline the interaction process with server updates
and unpack them into strictly typed ICastedUpdate
classes.
By leveraging the capabilities of BotManager, developers can automate the handling of updates received from the Telegram servers,
facilitating the efficient processing of incoming data.
Furthermore, BotManager incorporates a straightforward Inversion of Control (IoC) container, ensuring seamless management and configuration of dependencies within the framework.
SKitLs.Bots.Telegram.Core empowers developers with a reliable and robust foundation to build Telegram bots with ease. Its comprehensive features and well-structured design facilitate the development process, allowing developers to focus on implementing bot logic without the hassle of handling low-level API interactions.
Setup
Ensure getting localization packs (*.core.*).
Installation
Using Terminal Command:
To install the project using the terminal command, follow these steps:
- Open the terminal or command prompt.
- Run command:
dotnet add package SKitLs.Bots.Telegram.Core
Using NuGet Packages Manager:
To install the project using the NuGet Packages Manager, perform the following steps:
- Open your preferred Integrated Development Environment (IDE) that supports NuGet package management (e.g., Visual Studio).
- Create a new project or open an existing one.
- Select "Project" > "Manage NuGet Packages"
- In the "Browse" tab, search for the project package you want to install.
- Click on the "Install" button to add the selected package to your project.
- Follow any additional setup instructions or configurations provided in the project's documentation.
Downloading Source Code and Direct Linking:
To install the project by downloading the source code and directly linking it to your project, adhere to the following steps:
- Visit the project repository on GitHub
- Click on the "Code" button and select "Download ZIP" to download the project's source code as a zip archive.
- Extract the downloaded zip archive to the desired location on your local machine.
- Open your existing project or create a new one in your IDE.
- Add the downloaded project files to your solution using the "Add Existing Project" option in your IDE's solution explorer.
- Reference the project in your solution and ensure any required dependencies are resolved.
- Follow any additional setup or configuration instructions provided in the project's documentation.
Please note that each method may have specific requirements or configurations that need to be followed for successful installation. Refer to the project's documentation for any additional steps or considerations.
Do not forget to download and install appropriate localization pack from GitHub.
Usage
Localizations
Framework Core and each of its extensions supports localized debugging. Some of them requires specific language packages. You can find them in GitHub's locals folder.
Place locals in "resources/locals" or update localization path.
BotBuilder.DebugSettings.DebugLanguage = LangKey.EN;
BotBuilder.DebugSettings.UpdateLocalsPath("path/to/data");
Quick Start
static async Task Main(string[] args)
{
var privateMessages = new DefaultSignedMessageUpdateHandler();
var privateTexts = new DefaultSignedMessageTextUpdateHandler
{
CommandsManager = new DefaultActionManager<SignedMessageTextUpdate>()
};
privateTexts.CommandsManager.AddSafely(StartCommand);
privateMessages.TextMessageUpdateHandler = privateTexts;
ChatDesigner privates = ChatDesigner.NewDesigner()
.UseMessageHandler(privateMessages);
await BotBuilder.NewBuilder("YOUR_TOKEN")
.EnablePrivates(privates)
.Build()
.Listen();
}
private static DefaultCommand StartCommand => new("start", Do_StartAsync);
private static async Task Do_StartAsync(SignedMessageTextUpdate update)
{
await update.Owner.DeliveryService.AnswerSenderAsync("Hello, world!", update);
}
Add more Actions
private static DefaultCommand StartCommand => new("start", Do_StartAsync);
private static async Task Do_StartAsync(SignedMessageTextUpdate update)
{
await update.Owner.DeliveryService.AnswerSenderAsync("Hello, world!", update);
// OR if certain chat is needed
await update.Owner.DeliveryService.SendMessageToChatAsync(update.ChatId, "Hello, world!", update);
}
private static DefaultCommand ExitInput => new("Exit bot!", Do_ExitAsync);
private static DefaultCommand ExitCommand => new("exit", Do_ExitAsync);
private static async Task Do_ExitAsync(SignedMessageTextUpdate update)
{
// Access sent message
DeliveryResponse response = await update.Owner.DeliveryService.AnswerSenderAsync("Exiting...", update);
TelegramTextMessage message = new("Precess is completed.");
message.AllowSendingWithoutReply = true;
if (response.Success)
{
// Reply to message
message.ReplyToMessageId = response.SentMessage.MessageId;
}
await update.Owner.DeliveryService.AnswerSenderAsync(message, update);
}
private static DefaultCallback HelloCallback => new("helloCB", Do_HelloAsync);
private static async Task Do_HelloAsync(SignedCallbackUpdate update)
{
// Acces Telegram.Bot bot instance if necessary
await update.Owner.Bot.EditMessageTextAsync(update.TriggerMessageId, "Updated Body!")
}
You can use SKitLs.Bots.Telegram.AdvancedMessages package to get better messaging experience.
Use services
Add service to bot
// ... await BotBuilder.NewBuilder("YOUR_TOKEN") .EnablePrivates(privates) .AddServices<ISomeService>(new DefaultSomeService()) .Build() .Listen();
Resolve one when needed
private static DefaultCommand StartCommand => new("start", Do_StartAsync); private static async Task Do_StartAsync(SignedMessageTextUpdate update) { var someService = update.Owner.ResolveService<ISomeService>(); await update.Owner.DeliveryService.AnswerSenderAsync(someService.GetContentFor(update.Text), update); }
Visit GitHub page for more information.
Contributors
Currently, there are no contributors actively involved in this project. However, our team is eager to welcome contributions from anyone interested in advancing the project's development.
We value every contribution and look forward to collaborating with individuals who share our vision and passion for this endeavor. Your participation will be greatly appreciated in moving the project forward.
Thank you for considering contributing to our project.
License
This project is distributed under the terms of the MIT License.
Copyright (c) 2023-2024, SKitLs
Developer contact
For any issues related to the project, please feel free to reach out to us through the project's GitHub page. We welcome bug reports, feedback, and any other inquiries that can help us improve the project.
You can also contact the project owner directly via their GitHub profile at the following link or email: skitlsdev@gmail.com
Your collaboration and support are highly appreciated, and we will do our best to address any concerns or questions promptly and professionally. Thank you for your interest in our project.
Notes
Thank you for choosing our solution for your needs, and we look forward to contributing to your project's success.
Product | Versions 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. |
-
net8.0
- SKitLs.Utils.Localizations (>= 2.2.2)
- SKitLs.Utils.LocalLoggers (>= 1.3.1)
- SKitLs.Utils.Loggers (>= 1.4.1)
- Telegram.Bot (>= 19.0.0)
NuGet packages (6)
Showing the top 5 NuGet packages that depend on SKitLs.Bots.Telegram.Core:
Package | Downloads |
---|---|
SKitLs.Bots.Telegram.AdvancedMessages
Offers enhanced methods for sending messages in Telegram bots. An extension project built upon the SKitLs.Bots.Telegram.Core Framework. |
|
SKitLs.Bots.Telegram.ArgedInteractions
Provides mechanism for the serialization and deserialization of textual data. An extension project built upon the SKitLs.Bots.Telegram.Core Framework. |
|
SKitLs.Bots.Telegram.PageNavs
Allows to create special navigational menus. An extension project built upon the SKitLs.Bots.Telegram.Core Framework. |
|
SKitLs.Bots.Telegram.Stateful
Enables the segregation of user states. An extension project built upon the SKitLs.Bots.Telegram.Core Framework. |
|
SKitLs.Bots.Telegram.BotProcesses
Provides methods of creating bot processes with advanced textual input mechanics. An extension project built upon the SKitLs.Bots.Telegram.Core Framework. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated | |
---|---|---|---|
3.1.2 | 279 | 3/26/2024 | |
3.1.2-alpha0 | 106 | 3/25/2024 | |
3.1.2-alpha.1 | 66 | 3/25/2024 | |
3.1.1 | 241 | 3/24/2024 | |
3.1.1-alpha0 | 104 | 3/23/2024 | |
3.1.0 | 175 | 3/23/2024 | |
3.0.1 | 157 | 3/23/2024 | |
3.0.0 | 165 | 3/22/2024 | |
2.4.0 | 239 | 3/21/2024 | |
2.3.2 | 237 | 10/10/2023 | |
2.3.1 | 388 | 8/22/2023 | |
2.3.0 | 327 | 8/19/2023 | |
2.2.0 | 248 | 8/13/2023 | |
2.1.3 | 368 | 8/12/2023 | |
2.1.2 | 300 | 8/11/2023 | |
2.1.0 | 222 | 8/8/2023 | |
2.0.1 | 199 | 8/5/2023 | |
2.0.1-alpha | 157 | 8/5/2023 | |
2.0.0 | 315 | 8/1/2023 | |
1.5.1 | 183 | 7/30/2023 | |
1.4.3 | 372 | 7/23/2023 | |
1.4.2 | 175 | 7/22/2023 |
(~) Updated: DefaultBotAction ctor supports null Action
(~) Updated: Bot Localization does not returns fallback string (since Localization v2.2.2)