Skip to content

Instantly share code, notes, and snippets.

@ausbitbank
Created September 18, 2019 13:03
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ausbitbank/e8f5728ba94ee8fc9671fe1db3765cc1 to your computer and use it in GitHub Desktop.
Save ausbitbank/e8f5728ba94ee8fc9671fe1db3765cc1 to your computer and use it in GitHub Desktop.
Steem engine market discord notifications (requires redis, meeseeker, webcord)
from webcord import Webhook
import redis
import json
import time
palwebhook = Webhook("URLHERE", avatar_url=None)
paltokens = ['PAL','PALM','PALMM']
r = redis.Redis()
def buy(message):
data = message['data'].decode()
jsondata = json.loads(data)
key = jsondata['key']
tx = json.loads(r.get(key).decode())
payload = tx['payload']
payload = json.loads(payload)
print(tx['sender'], 'bought ', payload['quantity'], ' ', payload['symbol'], ' for ', payload['price'], ' steem each')
msg = ":arrow_up_small: ***" + tx['sender'] + "*** bids **`" + payload['price'] + "`** STEEM for **" + payload['quantity'] + "** " + payload['symbol']
if payload['symbol'] in paltokens:
palwebhook.send_message(msg,"PALmarket")
def sell(message):
data = message['data'].decode()
jsondata = json.loads(data)
key = jsondata['key']
tx = json.loads(r.get(key).decode())
payload = tx['payload']
payload = json.loads(payload)
print(tx['sender'], 'sold ', payload['quantity'], ' ', payload['symbol'], ' for ', payload['price'], ' steem each')
msg = ":small_red_triangle_down: ***" + tx['sender'] + "*** asks **`" + payload['price'] + "`** STEEM for **" + payload['quantity'] + "** " + payload['symbol']
if payload['symbol'] in paltokens:
palwebhook.send_message(msg,"PALmarket")
b = r.pubsub(ignore_subscribe_messages=True)
b.subscribe(**{'steem_engine:market:buy': buy})
buythread = b.run_in_thread(sleep_time=0.001)
print('Subscribed to steem engine buys')
s = r.pubsub(ignore_subscribe_messages=True)
s.subscribe(**{'steem_engine:market:sell': sell})
sellthread = s.run_in_thread(sleep_time=0.001)
print('Subscribed to steem engine sells')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment