Skip to content

Releases: BeyondKarto/ChatLeaderboardBot

Version 1.2

Choose a tag to compare

@BeyondKarto BeyondKarto released this 14 Aug 18:41
ffe9942

Telegram Bot for Points Calculation - Version 1.2

This Telegram bot is designed to count the number of characters in user messages in chats and assign points based on the length of these messages. The bot now supports additional functionality, including image point calculation, enhanced logging, and more refined data management. Only the bot owner has the rights to use special commands to manage the bot.

New Features and Updates in Version 1.2

  1. Image Points Calculation:

    • The bot now awards a fixed 10 points for each image sent in the chat, providing additional ways for users to earn points.
  2. Enhanced Data Logging:

    • Every user message, including text and images, is now logged in an Excel file on a dedicated "Messages" sheet. The logged data includes:
      • Chat ID
      • User ID
      • Username
      • Message text (or "Photo" for images)
      • Timestamp of the message
      • Message length (in characters)
      • Points earned for each message
    • The bot also logs whenever the /resetbot command is used, recording the reset action in the "Messages" sheet.
  3. Detailed Console Logging:

    • The bot provides detailed logs in the console, displaying information for each message processed:
      • Chat ID
      • User ID
      • Username
      • Message text
      • Message length
      • Points earned
  4. Refined Commands:

    • Updated command names for clarity:
      • /start is now /startbot
      • /reset is now /resetbot
      • /top is now /topbot
      • /getfile is now /getfilebot
  5. Code Improvements:

    • Added null checks and ensured that all operations handle potential null values gracefully.
    • Optimized the data management structure for better performance and reliability.
  6. Excel File Management:

    • The Excel file is updated every minute, ensuring that all data is recorded consistently.
    • The "Leaderboard" sheet tracks overall user performance, while the "Messages" sheet logs detailed message-level data.

Functionality

Points Calculation:

  • The bot calculates points for each user message based on the following logic:
    • If the message contains up to 10 characters: The user earns 0.25 points per character.
    • If the message contains between 10 and 25 characters: The user earns 0.5 points per character.
    • If the message contains between 25 and 75 characters: The user earns 0.75 points per character.
    • If the message contains more than 75 characters: The user earns 1 point per character.
    • If the message contains an image: The user earns 10 points.

Leaderboard Management:

  • The bot tracks the points earned by users in each chat and generates a leaderboard based on these data. The bot owner can view the current top 10 users using a special command.

Commands:

  • /startbot: Starts the bot and notifies that the bot begins tracking points.
  • /resetbot: Resets all tracking data in the current chat. This command can only be used by the bot owner.
  • /topbot: Shows the current top 10 users with the highest points in the chat. This command can only be used by the bot owner.
  • /getfilebot: Sends an Excel file with all points tracking data in the current chat. This command can only be used by the bot owner.

Data Storage:

  • The bot saves user points data in an Excel file, which is updated every minute. This file contains the following information:
    • Chat ID
    • User ID
    • Username
    • Number of points earned
    • Detailed message logs, including time, content, and points.

Requirements

  • .NET 5.0 or newer
  • Telegram Bot API
  • Telegram.Bot library
  • EPPlus library for working with Excel

How to Run

  1. Clone this repository.
  2. Install the required packages via NuGet:
    • Telegram.Bot
    • OfficeOpenXml
  3. Change botOwnerId in the code to your Telegram ID.
  4. Run the project using Visual Studio or the command line.

Contribution

You can contribute by creating pull requests or reporting issues in the issues section. Your suggestions for improving the bot’s functionality are welcome.

Version1.1

Choose a tag to compare

@BeyondKarto BeyondKarto released this 12 Aug 17:22
ffe9942

Telegram Chat Leaderboard Bot

Description

This bot tracks user activity in a Telegram chat, counting the number of messages and characters, and awards points based on the length of the messages. Additionally, the bot can handle images, awarding a fixed number of points for each image sent. The results are stored in an Excel file, which can be downloaded using a command.

Version Updates

Added:

  • Image Support: The bot now awards 10 points for each image sent in the chat.
  • Leaderboard: Added the ability to view the top 10 participants based on their accumulated points.
  • Message Statistics: The bot stores user messages along with the timestamp of when they were sent.
  • Commands:
    • /start: Begins tracking messages.
    • /reset: Resets all data and creates a new Excel file.
    • /top: Displays the top 10 users based on points.
    • /getfile: Downloads the Excel file with the activity statistics.

Command Descriptions

  • /start - Activates the bot to start tracking messages.
  • /reset - Resets all data and creates a new Excel file to store the statistics.
  • /top - Displays the top 10 users based on their accumulated points.
  • /getfile - Sends the Excel file containing data on user activity in the chat.

How to Use

  1. Start the bot by using the /start command.
  2. Send messages or images in the chat.
  3. Use the /top command to view the current top participants.
  4. Use the /getfile command to get the Excel file with the statistics.
  5. To reset data and create a new file, use the /reset command.