35 lines
1.4 KiB
C++
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;
|
|
};
|