Giter Site home page Giter Site logo

blockspacer / telegram-reactive Goto Github PK

View Code? Open in Web Editor NEW

This project forked from manu343726/telegram-reactive

0.0 2.0 0.0 17 KB

Example C++ telegram bot using a reactive API

Home Page: https://github.com/joaquintides/usingstdcpp2019

Python 1.78% CMake 3.11% C++ 95.11%

telegram-reactive's Introduction

A reactive Telegram bot

This is an example of a C++ telegram bot using a reactive API. See this repository for details.

How it works?

The usingstdcpp2019::urp API implements an event stream API similar to Rx. This bot is an example of integrating that API into the tgbot_cpp API to compose powerful Telegram message handling mechanisms. To do so, the example bop.cpp implements a ReactiveBot class that subscribes to any user message sent to the Telegram bot with TgBot::EventBroadcaster::onAnyMessage() and sends them through the urp::trigger API to generate an event. From there the message is an event that can be streamed and combined using different operators.

How to build

The example uses conan to gather all dependencies, which are all linked statically to generate a deps-free standalone executable. To set up the project run the following commands from the source tree:

$ mkdir build && cd build
$ conan install .. --build=missing
$ cmake ..
$ make

You need the following conan repositories:

The repositories are configured in your machine as follows:

$ conan remote add Manu343726 https://api.bintray.com/conan/manu343726/conan-packages
$ conan remote add bincrafters https://api.bintray.com/conan/bincrafters/public-conan

If everything runs smoothly there should be a bot executable in build/bin/.

Running the bot

Telegram bots use an unique API token to identify themselves. This token should be given to the bot through an environment variable called USINGSTDCPP2019_BOT_TOKEN:

$ export USINGSTDCPP2019_BOT_TOKEN="your telegram bot API token"
$ ./bin/bot
Hi! I'm @usingstdcpp2019_bot, I'm ready to talk with you!

See the Telegram Bot docs to get a new API token.

telegram-reactive's People

Contributors

manu343726 avatar manusharded avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.