Skip to content

Commit

Permalink
docs: add basic browser example
Browse files Browse the repository at this point in the history
  • Loading branch information
Whipstickgostop committed Sep 25, 2024
1 parent 6755ccb commit cfe8e03
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
12 changes: 12 additions & 0 deletions examples/browser/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<title>Twitch Chat Example | Streamer.bot Client</title>
<link rel="stylesheet" href="style.css">
</head>
<script type="text/javascript" src="https://unpkg.com/@streamerbot/client/dist/streamerbot-client.js"></script>
<script type="text/javascript" src="script.js"></script>
<body>
<div id="chat"></div>
</body>
</html>
5 changes: 5 additions & 0 deletions examples/browser/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const client = new StreamerbotClient();

client.on('Twitch.ChatMessage', ({ data }) => {
document.getElementById('chat').innerHTML += `<div class="message"><span class="username" style="color: ${data.message.color}">${data.message.displayName}</span>${data.message.message}</div>`;
});
17 changes: 17 additions & 0 deletions examples/browser/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
body {
background-color: #222;
color: #fff;
font-family:'Segoe UI', Tahoma, Geneva, Verdana, sans-serif
}

.message {
margin: 1em;
padding: 1em;
border-radius: .5em;
background-color: #333;
}

.username {
font-weight: bold;
margin-right: .5em;
}

0 comments on commit cfe8e03

Please sign in to comment.