SHARE
TWEET

Untitled

a guest Jul 16th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import discord
  2. import telebot
  3. import time
  4. import websocket
  5. import json
  6.  
  7.  
  8. client = discord.Client()
  9.  
  10.  
  11. try:
  12.     import thread
  13. except ImportError:
  14.     import _thread as thread
  15.  
  16. def on_message(ws, message):
  17.     data = json.loads(message)
  18.     if 'data' in data:
  19.         totalSize = 0
  20.         for d in data['data']:
  21.             totalSize = totalSize + d['size']
  22.         print(totalSize)
  23.  
  24.  
  25. def on_error(ws, error):
  26.     print(error)
  27.  
  28. def on_close(ws):
  29.     print("### closed ###")
  30.  
  31. def on_open(ws):
  32.     def run(*args):
  33.         thread.start_new_thread(run, ())
  34.  
  35. #
  36. # if __name__ == "__main__":
  37. #   websocket.enableTrace(True)
  38. #   ws = websocket.WebSocketApp("wss://www.bitmex.com/realtime?subscribe=trade:XBTUSD",
  39. #                                                           on_message = on_message,
  40. #                                                           on_error = on_error,
  41. #                                                           on_close = on_close)
  42. #   ws.on_open = on_open
  43. #   ws.run_forever()
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51. @client.event
  52. async def on_ready():
  53.     print('Logged in as')
  54.     print(client.user.name)
  55.     print(client.user.id)
  56.     print('------')
  57.     websocket.enableTrace(True)
  58.     ws = websocket.WebSocketApp("wss://www.bitmex.com/realtime?subscribe=trade:XBTUSD")
  59.     print(ws.recv())
  60.     ws.run_forever()
  61.  
  62.  
  63.  
  64. client.run('NTk4NjUxODk1MjEyNjcwOTg3.XSu74A.bFR6HQyv1pYudh64RqqIXvuU1RI')
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top