rearob
Version:
Reading robot (rero) can read any letter you gave XD
50 lines (43 loc) • 1.65 kB
JavaScript
const readline = require('readline')
const { exec } = require('child_process')
const letter = { ' ':100, a:11, b:12, c:13, d:14, e:15, f:16, g:17, h:18, i:19, j:20, k:21, l:22, m:23, n:24, o:25, p:26, q:27, r:28, s:29, t:30, u:31, v:32, w:33, x:34, y:35, z:36 }
let text = ''
function ask () {
let interface = readline.createInterface({ input : process.stdin, output : process.stdout })
interface.on('close', _ => {
if ( !text.length ) process.exit()
console.log('\r\nListen it!\r\n')
exec(`powershell.exe [console]::beep(1000, 500)`)
setTimeout(speel, 1000, 0)
})
setTimeout(_ => {
interface.question('What should i read now? >>> ', answer => {
text = answer
interface.close()
})
}, 1000)
}
function speel (x) {
const char = text[x]?.toLowerCase()
const charNumber = letter[char]
if ( charNumber && x < text.length ) {
process.stdout.write(char)
exec(`powershell.exe [console]::beep(${charNumber+'00'},100)`)
setTimeout(speel, 200, x+1)
} else {
console.log('\r\n\r\nFinish dude!\r\n')
text = ''
setTimeout(_ => {
exec(`powershell.exe [console]::beep(2500, 250)`)
exec(`powershell.exe [console]::beep(2000, 250)`)
exec(`powershell.exe [console]::beep(1500, 250)`)
exec(`powershell.exe [console]::beep(1000, 250)`)
}, 500)
setTimeout(ask, 1000)
}
}
setTimeout(exec, 500, `powershell.exe [console]::beep(1100, 250)`)
setTimeout(exec, 100, `powershell.exe [console]::beep(1200, 250)`)
setTimeout(exec, 100, `powershell.exe [console]::beep(1300, 250)`)
setTimeout(exec, 100, `powershell.exe [console]::beep(1400, 250)`)
setTimeout(ask, 1000)