Telegram Chatbot

Project Overview:

The aim of the Telegram Chatbot project is to regulate Telegram chatrooms for the PP Network. The project consists of a bot which monitors the messages sent by the users in the Telegram chatrooms. There are two types of chatrooms, a Common and Marketplace chatroom.

In the case of the Common chatroom, the bot would monitor how many messages a user sent in a given timeframe. If the user sends too many messages, the bot restricts the user for a given amount of time.

In the case of the Market chatroom, if the user sent a message, they are given a limited time to send more messages. If the user doesn’t send more messages or exceeds the number of messages they are allowed in the limited time, they are restricted for a given amount of hours.

Designing the Project:

The project was started by designing how the bot will work, how data will be stored in the bot’s database and the overall lifecycle of the bot.

Here are some bits of the design process of the project:

An overview of a database table
An overview of how the Worker functions
Overview of how the system will work

Prototyping the Project:

After the design was completed, a prototype of the project was completed. The purpose of the prototype was to ensure that the project met the requirements of the client before the actual bot was developed.

The prototype was a simple Python script that simulated the functionality of the bot, by allowing configurations to be set, creating user accounts and blocking the user accounts from sending messages when the user account exceeded the allowed messages sent.

Below are some screenshots of the prototype in action.

Command options for the prototype
Creating a new example user
Example user sending messages

Building the Project:

The project consisted of various parts that worked together to complete the functionality of the project. Each part was designed and built with various design patterns in order to keep the components modular and easily replaceable for any upgrades to the system.

During the development process, each component was extensively tested for bugs and instabilities in a test environment. Once the code passed all tests, it was moved to the production code.

Here are some snippets of code of the bot:

A snippet of code that schedules tasks
A snippet of a data object
A snippet of code that receives new Telegram messages

Testing the Project:

Once the bot was built, it was extensively tested in various Telegram groups to ensure the bot functioned as expected. Bugs that were missed during the testing in the development phase were discovered and resolved during the testing phase.

The client was involved in the testing process, which introduced new ways users interacted in the Telegram groups, which helped improved the bot’s stability and capacity to handle various means of user interaction.

The testing process was repeated until the client was satisfied with the bot.

Here are some snippets of the testing phase of the project:

Testing the commands of the bot on Telegram
Testing a fun feature of the bot
Testing if the bot restricts users on Telegram

The Final Result:

Once the client was satisfied with the bot, the project was completed and shipped to the client. You can read the testimonial of the client here.