All Projects → reo7sp → Tgbot Cpp

reo7sp / Tgbot Cpp

Licence: mit
C++ library for Telegram bot API

Programming Languages

cpp
1120 projects

Projects that are alternatives of or similar to Tgbot Cpp

Java Telegram Bot Api
Telegram Bot API for Java
Stars: ✭ 819 (+86.56%)
Mutual labels:  telegram-api, bot, telegram-bot, telegram
Node Telegram Api
A simple API to create and control Telegram bots
Stars: ✭ 117 (-73.35%)
Mutual labels:  telegram-api, bot, telegram-bot, telegram
Turibot
TuriBot is a simple way to communicate with Telegram APIs in PHP
Stars: ✭ 68 (-84.51%)
Mutual labels:  telegram-api, bot, telegram-bot, telegram
Mypackbot
🤖 Your own unlimited pack of Telegram-stickers
Stars: ✭ 18 (-95.9%)
Mutual labels:  telegram-api, bot, telegram-bot, telegram
Groupbutler
This bot can help you in managing your group with rules, anti-flood, description, custom triggers, and much more!
Stars: ✭ 399 (-9.11%)
Mutual labels:  telegram-api, bot, telegram-bot, telegram
Telegram Bot Api
First Telegram Bot API node.js library
Stars: ✭ 205 (-53.3%)
Mutual labels:  telegram-api, bot, telegram-bot, telegram
Novagram
An Object-Oriented PHP library for Telegram Bots
Stars: ✭ 112 (-74.49%)
Mutual labels:  telegram-api, bot, telegram-bot, telegram
Informer
A Telegram Mass Surveillance Bot in Python
Stars: ✭ 745 (+69.7%)
Mutual labels:  telegram-api, bot, telegram-bot, telegram
Micro Bot
🤖 Zero-configuration Telegram bot runner
Stars: ✭ 173 (-60.59%)
Mutual labels:  telegram-api, bot, telegram-bot, telegram
Mattata
A powerful, plugin-based, multi-purpose Telegram bot designed to serve a wide variety of purposes
Stars: ✭ 107 (-75.63%)
Mutual labels:  telegram-api, telegram-bot, telegram
Madelineproto
Async PHP client/server API for the telegram MTProto protocol
Stars: ✭ 1,776 (+304.56%)
Mutual labels:  telegram-api, bot, telegram
Shieldy
@shieldy_bot Telegram bot repository
Stars: ✭ 351 (-20.05%)
Mutual labels:  bot, telegram-bot, telegram
Magento Chatbot
Magento Chatbot Integration with Telegram, Messenger, Whatsapp, WeChat, Skype and wit.ai.
Stars: ✭ 149 (-66.06%)
Mutual labels:  telegram-api, bot, telegram
Sentry Telegram
Plugin for Sentry which allows sending notification via Telegram messenger.
Stars: ✭ 168 (-61.73%)
Mutual labels:  telegram-api, telegram-bot, telegram
Pytg
Python package that wraps around Telegram messenger CLI. Send and receive messages, and more.
Stars: ✭ 365 (-16.86%)
Mutual labels:  bot, telegram-bot, telegram
Telegram Bot
Ruby gem for building Telegram Bot with optional Rails integration
Stars: ✭ 433 (-1.37%)
Mutual labels:  bot, telegram-bot, telegram
Drone Telegram
Drone plugin for sending Telegram notifications
Stars: ✭ 67 (-84.74%)
Mutual labels:  telegram-api, telegram-bot, telegram
Core
PHP Telegram Bot based on the official Telegram Bot API
Stars: ✭ 2,899 (+560.36%)
Mutual labels:  telegram-api, telegram-bot, telegram
The Guard Bot
The Guard, a Telegram bot to moderate groups.
Stars: ✭ 299 (-31.89%)
Mutual labels:  bot, telegram-bot, telegram
Python Telegram
Python client for the Telegram's tdlib
Stars: ✭ 246 (-43.96%)
Mutual labels:  telegram-api, telegram-bot, telegram

tgbot-cpp

Travis build Status
GitHub contributors

C++14 library for Telegram bot API.

Documentation is located here.

State

  • [x] Bot API 3.0 ~ 3.6
  • [x] Bot API 4.0 ~ 4.4 (Implemented all APIs except 'Telegram Passport')

Sample

Simple echo bot which sends everything it receives:

#include <stdio.h>
#include <tgbot/tgbot.h>

int main() {
    TgBot::Bot bot("PLACE YOUR TOKEN HERE");
    bot.getEvents().onCommand("start", [&bot](TgBot::Message::Ptr message) {
        bot.getApi().sendMessage(message->chat->id, "Hi!");
    });
    bot.getEvents().onAnyMessage([&bot](TgBot::Message::Ptr message) {
        printf("User wrote %s\n", message->text.c_str());
        if (StringTools::startsWith(message->text, "/start")) {
            return;
        }
        bot.getApi().sendMessage(message->chat->id, "Your message is: " + message->text);
    });
    try {
        printf("Bot username: %s\n", bot.getApi().getMe()->username.c_str());
        TgBot::TgLongPoll longPoll(bot);
        while (true) {
            printf("Long poll started\n");
            longPoll.start();
        }
    } catch (TgBot::TgException& e) {
        printf("error: %s\n", e.what());
    }
    return 0;
}

All other samples are located here.

Dependencies

Firstly you need to install some dependencies such as Boost and build tools such as CMake. On Debian-based distibutives you can do it with these commands:

sudo apt-get install g++ make binutils cmake libssl-dev libboost-system-dev zlib1g-dev

If you want to use curl-based http client CurlHttpClient, you also need to install libcurl4-openssl-dev package.

Library installation

If you want to install the library system-wide:

git clone https://github.com/reo7sp/tgbot-cpp
cd tgbot-cpp
cmake .
make -j4
sudo make install

You can treat this repository as a submodule of your project, for example, see echobot-submodule

You can use Docker to build and run your bot. Set the base image of your's Dockerfile to reo7sp/tgbot-cpp.

Bot compilation

With CMake

Example CMakeLists.txt

Without CMake

g++ telegram_bot.cpp -o telegram_bot --std=c++14 -I/usr/local/include -lTgBot -lboost_system -lssl -lcrypto -lpthread

Build options

-DTGBOT_DISABLE_NAGLES_ALGORITHM   # Disable 'Nagle's algorithm'
-DTGBOT_CHANGE_SOCKET_BUFFER_SIZE  # Socket Buffer Size Expansion
-DTGBOT_CHANGE_READ_BUFFER_SIZE    # Read Buffer Size Expansion

Licence

The MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].