Last active
February 2, 2021 18:37
-
-
Save ajkachnic/c24f10224ceb9ad09cf35103613b8f88 to your computer and use it in GitHub Desktop.
Script to chat on repl logs
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
const fetch = require('node-fetch') | |
const prompt = require('prompt-sync')() | |
const chalk = require('chalk') | |
const nick = "@andrew" | |
const markdown = msg => { | |
const bold = /\*\*(.*)\*\*/gim | |
const strikethrough = /\~\~(.*)\~\~/gim | |
const italics = /\*(.*)\*/gim | |
return msg | |
.replace(bold, '[1m$1[22m') | |
.replace(italics, '[3m$1[23m') | |
.replace(strikethrough, '[9m$1[29m') | |
.trim() | |
} | |
const ask = async () => { | |
const text = markdown(prompt('>> ')) | |
if(text === null) process.exit(1) | |
const message = chalk.bold(nick) + `: ${chalk.dim(text)}` | |
const url = `https://blog.repl.it/${encodeURIComponent(message)}` | |
await fetch(url) | |
ask() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
well things escalated quickly 🤣