简体   繁体   中英

requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://chat.meta.stackexchange.com/chats/1543/messages/new

I have a simple piece of code for a chat bot:

from chatexchange.client import Client

email = "generic_email@mail.com"
password = "**********"
se_chat = Client("meta.stackexchange.com")
se_chat.login(email, password)

def on_event(event, _):
    if event.data['event_type'] == 1:
        event.message.reply("Hello World!")

room = se_chat.get_room('1543')
room.join()
room.watch_socket(on_event)

while True:
    pass

room.leave()

But when I run the code, I get:

Exception in thread message_sender:
Traceback (most recent call last):
  File "C:\Users\wil\AppData\Local\Programs\Python\Python37\lib\threading.py", line 926, in _bootstrap_inner
    self.run()
  File "C:\Users\wil\AppData\Local\Programs\Python\Python37\lib\threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\wil\AppData\Local\Programs\Python\Python37\lib\site-packages\chatexchange\client.py", line 183, in _worker
    self._do_action_despite_throttling(next_action)
  File "C:\Users\wil\AppData\Local\Programs\Python\Python37\lib\site-packages\chatexchange\client.py", line 221, in _do_action_despite_throttling
    response = self._br.send_message(room_id, text)
  File "C:\Users\wil\AppData\Local\Programs\Python\Python37\lib\site-packages\chatexchange\browser.py", line 301, in send_message
    {'text': text})
  File "C:\Users\wil\AppData\Local\Programs\Python\Python37\lib\site-packages\chatexchange\browser.py", line 133, in post_fkeyed
    return self.post(url, data, headers)
  File "C:\Users\wil\AppData\Local\Programs\Python\Python37\lib\site-packages\chatexchange\browser.py", line 113, in post
    return self._request('post', url, data, headers, with_chat_root)
  File "C:\Users\wil\AppData\Local\Programs\Python\Python37\lib\site-packages\chatexchange\browser.py", line 102, in _request
    response.raise_for_status()
  File "C:\Users\wil\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\models.py", line 940, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://chat.meta.stackexchange.com/chats/1543/messages/new

What is wrong with my code?

I have a simple piece of code for a chat bot:

from chatexchange.client import Client

email = "generic_email@mail.com"
password = "**********"
se_chat = Client("meta.stackexchange.com")
se_chat.login(email, password)

def on_event(event, _):
    if event.data['event_type'] == 1:
        event.message.reply("Hello World!")

room = se_chat.get_room('1543')
room.join()
room.watch_socket(on_event)

while True:
    pass

room.leave()

But when I run the code, I get:

Exception in thread message_sender:
Traceback (most recent call last):
  File "C:\Users\wil\AppData\Local\Programs\Python\Python37\lib\threading.py", line 926, in _bootstrap_inner
    self.run()
  File "C:\Users\wil\AppData\Local\Programs\Python\Python37\lib\threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\wil\AppData\Local\Programs\Python\Python37\lib\site-packages\chatexchange\client.py", line 183, in _worker
    self._do_action_despite_throttling(next_action)
  File "C:\Users\wil\AppData\Local\Programs\Python\Python37\lib\site-packages\chatexchange\client.py", line 221, in _do_action_despite_throttling
    response = self._br.send_message(room_id, text)
  File "C:\Users\wil\AppData\Local\Programs\Python\Python37\lib\site-packages\chatexchange\browser.py", line 301, in send_message
    {'text': text})
  File "C:\Users\wil\AppData\Local\Programs\Python\Python37\lib\site-packages\chatexchange\browser.py", line 133, in post_fkeyed
    return self.post(url, data, headers)
  File "C:\Users\wil\AppData\Local\Programs\Python\Python37\lib\site-packages\chatexchange\browser.py", line 113, in post
    return self._request('post', url, data, headers, with_chat_root)
  File "C:\Users\wil\AppData\Local\Programs\Python\Python37\lib\site-packages\chatexchange\browser.py", line 102, in _request
    response.raise_for_status()
  File "C:\Users\wil\AppData\Local\Programs\Python\Python37\lib\site-packages\requests\models.py", line 940, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://chat.meta.stackexchange.com/chats/1543/messages/new

What is wrong with my code?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM