#!/usr/bin/env bash show_help() { cat << "HELP_TEXT" post2get - post a message to https://gettogether.dev. A clever, minimalist social network where the joke is in the name - "GET together" because you create posts using HTTP GET requests instead of the usual POST method. Usage: post2get USERNAME "MESSAGE" Arguments: USERNAME Your nickname (2-20 letters, numbers, underscores, no spaces) MESSAGE Your message (Max 280 chars. If spaces, enclose in quotes) Options: -h, --help Show this help message Examples: post2get Larry "Let's GET together at Bernie's this weekend." post2get Doc_Brown "Roads? Where we're going we don't need roads." post2get Superbad "McLovin? What kind of a stupid name is that, Fogell?" Notes: - Message MUST be in quotes if spaces used. - Username cannot contain spaces - Replying to posts is not supported by this script - Deleting posts is not supported by this script Companion scripts: - getfeed : view the feed (no colors) - getfeed-color: view the feed (with colors) HELP_TEXT } if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then show_help exit 0 fi if [ $# -ne 2 ]; then echo echo "ERROR: Invalid number of arguments" echo echo "Usage: post2get USERNAME \"MESSAGE\"" echo "Type: 'post2get -h' for more information." echo exit 1 fi NAME="$1" TEXT="$2" # Username validation per website requirements (2-20 chars, alphanumeric, underscore only) if [[ ! "$NAME" =~ ^[a-zA-Z0-9_]{2,20}$ ]]; then echo echo "ERROR: Invalid username '$NAME'" echo echo "Username must be 2-20 characters (letters, numbers, underscores only)" echo "Try 'post2get --help' for more information." echo exit 1 fi # Message must be 280 chars or less per website requirements if [ ${#TEXT} -gt 280 ]; then echo echo "ERROR: Message exceeds 280 characters (${#TEXT} chars)" echo "Try 'post2get --help' for more information." echo exit 1 fi # Post using curl as documented at https://gettogether.dev/#how-to echo echo "Posting as '$NAME'..." curl -s -G 'https://gettogether.dev/post' \ --data-urlencode "name=$NAME" \ --data-urlencode "text=$TEXT" | python3 -c " import sys, json data = json.load(sys.stdin) if data.get('ok'): print('Posted successfully! ID:', data['id']) else: print('Failed:', data) " # Blank line for cleaner output (safe to remove) echo