Skip to content

Commit

Permalink
Telegram updates added
Browse files Browse the repository at this point in the history
  • Loading branch information
safimuhammad committed Aug 23, 2022
1 parent 39ce2a8 commit a1de599
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions cryptoPriceAlert.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@

# # Add key in the key parameter in url before running the script
ethereum_api_url = 'https://api.nomics.com/v1/currencies/ticker?key=309e2d11ad8b5499d8c249e384a1c2d6418febd6&ids=ETH,BTC&interval=1d,30d&platform-currency=ETH&per-page=100&page=1'
ifttt_webhook_url = "https://maker.ifttt.com/trigger/{}/json/with/key/bnyuBAEItT2GFAHslUQwi2"
ifttt_webhook_url = "https://maker.ifttt.com/trigger/{}/with/key/bnyuBAEItT2GFAHslUQwi2"

def get_ethereum_price():
response = requests.get(ethereum_api_url)
reponse_json = response.json()
notifier_ifttt= requests.post(ifttt_webhook_url)
return float(reponse_json[0]['price'])
setFloat= float(reponse_json[0]['price'])
return float("{:.2f}".format(setFloat))


def post_notification(event, value):
print('check event',event , value)
data = {'value1': value}
ifttt_event_url = ifttt_webhook_url.format(event)
requests.post(ifttt_event_url, json=data)
Expand All @@ -26,8 +26,7 @@ def format_telegram(ethereum_history):
for ethereum_price in ethereum_history:
date = ethereum_price['date'].strftime('%d.%m.%Y %H:%M')
price = ethereum_price['price']

row = "{}: $<b>{}</b>".format(date, price)
row = '{}: $<b>{}</b>'.format(date, price)
rows.append(row)
return '<br>'.join(rows)

Expand All @@ -54,11 +53,10 @@ def main():

ethereum_history = []

time.sleep(1*5)
time.sleep(5*60)


if __name__ == '__main__':
print('main function')
main()


Expand Down

0 comments on commit a1de599

Please sign in to comment.