poomer-discord/README.md

73 lines
2.6 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 homebrew
curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip-components 1 -C homebrew
eval "$(homebrew/bin/brew shellenv)"
brew update --force --quiet
brew install openssl
git clone https://github.com/brainboxdotcc/DPP.git
cd DPP
/Applications/CMake.app/Contents/bin/cmake -B ./build \
-DOPENSSL_ROOT_DIR=../homebrew/opt/openssl@3 \
-DOPENSSL_INCLUDE_DIR=../homebrew/opt/openssl@3/include \
-DOPENSSL_CRYPTO_LIBRARY=../homebrew/opt/openssl@3/lib/libcrypto.a \
-DOPENSSL_SSL_LIBRARY=../homebrew/opt/openssl@3/lib/libssl.a
/Applications/CMake.app/Contents/bin/cmake --build ./build -j8
cd ..
git clone https://git.indoodle.com/oomer/poomer-discord.git
cd poomer-discord
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 -j4
```