Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import json
- def handler_mes(datas):
- if len(datas) > 0:
- for data in datas:
- if data.get('op')[0] == 'comment' and data.get('op')[1].get('title') != '':
- print(data.get('op')[1].get('body'))
- def on_message(ws, message):
- jsons = json.loads(message)
- data_result = jsons.get('result')
- if jsons.get('id') == 1:
- height = int(data_result.get('previous')[0:8], 16)
- ws.send(json.dumps({'id': 2, 'method': 'call', 'jsonrpc':'2.0', 'params': ['operation_history', 'get_ops_in_block', [height, 'false']]}))
- elif jsons.get('id') == 2:
- handler_mes(data_result)
- def on_error(ws, error):
- print(error)
- def on_close(ws):
- print("### closed ###")
- def on_open(ws):
- 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