ValvePython / dota2

🐸 Python package for interacting with Dota 2 Game Coordinator
http://dota2.readthedocs.io
204 stars 32 forks source link

Chat feature. #20

Closed Philaeux closed 7 years ago

Philaeux commented 7 years ago

Every function are tested working except the request_chat_channels which gives me a protobuff decode error:

[2017-01-02 23:59:22,912] DEBUG Emit event: <EMsg.ClientFromGC: 5453>
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/gevent/greenlet.py", line 536, in run
    result = self._run(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.4/dist-packages/steam/client/gc.py", line 117, in _handle_from_gc
    self._process_gc_message(clear_proto_bit(emsg), header, body)
  File "/usr/local/lib/python3.4/dist-packages/dota2/client.py", line 107, in _process_gc_message
    message.ParseFromString(payload)
  File "/usr/local/lib/python3.4/dist-packages/google/protobuf/message.py", line 185, in ParseFromString
    self.MergeFromString(serialized)
  File "/usr/local/lib/python3.4/dist-packages/google/protobuf/internal/python_message.py", line 1087, in MergeFromString
    if self._InternalParse(serialized, 0, length) != length:
  File "/usr/local/lib/python3.4/dist-packages/google/protobuf/internal/python_message.py", line 1123, in InternalParse
    pos = field_decoder(buffer, new_pos, end, self, field_dict)
  File "/usr/local/lib/python3.4/dist-packages/google/protobuf/internal/decoder.py", line 612, in DecodeRepeatedField
    if value.add()._InternalParse(buffer, pos, new_pos) != new_pos:
  File "/usr/local/lib/python3.4/dist-packages/google/protobuf/internal/python_message.py", line 1123, in InternalParse
    pos = field_decoder(buffer, new_pos, end, self, field_dict)
  File "/usr/local/lib/python3.4/dist-packages/google/protobuf/internal/decoder.py", line 502, in DecodeField
    field_dict[key] = _ConvertToUnicode(buffer[pos:new_pos])
  File "/usr/local/lib/python3.4/dist-packages/google/protobuf/internal/decoder.py", line 469, in _ConvertToUnicode
    return local_unicode(byte_str, 'utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd0 in position 62: 'utf-8' codec can't decode byte 0xd0 in position 62: unexpected end of data in field: CMsgDOTARequestChatChannelListResponse.ChatChannel.channel_name
Mon Jan  2 23:59:22 2017 <Greenlet at 0x7f87a816c5a0: <bound method Dota2Client._handle_from_gc of <Dota2Client(<SteamClient(('162.254.196.42', 27021)) online>) <GCConnectionStatus.HAVE_SESSION: 0>>>(<MsgProto <EMsg.ClientFromGC: 5453>>)> failed with UnicodeDecodeError
rossengeorgiev commented 7 years ago

Thanks. I had a brief look through code and I not sure that is the API. I think there should be chat channel and those channel specific methods should be on there. Also, I don't see any tracking of members of each channel. This is a tricky bit as some channel types will get the member list as proto message, including any players who join/leave. Other types get their member list through a http api.

Anyway, I will make a separate branch and make some changes to this.