poomer-discord/README.md
2026-01-04 04:22:34 +00:00

3.7 KiB

poomer-discord

Overview

Prototype C++ Discord bot, that supports 2 features

  • listens for /oomer command and replies, then 5 seconds later it sends a jpeg
  • When one or more jpegs are dropped into a channel, it will read the jpeg, flip it vertically and send it back to the channel
  • In both cases it will use @{user} in the reponse to notify the submitter

Technical details

  • Uses DPP c++ lib for Discord comms
    • depends on openssl and zlib
  • non blocking multi-threaded, so it can listen for other users sending /oomer command while spawning one or more threads to deal with jpeg replies
  • jpeg image is stored as byte data in embedded_image.h to avoid an on disk jpeg.

Build

workdir/
├── DPP/
├── libssl/
├── zlib/
├── libssl/

Ubuntu Linux x64 and arm64

sudo apt install build-essential git cmake -y
mkdir workdir && cd workdir
mkdir zlib libssl DPP poomer-discord sqlite3

# Build zlib
cd zlib && git clone https://github.com/madler/zlib.git .
./configure --static
make -j$(nproc)

# Build OpenSSL 
cd ../libssl && git clone https://github.com/openssl/openssl.git .
./Configure $([ "$(uname -m)" = "aarch64" ] && echo "linux-aarch64" || echo "linux-x86_64") 
make -j$(nproc)

# Build DPP
cd ../DPP && git clone https://github.com/brainboxdotcc/DPP.git .
#zlib wants an absolute path to help cmake find_package work, ssl requires explicit vars
cmake -B ./build -DCMAKE_PREFIX_PATH="$PWD/../zlib;$PWD/../libssl"
cmake --build ./build -j$(nproc)

# Build sqlite3
cd ../sqlite3
wget https://www.sqlite.org/2025/sqlite-autoconf-3510100.tar.gz
tar xzf sqlite-autoconf-3510100.tar.gz --strip-components=1
./configure --enable-static --disable-shared && make -j$(nproc)

cd ../poomer-discord && git clone https://git.indoodle.com/oomer/poomer-discord.git .
wget https://raw.githubusercontent.com/nothings/stb/master/stb_image.h
wget https://raw.githubusercontent.com/nothings/stb/master/stb_image_write.h
make all -j$(nproc)

MacOS x64 and arm64

mkdir workdir && cd workdir
mkdir zlib libssl DPP poomer-discord sqlite3

# Build zlib
cd zlib && git clone https://github.com/madler/zlib.git .
./configure --static
make -j$(sysctl -n hw.ncpu)

# Build OpenSSL (creates dynamic .dylib libraries needed for DPP)
cd ../libssl && git clone https://github.com/openssl/openssl.git .
./Configure $([ "$(uname -m)" = "arm64" ] && echo "darwin64-arm64-cc" || echo "darwin64-x86_64-cc")
make -j$(sysctl -n hw.ncpu)
# Fix OpenSSL library install names for portability
# Run this after OpenSSL is built to make the libraries use @rpath instead of hardcoded paths
install_name_tool -id @rpath/libssl.dylib libssl.dylib
install_name_tool -id @rpath/libcrypto.dylib libcrypto.dylib
install_name_tool -change /tmp/openssl-install/lib/libcrypto.4.dylib @rpath/libcrypto.dylib libssl.dylib

# Build sqlite3
cd ../sqlite3
curl -LO https://www.sqlite.org/2025/sqlite-autoconf-3510100.tar.gz
tar xzf sqlite-autoconf-3510100.tar.gz --strip-components=1
./configure --enable-static --disable-shared && make -j$(sysctl -n hw.ncpu)

# Build DPP
cd ../DPP && git clone https://github.com/brainboxdotcc/DPP.git .
/Applications/CMake.app/Contents/bin/cmake -B ./build \
    -DOPENSSL_INCLUDE_DIR="$PWD/../libssl/include" \
    -DOPENSSL_CRYPTO_LIBRARY="$PWD/../libssl/libcrypto.dylib" \
    -DOPENSSL_SSL_LIBRARY="$PWD/../libssl/libssl.dylib" \
    -DCMAKE_PREFIX_PATH="$PWD/../zlib"
/Applications/CMake.app/Contents/bin/cmake --build ./build -j$(sysctl -n hw.ncpu)

# Build poomer-discord
cd ../poomer-discord
git clone https://git.indoodle.com/oomer/poomer-discord.git .
curl -LO https://raw.githubusercontent.com/nothings/stb/master/stb_image.h
curl -LO https://raw.githubusercontent.com/nothings/stb/master/stb_image_write.h
make all -j$(sysctl -n hw.ncpu)