summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2025-07-23 17:45:09 +0500
committerilotterytea <iltsu@alright.party>2025-07-23 17:45:09 +0500
commitd9713c9184741a00c9d15f3ae50c96a5695afd92 (patch)
tree06d2f2f65566a4c50adaf1ba93a5edd4ed151e95
parentbdf5110655da586e05da0c5dff3512b4d83bd207 (diff)
fix: some fixes in rss
-rw-r--r--bot/src/rss.cpp21
-rw-r--r--bot/src/schemas/stream.cpp8
2 files changed, 17 insertions, 12 deletions
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<RSSChannel> 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<RSSChannel> 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<RSSMessage> 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";
}
}