summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2025-10-26 22:32:49 +0500
committerilotterytea <iltsu@alright.party>2025-10-26 22:32:49 +0500
commit94e74ac79e775253b56384748c619a764d31e091 (patch)
tree403969aba0a764a2dad89da47d3d4764654c6873
parent051ec346e7e0f2581d15ffd8a696caa195c989e4 (diff)
feat: fetch recent messages
-rw-r--r--scripts/chat.js15
-rw-r--r--twitch.html12
2 files changed, 25 insertions, 2 deletions
diff --git a/scripts/chat.js b/scripts/chat.js
index 8f7e31f..e6c9e81 100644
--- a/scripts/chat.js
+++ b/scripts/chat.js
@@ -182,4 +182,19 @@ function connectToChat(host, nick, password, room) {
clearInterval(membershipInterval);
setTimeout(() => connectToChat(host, nick, password, room), 5000);
});
+}
+
+function getRecentMessages(room) {
+ fetch(`https://recent-messages.robotty.de/api/v2/recent-messages/${room}`)
+ .then((r) => r.json())
+ .then((json) => {
+ if (json["error"] != null) {
+ addSystemMessage(`${json["error"]} (Recent messages)`);
+ return;
+ }
+
+ for (const message of json["messages"]) {
+ addMessage(parseIRCMessage(message));
+ }
+ });
} \ No newline at end of file
diff --git a/twitch.html b/twitch.html
index 9adc40c..504c752 100644
--- a/twitch.html
+++ b/twitch.html
@@ -16,7 +16,9 @@
<script>
let user = null;
const params = {
- "tinyemotesinstances": null
+ "channel": null,
+ "tinyemotesinstances": null,
+ "fetchrecentmessages": null
};
const badges = {};
const emotes = {};
@@ -26,7 +28,7 @@
params[k] = v;
}
- if (!("channel" in params)) {
+ if (params.channel == null) {
addSystemMessage("No channel specified!");
return;
}
@@ -38,7 +40,13 @@
addSystemMessage(`Channel #${params["channel"]} does not exist.`);
return;
}
+
user = json[0];
+
+ if (params.fetchrecentmessages != null) {
+ getRecentMessages(user["login"]);
+ }
+
connectToChat("wss://irc-ws.chat.twitch.tv", "justinfan12345", "65432", user["login"]);
getTwitchBadges(user["login"], badges);