pip3 install requests
This program uses a MySql database. You can run the db_update.sql
to create the table that the program needs.
Register IFTTT and create an activity
- Create your applet after signing up for [IFTTT].
- Click the big blue「+This」button.
- Search for the「Webhooks」service, then select「Receive a web request」.
- Rename the「event」for you want to name, for example,
ico_price_emergency
- Then click the big blue「+That」button.
- Search the「notifications」service and select「send a notification from the IFTTT app」.
- Change the「Title」to
{{Value1}}
,「Message」to{{Value2}}
, the「Link URL」to{{Value3}}
. - Click the「Finish」button to complete.
- Open the IFTTT webhooks and click the「Documentation」button in the upper right corner.
- The Documentation page has your
Webhooks URL
, includingEvent Name
andkey
, which is used in the python code.
Edit PriceReminder.py, Change the top variable to your own information: KEY
, MySql Database info and REMINDER_POINT
.
# IFTTT Info
KEY = "your_ifttt key"
IFTTT_WEBHOOKS_URL = 'https://maker.ifttt.com/trigger/{}/with/key/%s' % KEY
EVENT_NAME = "your_event_name"
# Database information
DB_HOST = "localhost"
DB_USER = "your_db_user_name"
DB_PWD = "your_db_password"
DB_NAME = "ICO"
DB_CHARSET = "utf8mb4"
# Other Setting
REMINDER_POINT = 0.05
ICO_API_URL = 'https://api.coinmarketcap.com/v1/ticker/'
Set the timer task in CentOS using crontab
.
crontab -e # Edit timing task
# Save and exit by adding a line of the following code to the timed task
*/2 * * * * python3.6 PriceReminder.py
crontab -l # View the current list of timed tasks
service crond start && service crond status # Start the timer task and check the status
crontab configuration format
* * * * * command # minute(0-59) hour(0-23) day(1-31) month(1-12) week(0-6, 0 is Sunday) command # Column 1 represents minutes 1 to 59, '*' or '*/1' is every minute. # Column 2 represents hours 1 to 23(0 is zero) # Column 3 represents dates 1 to 31 # Column 4 represents months 1 through 12 # Column 5 marks week 0 ~ 6(0 is Sunday)
After completing the above steps, you can wait for it to run the script every two minutes!