Advertisement
Guest User

Untitled

a guest
Jul 1st, 2018
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.87 KB | None | 0 0
  1. import json
  2.  
  3. def handler_mes(datas):
  4.     if len(datas) > 0:
  5.         for data in datas:
  6.             if data.get('op')[0] == 'comment' and data.get('op')[1].get('title') != '':
  7.                 print(data.get('op')[1].get('body'))
  8.  
  9. def on_message(ws, message):
  10.     jsons = json.loads(message)
  11.     data_result = jsons.get('result')
  12.     if jsons.get('id') == 1:
  13.         height = int(data_result.get('previous')[0:8], 16)
  14.         ws.send(json.dumps({'id': 2, 'method': 'call', 'jsonrpc':'2.0', 'params': ['operation_history', 'get_ops_in_block', [height, 'false']]}))
  15.     elif jsons.get('id') == 2:
  16.         handler_mes(data_result)
  17.  
  18.  
  19. def on_error(ws, error):
  20.     print(error)
  21.  
  22. def on_close(ws):
  23.     print("### closed ###")
  24.  
  25. def on_open(ws):
  26.     ws.send(json.dumps({'id': 1, 'method': 'call', 'jsonrpc':'2.0', 'params': ['database_api', 'set_block_applied_callback', [0]]}))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement