-
-
Save mishushakov/eb281f8edbb7e2bd2e6580de193d87f4 to your computer and use it in GitHub Desktop.
Pepe the Frog from Deno Deploy Demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Grab ascii pepe from gist | |
const pepe = await fetch('https://gist.github.com/mishushakov/eb281f8edbb7e2bd2e6580de193d87f4/raw/15c4dcb0c913a33d71ae0f84879fd311f6811652/pepe_small.txt') | |
const pepe_txt = await pepe.text() | |
// List of greetings to which pepe responds | |
const greetings = ['Hello', 'Hi', 'Hey', 'hello', 'hi', 'hey', 'pepe'] | |
// Last time pepe appeared | |
let lastgreeting = Date.now() | |
const connect = function () { | |
// Connect to the demo | |
const ws = new WebSocket('wss://mini-ws-chat.deno.dev') | |
ws.onmessage = async (m) => { | |
// Check if pepe was greeted | |
if (greetings.includes(m.data)) { | |
// Calculate the difference (in seconds) between last time pepe was greeted | |
const difference = Math.floor((Date.now() - lastgreeting) / 1000) | |
// If difference is greater than 60 seconds, draw the pepe | |
if (difference >= 60) { | |
pepe_txt.split(/\r?\n/).forEach(line => ws.send(line)) | |
// Reset the date | |
lastgreeting = Date.now() | |
} | |
} | |
} | |
// Handle error | |
ws.onerror = (e) => console.log(e) | |
// Handle connection drop | |
ws.onclose = () => connect() | |
} | |
connect() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
████████ ██████ | |
█░░░░░░░░██ ██░░░░░░█ | |
█░░░░░░░░░░░█░░░░░░░░░█ | |
█░░░░░░░███░░░█░░░░░░░░░█ | |
█░░░░███░░░███░█░░░████░█ | |
█░░░██░░░░░░░░███░██░░░░██ | |
█░░░░░░░░░░░░░░░░░█░░░░░░░░███ | |
█░░░░░░░░░░░░░██████░░░░░████░░█ | |
█░░░░░░░░░█████░░░████░░██░░██░░█ | |
██░░░░░░░███░░░░░░░░░░█░░░░░░░░███ | |
█░░░░░░░░░░░░░░█████████░░█████████ | |
█░░░░░░░░░░█████ ████ ████ █████ █ | |
█░░░░░░░░░░█ █ ███ █ ███ █ █ | |
█░░░░░░░░░░░░█ ████ ████ ██ ██████ | |
░░░░░░░░░░░░░█████████░░░████████░░░█ | |
░░░░░░░░░░░░░░░░█░░░░░█░░░░░░░░░░░░█ | |
░░░░░░░░░░░░░░░░░░░░██░░░░█░░░░░░██ | |
░░░░░░░░░░░░░░░░░░██░░░░░░░███████ | |
░░░░░░░░░░░░░░░░██░░░░░░░░░░█░░░░░█ HELLO HELLO, THIS IS PEPE FROM HACKERNEWS! | |
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█ MORE: https://news.ycombinator.com/item?id=29131751 | |
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█ CODE: https://git.io/JXTZu | |
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█ | |
░░░░░░░░░░░█████████░░░░░░░░░░░░░░██ | |
░░░░░░░░░░█▒▒▒▒▒▒▒▒███████████████▒▒█ | |
░░░░░░░░░█▒▒███████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒█ | |
░░░░░░░░░█▒▒▒▒▒▒▒▒▒█████████████████ | |
░░░░░░░░░░████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒█ | |
░░░░░░░░░░░░░░░░░░██████████████████ | |
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█ | |
██░░░░░░░░░░░░░░░░░░░░░░░░░░░██ | |
▓██░░░░░░░░░░░░░░░░░░░░░░░░██ | |
▓▓▓███░░░░░░░░░░░░░░░░░░░░█ | |
▓▓▓▓▓▓███░░░░░░░░░░░░░░░██ | |
▓▓▓▓▓▓▓▓▓███████████████▓▓█ | |
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██ | |
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█ | |
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓█ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
▄█▀▀▀▀▀▀█▄ ▄▀▀▀▀▀▀▄ | |
▄▀░░░░░░▄▄▄▄▀█░░░░░░░░▀▄ | |
█░░░░░░▀▀░░░░▀▀█▄▀▀▀▀▀▀▀█▄ | |
█░░░░░░░░▄▄████████▄░▄███████▄ | |
▄▀░░░░░░░▀███████████▄██████████▄ | |
█▀░░░░░▄▀▀█▀░▄█▄███▄░▀█░▄█▄███░░░█ | |
█░░░░░░░▀▀█▀▀▄▄█████▄▄▀▀▄▄█████▀▀▀█ | |
█▀░░░░░░░░░░▀▄▄▄▄▄▄▄▄▄▄▀░░░░░░░░▄█▀ HELLO HELLO, THIS IS PEPE FROM HACKERNEWS! | |
█░░░░░░░░░░░░░░░░░░▄▀░░░░░░▀█▀▀▀█▄ MORE: https://news.ycombinator.com/item?id=29131751 | |
█░░░░░░░░░░░▄▄▄▄░░░░░░░░░░░░░░░░░█ CODE: https://git.io/JXTZu | |
█░░░░░░░░▄▀▀░▄▄░▀▀▀▀▀▄▄▄▄▄▄▄▀▀▀▀▀▀█ | |
▀█░░░░░█░▀▄▀▀░░▀▀▀▀▀▄▄▄▄▄▄▄▄▄▄▄▄▄█ | |
▄█▄▄░░░▀▄░░▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▄▄▄▄▄▄▀ | |
▄▀▀░▀██▄░░░▀▀░░░░░░░░░░░░░░▄▄▄▀▀ | |
░░░░░░▀▀███▄▄▄▄▄▄▄▄▄▄▄▄▄████▄ | |
░░░░░░░░░░▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀░░░▀█▄ | |
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░█ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment