ATTRIBUTE-BASED ROUTING FOR HANDLING TELEGRAM BOT UPDATES

Authors

DOI:

https://doi.org/10.32689/maup.it.2025.3.17

Keywords:

attribute-based routing, Telegram Bot, declarative attributes, .NET, dependency injection, modular architecture, scalability

Abstract

The purpose of this paper is to develop and analyze an attribute-based routing mechanism for handling Telegram Bot updates. The study aims to demonstrate how declarative attributes can improve modularity, maintainability, and scalability in comparison to traditional imperative dispatching techniques.The research employs attribute-oriented programming (AOP) in .NET combined with dependency injection (DI) andreflection. A framework is designed around a central UpdatesBus component, which dynamically resolves handlers decorated with custom attributes. Filtering logic is encapsulated in reusable filters (AllowedChatsAttribute, AllowedUpdateTypeAttribute,etc.), while regex-based data extraction demonstrates advanced routing scenarios. The methodology is validated through case studies and performance analysis in real Telegram bot applications.The novelty of this work lies in adapting attribute-based routing, widely applied in web frameworks such as ASP.NET Core, to the domain of Telegram bots. Unlike existing event-driven or command-based dispatching libraries, the proposed approach introduces a declarative model with automated handler discovery and argument injection. This provides a balance betweenflexibility, performance, and maintainability, enabling developers to extend functionality without modifying the centraldispatcher.Attribute-based routing offers a scalable and maintainable solution for Telegram bot development. Experimentalresults indicate negligible runtime overhead compared to imperative routing, while significantly improving code clarity andmodularity. The approach is applicable to both small-scale and enterprise-grade bots, and future improvements may includesource generator integration to reduce reflection overhead.

References

Bergmans L., Lopes C. V. Aspect-oriented programming. In S. Demeyer & J. Bosch (Eds.), Object-oriented technology: ECOOP’99 workshop reader. Lecture Notes in Computer Science, 1999. vol. 1743, pp. 288–313. Springer. https://doi.org/10.1007/3-540-46589-8_17

Butland A. Dependency Injection in ASP.NET Core Attributes. 2020, June 9. URL: https://www.andybutland.dev/2020/06/dependency-injection-in-aspnet-core-attributes.html (September 16, 2025).

Fowler, M. Inversion of control containers and the dependency injection pattern. 2004. URL: https://martinfowler.com/articles/injection.html (September 16, 2025)

Mens K., Lopes C., Tekinerdogan B., Kiczales G. Aspect-oriented programming. In M. Aksit (Ed.), ECOOP’97 workshops: Proceedings of the 11th European conference on object-oriented programming. Lecture Notes in Computer Science, 1998. vol. 1357, pp. 483–496. Springer. https://doi.org/10.1007/3-540-69687-3_88

Microsoft. Attribute routing in ASP.NET Web API 2. Microsoft Learn. 2014. URL: https://learn.microsoft.com/en-us/aspnet/web-api/overview/web-api-routing-and-actions/attribute-routing-in-web-api-2 (September 16, 2025).

Microsoft. Introducing C# Source Generators. The .NET Blog. 2020, April 29. URL: https://devblogs.microsoft.com/dotnet/introducing-c-source-generators/

Microsoft. Routing to controller actions in ASP.NET Core. Microsoft Learn. 2023. URL: https://learn.microsoft.com/en-us/aspnet/core/mvc/controllers/routing (September 16, 2025).

Microsoft. (2024, November 12). Reflection versus source generation in System. Text. Json. URL: https://learn.microsoft.com/en-us/dotnet/standard/serialization/system-text-json/reflection-vs-source-generation (September 16, 2025).

Microsoft. (n.d.). Attributes in C#. MSDN documentation. URL: https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/attributes (September 16, 2025).

Downloads

Published

2025-12-04

How to Cite

ПАШКОВСЬКИЙ, Б. (2025). ATTRIBUTE-BASED ROUTING FOR HANDLING TELEGRAM BOT UPDATES. Information Technology and Society, (3 (18), 123-127. https://doi.org/10.32689/maup.it.2025.3.17