Files
sniper/include/DiscordNotifier.hpp
2026-08-09 16:51:01 -05:00

35 lines
1.4 KiB
C++

#pragma once
#include <string>
#include <vector>
#include <optional>
// Builds and sends the same "stock update" embed the python script sent via
// webhook, but preferring the bot's own REST API (POST /channels/{id}/messages)
// since we now have a real bot token. Falls back to a legacy webhook URL if
// no channel id is configured.
class DiscordNotifier {
public:
DiscordNotifier(std::string bot_token, std::string channel_id, std::string webhook_url);
void sendStockUpdate(const std::string& url,
const std::vector<std::string>& offers,
const std::string& change_text,
bool ping,
std::optional<double> min_price,
std::optional<double> max_price,
const std::vector<std::string>& keywords);
private:
std::string bot_token_;
std::string channel_id_;
std::string webhook_url_;
std::string buildPayload(const std::string& url,
const std::vector<std::string>& offers,
const std::string& change_text,
bool ping,
std::optional<double> min_price,
std::optional<double> max_price,
const std::vector<std::string>& keywords) const;
};