Skip to content

Instantly share code, notes, and snippets.

@hidao80
Created December 19, 2024 22:23
Show Gist options
  • Save hidao80/855e3248a132a11c6112808b0ca58c86 to your computer and use it in GitHub Desktop.
Save hidao80/855e3248a132a11c6112808b0ca58c86 to your computer and use it in GitHub Desktop.
A shell script to randomly post messages to Misskey.
#!/bin/bash
# Message list
MESSAGES=(
"Hello, world!"
"How's everyone doing today?"
"This is a random message."
"Hope you all are having a great day!"
"Remember to smile!"
"Coding is fun."
"Keep up the great work!"
"Misskey is awesome!"
"What are you working on today?"
"Stay positive and happy!"
)
# Select a random message
RANDOM_MESSAGE=${MESSAGES[$RANDOM % ${#MESSAGES[@]}]}
# Set Misskey instance and API key
INSTANCE_URL="https://misskey.dev"
API_KEY="your_api_key_here"
# Calculate a random time (0-1430 minutes later)
DELAY=$((RANDOM % 1431))
# Set a timer to send after the specified time
# echo "Message will be sent in $DELAY minutes."
sleep $((DELAY * 60))
# Send the message using the curl command
curl -X POST "$INSTANCE_URL/api/notes/create" \
-H "Content-Type: application/json" \
-d '{"i":"'$API_KEY'","text":"'$RANDOM_MESSAGE'"}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment