telegram-bot

This Telegram Bot is a C++ application designed to handle user commands, enforce rate limits, and interact seamlessly with the Telegram API.

https://github.com/genyleap/telegram-bot

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.0%) to scientific vocabulary
Last synced: 8 months ago · JSON representation ·

Repository

This Telegram Bot is a C++ application designed to handle user commands, enforce rate limits, and interact seamlessly with the Telegram API.

Basic Info
  • Host: GitHub
  • Owner: genyleap
  • License: mit
  • Language: C++
  • Default Branch: main
  • Size: 74.2 KB
Statistics
  • Stars: 3
  • Watchers: 1
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Created about 1 year ago · Last pushed about 1 year ago
Metadata Files
Readme License Code of conduct Citation Security

README.md

Telegram Bot in C++

This repository contains a Telegram Bot implemented in C++. The bot is designed to handle user commands, enforce rate limits, and interact with the Telegram API to send and receive messages. It is a robust and scalable solution for building custom Telegram bots with advanced features.


Features

  • Command Handling: Register and execute custom commands dynamically.
  • Rate Limiting: Prevent abuse by limiting user requests within a specified time interval.
  • Telegram API Integration: Send and receive messages with optional Markdown formatting.
  • Thread Safety: Ensures safe access to shared resources using mutexes.
  • JSON Parsing: Processes Telegram API responses using JsonCpp.
  • Logging: Provides detailed logs for debugging and monitoring bot activity.

Getting Started

Prerequisites

  • libcurl: For HTTP requests and URL encoding.
  • JsonCpp: For parsing JSON responses.
  • C++ Compiler: Supports C++11 or later.

Installation

Linux

  1. Clone the repository: bash git clone https://github.com/genyleap/telegram-bot cd telegram-bot

  2. Install dependencies: bash sudo apt-get install libcurl4-openssl-dev libjsoncpp-dev

  3. Build the project: bash mkdir build cd build cmake .. make

  4. Run the bot: bash ./TelegramBot YOUR_TELEGRAM_BOT_TOKEN


Windows

  1. Clone the repository: bash git clone https://github.com/genyleap/telegram-bot cd telegram-bot

  2. Install dependencies:

    • Download and install vcpkg for managing dependencies.
    • Install libcurl and jsoncpp using vcpkg: bash vcpkg install curl jsoncpp
  3. Build the project:

    • Open the project in Visual Studio or use CMake: bash mkdir build cd build cmake -DCMAKE_TOOLCHAIN_FILE=[path-to-vcpkg]/scripts/buildsystems/vcpkg.cmake .. cmake --build .
  4. Run the bot: bash .\TelegramBot YOUR_TELEGRAM_BOT_TOKEN


macOS

  1. Clone the repository: bash git clone https://github.com/genyleap/telegram-bot cd telegram-bot

  2. Install dependencies: bash brew install curl jsoncpp

  3. Build the project: bash mkdir build cd build cmake .. make

  4. Run the bot: bash ./TelegramBot YOUR_TELEGRAM_BOT_TOKEN


Usage

Registering Commands

You can register custom commands with the bot: ```cpp TelegramBot bot("YOURTELEGRAMBOT_TOKEN");

bot.registerCommand(Command("start", { bot.sendMessage(chatId, "Welcome to the bot!"); }));

bot.registerCommand(Command("help", { bot.sendMessage(chatId, "Available commands: /start, /help"); }));

bot.start(); ```

Sending Messages

The bot can send messages with optional Markdown formatting: cpp bot.sendMessage(chatId, "Hello, world!", true); // Markdown enabled


Configuration

  • Rate Limiting: Adjust the rate limit settings in the RateLimiter constructor: cpp RateLimiter rateLimiter(5, std::chrono::seconds(10)); // 5 requests per 10 seconds

  • Logging: Customize logging levels and output as needed.


Example Commands

  • /start: Welcomes the user.
  • /help: Lists available commands.
  • Add custom commands to suit your bot's functionality.

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any improvements, bug fixes, or new features.


License

This project is licensed under the MIT License. See the LICENSE file for details.


Acknowledgments

  • libcurl: For handling HTTP requests.
  • JsonCpp: For parsing JSON responses.
  • Telegram API: For providing the bot infrastructure.

Enjoy building your Telegram bot with this C++ implementation! 🚀

Owner

  • Name: The Genyleap ™
  • Login: genyleap
  • Kind: organization
  • Email: info@genyleap.com
  • Location: Worldwide

Revolution of the software leap.

Citation (CITATION.md)

cff-version: 1.2.0
message: "If you use this software, please cite it as below."
authors:
- family-names: "Asadzadeh"
  given-names: "Kambiz"
  orcid: "https://orcid.org/0009-0009-2065-3977"
title: "PT"
version: 1.1.222
date-released: 2023-04-25
url: "https://kambizasadzadeh.com"
repository-code: "https://github.com/genyleap/Project-Template"

GitHub Events

Total
  • Watch event: 4
  • Push event: 2
  • Create event: 2
Last Year
  • Watch event: 4
  • Push event: 2
  • Create event: 2

Committers

Last synced: 10 months ago

All Time
  • Total Commits: 3
  • Total Committers: 1
  • Avg Commits per committer: 3.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 3
  • Committers: 1
  • Avg Commits per committer: 3.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
C O M P Ξ Z k****o@g****m 3

Issues and Pull Requests

Last synced: 10 months ago

All Time
  • Total issues: 0
  • Total pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Total issue authors: 0
  • Total pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels