Skip to content

Latest commit

 

History

81 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

stoat++

a simple c++17 library for stoat.chat.

requirements

  • c++17 compiler
  • cmake (3.16+)
  • git
  • openssl

installation

add it as a subdirectory in your cmake project:

git clone https://codeberg.org/siq/stoatplusplus.git stoatpp

then add to your CMakeLists.txt:

add_subdirectory(stoatpp)
target_link_libraries(your_target PRIVATE stoatpp)

setup with msys2 (windows)

open the ucrt64 or mingw64 shell (do not use the msys shell) and run:

# for ucrt64
pacman -S git mingw-w64-ucrt-x86_64-toolchain mingw-w64-ucrt-x86_64-cmake mingw-w64-ucrt-x86_64-openssl

# for mingw64
pacman -S git mingw-w64-x86_64-toolchain mingw-w64-x86_64-cmake mingw-w64-x86_64-openssl

build locally:

mkdir build && cd build
cmake -G "MinGW Makefiles" ..
cmake --build .

setup with linux (debian/ubuntu)

sudo apt update
sudo apt install build-essential cmake git libssl-dev

mkdir build && cd build
cmake ..
cmake --build .

setup with immutable systems (bazzite, steamos, etc.)

since the host system is read-only, use distrobox (pre-installed) to create a development container:

# create and enter a fedora container
distrobox create -n dev-box -i registry.fedoraproject.org/fedora:40
distrobox enter dev-box

# inside the container, install dependencies
sudo dnf install git cmake gcc-c++ openssl-devel

# build
mkdir build && cd build
cmake ..
cmake --build .

simple example

#include <stoatpp/stoatpp.h>
#include <iostream>

int main() {
    stoatpp::ClientConfig cfg;
    cfg.log_level = stoatpp::LogLevel::INFO;

    stoatpp::cluster bot("YOUR_BOT_TOKEN_HERE", cfg);

    bot.on_ready([](const stoatpp::events::Ready& event) {
        std::cout << "logged in as " << event.user.username << "\n";
    });

    bot.on_message([&bot](const stoatpp::events::Message& event) {
        if (event.author.bot) return;

        if (event.content == "!ping") {
            bot.send_message(event.channel_id, "pong!");
        }
    });

    bot.start();
    return 0;
}

see docs.md for the full api.

for updates

join the server.

About

stoat.chat api wrapper in c++

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages