GithubHelp home page GithubHelp logo

hexicord's Introduction

Hexicord

Latest Release Discord server Issues License

Discord API implementation using C++11 with boost libraries.

Table of contents

Features

  • Gateway session with auto-reconnection on failure.
  • Wrapper that hides weird API details.
  • Using HTTP persistent connection to reduce overhead in series of REST requests.
  • Minimal runtime dependencies.

Installation

Requirements

  • CMake 3.0+
  • GCC 4.8.1+ or Clang 3.3+ or other C++11 compatible compiler
  • boost.asio 1.56+
  • OpenSSL 1.0.1+
  • boost.beast (submodule or system)
  • (Optional) Doxygen, if you also want to build documentation
  • (Optional) Zlib, if you want to use gateway message compression

Note: Versions is approximate and can be actually lower or higher, please report any problems with versions in specified range.

Following command should be enough for everything on debian-based distros:

# apt-get install cmake gcc doxygen libz-dev libboost-dev libboost-system-dev libssl-dev

Installation

$ git clone https://github.com/foxcpp/Hexicord.git  # clone repository
$ cd Hexicord
$ git submodule update --init                       # download boost.beast
$ mkdir build; cd build
$ cmake .. -DCMAKE_BUILD_TYPE=Release               # configure build system, Release enabled optimizations.

You can also enable HEXICORD_SHARED if you need shared library, HEXICORD_STATIC is enabled by default.

$ make

Usage

Library contain two big classes Hexicord::GatewayClient and Hexicord::Restclient. First maintains persistent gateway connection for real-time events, next one provides interface to REST API methods.

There is simple echo bot:

#include <boost/asio/io_service.hpp>
#include <hexicord/gateway_client.hpp>
#include <hexicord/rest_client.hpp>

using namespace Hexicord;

int main() {
    boost::asio::io_service ioService;
    GatewayClient gclient(ioService, "PUT YOUR TOKEN HERE");
    RestClient    rclient(ioService, "PUT YOUR TOKEN HERE");

    gclient.eventsDispatcher.addHandler(Event::MessageCreate, [&client](const nlohmann::json& message) {
        rclient.sendTextMessage(Hexicord::Snowflake(message["channel_id"].get<std::string>()), message["content"]);
    });

    gclient.connect(rclient.getGatewayUrlBot().first); // replace with rclient.getGatewayUrl() if not using bot account.
    ios.run(); 
}

Examples

See examples/.

Documentation

Documentation is generated using Doxygen if HEXICORD_DOCS option is enabled (default if Doxygen found).

$ cmake . -DHEXICORD_DOCS=ON
$ make doc

Output will be in docs/.

Also documentation for latest release can be browsed online here.

Contributing

Here is some of the ways that you can contribute:

  • Submit a bug report. We love hearing about broken things, so that we can fix them.
  • Provide feedback. Even simple questions about how things work or why they were done a certain way carries value.
  • Test code. Checkout dev branch, compile it and start trying to break stuff! :-)
  • Write code. Check issues marked with help wanted tag.
Code style

In short: camelCase (snake_case for files), 4 spaces indent, { on same line. Nobody likes to read long style guides, right? If you unsure about something else - just look at code.

License

Distributed under the MIT License.

Copyright (c) Maks Mazurov (fox.cpp) 2017 

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

hexicord's People

Contributors

foxcpp avatar sertsch1 avatar pantherion 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.