support pnut api v1
This commit is contained in:
parent
84e96df945
commit
90a831650a
1 changed files with 18 additions and 17 deletions
|
@ -22,7 +22,7 @@ _connected = threading.Event()
|
|||
_error = threading.Event()
|
||||
|
||||
def subscribe(connection_id):
|
||||
url = f"https://api.pnut.io/v0/channels/{config['CHANNEL']}/messages"
|
||||
url = f"https://api.pnut.io/v1/channels/{config['CHANNEL']}/messages"
|
||||
url += "?connection_id=" + connection_id
|
||||
headers = {'Authorization': "Bearer " + config['ACCESS_TOKEN']}
|
||||
r = requests.get(url, headers=headers)
|
||||
|
@ -302,7 +302,8 @@ def on_message(ws, message):
|
|||
|
||||
if "channel_type" in msg['meta'] and msg['meta']['channel_type'] == "io.pnut.core.chat":
|
||||
|
||||
pmsg = pnutpy.models.Message.from_response_data(msg['data'])
|
||||
for d_item in msg['data']:
|
||||
pmsg = pnutpy.models.Message.from_response_data(d_item)
|
||||
|
||||
if 'is_deleted' in msg['meta']:
|
||||
return
|
||||
|
@ -380,7 +381,7 @@ if __name__ == "__main__":
|
|||
|
||||
pnutpy.api.add_authorization_token(config['ACCESS_TOKEN'])
|
||||
|
||||
ws_url = "wss://stream.pnut.io/v0/user"
|
||||
ws_url = "wss://stream.pnut.io/v1/user"
|
||||
ws_url += "?access_token=" + config['ACCESS_TOKEN']
|
||||
|
||||
# setup the websocket connection
|
||||
|
|
Loading…
Reference in a new issue