#!/bin/bash #2026 miredo version="2" refresh_time=30 #strip out excess keypresses cleanbuffer() { while read -t 0 do read -N 1 -s done } #reset all colors reset_col() { echo -e -n "\033[0m" } #set the color #usage: set_col color bold #color 30-37: blk, red, grn, ylw, blu, mag, cyn, wht #40-47 set the background color #bold is 1 or 0 set_col() { echo -e -n "\033[$2;$1m" } #main program starts here, shows the intro reset_col clear set_col 36 0 echo "miredo's comchat viewer for Chat@Heyuri" echo "version $version" set_col 36 1 echo "press q to exit" sleep 1 #minimum time to show the header #main loop here while true do #get terminal size scr_w=`tput cols` scr_h=`tput lines` #load and format the message list reset_col set_col 31 1 echo "[loading...]" cleanbuffer #TODO: handle HTML entities somehow lol #TODO: strip all control characters - probably not an issue, but there isn't a real reason to not do it msg="$(curl -s https://cgi.heyuri.net/chat/simplelog.txt | fold -s -w $scr_w | head -n $(expr $scr_h - 3) )" clear set_col 44 0 set_col 37 1 echo "[refeshed on $(date) | ($scr_w"x"$scr_h) | reload: $refresh_time"s"]" #display the messages #dumb hack that admittedly doesn't matter to show the first line in a diferent color reset_col set_col 37 1 echo "$msg" | head -n 1 reset_col echo "$msg" | tail -n +2 set_col 44 0 set_col 37 1 echo "keys: q-quit, all others refresh" reset_col #handle quit/refresh, quits on q read -t $refresh_time -N 1 -s inp if [[ "$inp" == "q" ]] then exit 1 fi cleanbuffer set_col 33 1 echo "[refreshing...]" reset_col sleep 1 #minimum time so we don't hammer the site with a bunch of requests done