Skip to content

Instantly share code, notes, and snippets.

@fkbenjamin
Last active September 5, 2018 21:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fkbenjamin/79f8e15a3183f4bf8aa8437d05057cfa to your computer and use it in GitHub Desktop.
Save fkbenjamin/79f8e15a3183f4bf8aa8437d05057cfa to your computer and use it in GitHub Desktop.
Alerts via SMS if a new proposal on the Cosmos Testnet is found.
#!/bin/bash
phone=$1
last_proposal=$(gaiacli gov query-proposals | tail -1)
echo "Queried last proposal"
echo $last_proposal
while true
do
sleep 10s
new_last_proposal=$(gaiacli gov query-proposals | tail -1)
if [ "$last_proposal" != "$new_last_proposal" ]
then
echo "New Proposal found"
echo "Send SMS to $phone"
curl -s -d "to=%2B$phone" -d "body=Found a new proposal! $new_last_proposal" https://utils.lib.id/sms@1.0.4/
last_proposal=$new_last_proposal
echo ""
else
echo "No new Proposal $new_last_proposal"
fi
done
@fkbenjamin
Copy link
Author

fkbenjamin commented Aug 31, 2018

Time Interval can be changed. 10s is maybe too often. Every 3m should suffice.

To start: source proposal_alert.sh 49123456754 (phone number without "+")

Just a fair warning: SMS are limited to 10/hr per IP Address

@CzMcClane
Copy link

Code for autovoting, need the password typed twice in a file named pass

            sproposal_id=$(gaiacli gov query-proposals | tail -n 1 | cut -d'-' -f1)
            proposal_id=${sproposal_id//[[:blank:]]/}
            gaiacli gov vote --proposal-id=$proposal_id --option=Abstain --from=YourName --chain-id=gaia-8001 < pass

@fkbenjamin
Copy link
Author

Nice! I thought about autovoting too, but instead of saving the password in a file I would rather use expect and pass it as an argument...For now I will keep voting manually though. It's good practice for later...

@CzMcClane
Copy link

for me i've set it up to get a setting from a file and vote only if im not around. The voting period is to small and i have to sleep, i've got slashed pretty bad yesterday from missing all the proposals.

@BaryonNetwork
Copy link

Great stuff. Where can I get more information on utils.lib.id/sms ?

@BaryonNetwork
Copy link

Thanks for the auto vote motivation, here is my implementation, it keeps the key passphrase off of the filesystem.
https://gist.github.com/BaryonNetwork/a3a252a698d1c38d369f57dbc3f3ec55

@fkbenjamin
Copy link
Author

@BaryonNetwork You can find more info in the SMS lib at https://stdlib.com/@utils/lib/sms/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment