~ysu/gemini-chatroom

ref: a680799a0b1808899ff69d862b47e068068da2ea gemini-chatroom/bin/chat0/post -rwxr-xr-x 557 bytes
a680799a — vps changed message formatting 2 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#! /bin/bash

chatNum=0

if [ -z "$QUERY_STRING" ]; then
	echo -e "10 Message\r\n"
fi

user=$(echo $PATH_INFO | cut -d '/' -f 2)

if [ -z "$user" ]; then
	user="anon"
fi

nstr=$(echo $QUERY_STRING | sed 's/\(%0A\|
\)/ /g' | sed 's/%/\\x/g')
nuser=$(echo ${user//[!A-z]/})

if [ $(cat last_message) != $nstr ]; then
	printf "($(date "+%Y/%m/%d %R %Z")) $(echo $nuser: $nstr | awk '{printf "%9s %s\n", $1, $2}')\n" >> message_log
	echo $nstr > last_message
	echo -e "30 /bin/chat$chatNum\r\n"
else
	echo -e "40 Message failed! Reason: Spam protection\r\n"
fi