telegram-bot
This Telegram Bot is a C++ application designed to handle user commands, enforce rate limits, and interact seamlessly with the Telegram API.
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
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
Metadata Files
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
Clone the repository:
bash git clone https://github.com/genyleap/telegram-bot cd telegram-botInstall dependencies:
bash sudo apt-get install libcurl4-openssl-dev libjsoncpp-devBuild the project:
bash mkdir build cd build cmake .. makeRun the bot:
bash ./TelegramBot YOUR_TELEGRAM_BOT_TOKEN
Windows
Clone the repository:
bash git clone https://github.com/genyleap/telegram-bot cd telegram-botInstall dependencies:
- Download and install vcpkg for managing dependencies.
- Install
libcurlandjsoncppusing vcpkg:bash vcpkg install curl jsoncpp
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 .
- Open the project in Visual Studio or use CMake:
Run the bot:
bash .\TelegramBot YOUR_TELEGRAM_BOT_TOKEN
macOS
Clone the repository:
bash git clone https://github.com/genyleap/telegram-bot cd telegram-botInstall dependencies:
bash brew install curl jsoncppBuild the project:
bash mkdir build cd build cmake .. makeRun 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
RateLimiterconstructor:cpp RateLimiter rateLimiter(5, std::chrono::seconds(10)); // 5 requests per 10 secondsLogging: 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
- Website: https://genyleap.com
- Twitter: genyleap
- Repositories: 3
- Profile: https://github.com/genyleap
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
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