93 lines
3.4 KiB
Markdown
93 lines
3.4 KiB
Markdown
# 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
|
|
|
|
### Ubuntu Linux
|
|
|
|
```
|
|
sudo apt install build-essential git cmake -y
|
|
mkdir workdir && cd workdir
|
|
mkdir zlib libssl DPP poomer-discord sqlite3 && cd zlib
|
|
git clone https://github.com/madler/zlib.git .
|
|
./configure --static
|
|
make -j4
|
|
cd ../libssl && git clone https://github.com/openssl/openssl.git .
|
|
./Configure linux-x86_64 no-shared
|
|
make -j4
|
|
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 -j4
|
|
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 -j4
|
|
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 -j4
|
|
```
|
|
|
|
### MacOS
|
|
|
|
```
|
|
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 darwin64-arm64-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)
|
|
```
|
|
|
|
|
|
|