From d9713c9184741a00c9d15f3ae50c96a5695afd92 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Wed, 23 Jul 2025 17:45:09 +0500 Subject: fix: some fixes in rss --- bot/src/rss.cpp | 21 ++++++++++----------- bot/src/schemas/stream.cpp | 8 +++++++- 2 files changed, 17 insertions(+), 12 deletions(-) (limited to 'bot/src') diff --git a/bot/src/rss.cpp b/bot/src/rss.cpp index a52c176..3a1b575 100644 --- a/bot/src/rss.cpp +++ b/bot/src/rss.cpp @@ -64,7 +64,7 @@ namespace bot { while (true) { this->add_channels(); this->check_channels(); - std::this_thread::sleep_for(std::chrono::seconds(30)); + std::this_thread::sleep_for(std::chrono::seconds(60)); } } @@ -117,9 +117,6 @@ namespace bot { break; case schemas::TELEGRAM: bridge = "TelegramBridge"; - if (name[0] != '@') { - name = "%40" + name; - } break; default: break; @@ -229,14 +226,17 @@ namespace bot { this->irc_client.say(event.channel_alias_name, msg); } } + + it->messages = channel->messages; } } - std::optional get_rss_channel(const std::string &url) { - cpr::Response response = cpr::Get( - cpr::Url{url}, - cpr::Header{{"Accept", "application/xml"}, - {"User-Agent", "https://github.com/ilotterytea/bot"}}); + std::optional get_rss_channel(const std::string& url) { + cpr::Response response = + cpr::Get(cpr::Url{url}, cpr::Header{{"Accept", "application/xml"}, + {"User-Agent", "Mozilla/5.0"}, + {"Cache-Control", "no-cache"}, + {"Pragma", "no-cache"}}); if (response.status_code != 200) { return std::nullopt; @@ -250,7 +250,6 @@ namespace bot { pugi::xml_node channel = doc.child("rss").child("channel"); std::string channel_name = channel.child("title").text().as_string(); - std::string channel_url = channel.child("link").text().as_string(); std::vector messages; for (pugi::xml_node item : channel.children("item")) { @@ -271,6 +270,6 @@ namespace bot { timestamp}); } - return (RSSChannel){channel_name, channel_url, std::nullopt, messages}; + return (RSSChannel){channel_name, url, std::nullopt, messages}; } } \ No newline at end of file diff --git a/bot/src/schemas/stream.cpp b/bot/src/schemas/stream.cpp index 80fc854..f9981a0 100644 --- a/bot/src/schemas/stream.cpp +++ b/bot/src/schemas/stream.cpp @@ -82,7 +82,13 @@ namespace bot::schemas { return "bttv_updated_emote"; } #endif - else { + else if (type == RSS) { + return "rss"; + } else if (type == TWITTER) { + return "twitter"; + } else if (type == TELEGRAM) { + return "telegram"; + } else { return "custom"; } } -- cgit v1.2.3