chillavanilla / TeeworldsEconMod

A python script which communicates with teeworlds server log as input and econ connection as output.
MIT License
3 stars 2 forks source link

Discord bridge utf8 bug #24

Open ChillerDragon opened 5 years ago

ChillerDragon commented 5 years ago

line: 0:-2:el pro: ¡VB 89YUOL
Traceback (most recent call last):
  File "./bot.py", line 46, in <module>
    main()
  File "./bot.py", line 38, in main
    HandleData(line)
  File "./bot.py", line 24, in HandleData
    requests.post("https://discordapp.com/api/webhooks/" + token, data={"content": line})
  File "/home/chiller/.local/lib/python3.5/site-packages/requests/api.py", line 116, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/home/chiller/.local/lib/python3.5/site-packages/requests/api.py", line 60, in request
    return session.request(method=method, url=url, **kwargs)
  File "/home/chiller/.local/lib/python3.5/site-packages/requests/sessions.py", line 519, in request
    prep = self.prepare_request(req)
  File "/home/chiller/.local/lib/python3.5/site-packages/requests/sessions.py", line 462, in prepare_request
    hooks=merge_hooks(request.hooks, self.hooks),
  File "/home/chiller/.local/lib/python3.5/site-packages/requests/models.py", line 316, in prepare
    self.prepare_body(data, files, json)
  File "/home/chiller/.local/lib/python3.5/site-packages/requests/models.py", line 507, in prepare_body
    body = self._encode_params(data)
  File "/home/chiller/.local/lib/python3.5/site-packages/requests/models.py", line 104, in _encode_params
    v.encode('utf-8') if isinstance(v, str) else v))
UnicodeEncodeError: 'utf-8' codec can't encode character '\udcc2' in position 13: surrogates not allowed
ChillerDragon commented 5 years ago
line: *** 'xxx' entered and joined the red team
line: 1:-2:x@xx: ФРРФ
Traceback (most recent call last):
  File "./bot.py", line 46, in <module>
    main()
  File "./bot.py", line 38, in main
    HandleData(line)
  File "./bot.py", line 24, in HandleData
    requests.post("https://discordapp.com/api/webhooks/" + token, data={"content": line})
  File "/home/chiller/.local/lib/python3.5/site-packages/requests/api.py", line 116, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/home/chiller/.local/lib/python3.5/site-packages/requests/api.py", line 60, in request
    return session.request(method=method, url=url, **kwargs)
  File "/home/chiller/.local/lib/python3.5/site-packages/requests/sessions.py", line 519, in request
    prep = self.prepare_request(req)
  File "/home/chiller/.local/lib/python3.5/site-packages/requests/sessions.py", line 462, in prepare_request
    hooks=merge_hooks(request.hooks, self.hooks),
  File "/home/chiller/.local/lib/python3.5/site-packages/requests/models.py", line 316, in prepare
    self.prepare_body(data, files, json)
  File "/home/chiller/.local/lib/python3.5/site-packages/requests/models.py", line 507, in prepare_body
    body = self._encode_params(data)
  File "/home/chiller/.local/lib/python3.5/site-packages/requests/models.py", line 104, in _encode_params
    v.encode('utf-8') if isinstance(v, str) else v))
UnicodeEncodeError: 'utf-8' codec can't encode character '\udcd0' in position 13: surrogates not allowed
ChillerDragon commented 5 years ago
line: 5:-2:xxx: español?
Traceback (most recent call last):
  File "./bot.py", line 46, in <module>
    main()
  File "./bot.py", line 38, in main
    HandleData(line)
  File "./bot.py", line 24, in HandleData
    requests.post("https://discordapp.com/api/webhooks/" + token, data={"content": line})
  File "/home/chiller/.local/lib/python3.5/site-packages/requests/api.py", line 116, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/home/chiller/.local/lib/python3.5/site-packages/requests/api.py", line 60, in request
    return session.request(method=method, url=url, **kwargs)
  File "/home/chiller/.local/lib/python3.5/site-packages/requests/sessions.py", line 519, in request
    prep = self.prepare_request(req)
  File "/home/chiller/.local/lib/python3.5/site-packages/requests/sessions.py", line 462, in prepare_request
    hooks=merge_hooks(request.hooks, self.hooks),
  File "/home/chiller/.local/lib/python3.5/site-packages/requests/models.py", line 316, in prepare
    self.prepare_body(data, files, json)
  File "/home/chiller/.local/lib/python3.5/site-packages/requests/models.py", line 507, in prepare_body
    body = self._encode_params(data)
  File "/home/chiller/.local/lib/python3.5/site-packages/requests/models.py", line 104, in _encode_params
    v.encode('utf-8') if isinstance(v, str) else v))
UnicodeEncodeError: 'utf-8' codec can't encode character '\udcc3' in position 17: surrogates not allowed