olety / trollabot

vk.com chat bot
http://devety.com
0 stars 0 forks source link

Suddenly stops working after running for a while #1

Open olety opened 8 years ago

olety commented 8 years ago

If you run the bot for a while (i.e. overnight), it exits the program and returns this error.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "trollabot.py", line 293, in <module>
    main()
  File "trollabot.py", line 290, in main
    bot = Trollabot()
  File "trollabot.py", line 126, in __init__
    self.start()
  File "trollabot.py", line 131, in start
    oldMsg = self._getMsg(oldMsg = oldMsg)
  File "trollabot.py", line 142, in _getMsg
    newMsg = self.vkApi.messages.get(count = 1) #get the newest message
  File "/usr/local/lib/python3.4/dist-packages/vk/api.py", line 173, in __call__
    return self._api._session.make_request(self)
  File "/usr/local/lib/python3.4/dist-packages/vk/api.py", line 67, in make_request
    response = self.send_api_request(method_request, captcha_response=captcha_response)
  File "/usr/local/lib/python3.4/dist-packages/vk/api.py", line 115, in send_api_request
    response = self.requests_session.post(url, method_args, timeout=timeout)
  File "/usr/local/lib/python3.4/dist-packages/requests/sessions.py", line 511, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/vk/utils.py", line 78, in request
    response = super(LoggingSession, self).request(method, url, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/requests/sessions.py", line 468, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.4/dist-packages/requests/sessions.py", line 576, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.4/dist-packages/requests/adapters.py", line 449, in send
    raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='api.vk.com', port=443): Read timed out. (read timeout=10)
olety commented 8 years ago

Since the original above exception is now unknown, it will be possible to identify it and solve this issue when logging to a file will be implemented.

olety commented 8 years ago

It's happening because vk.com requires user to input a CAPTCHA every once in a while. Since this bot can't recognize it, it asks for user input and user isn't always there.

One possible solution would be to add an email notifier to enter the CAPTCHA or something like that.