HuyaneMatsu / hata

Async Discord API wrapper.

Home Page:https://www.astil.dev/project/hata/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug] Cannot use Fosscord with Hata

Yu-Vitaqua-fer-Chronos opened this issue · comments

Description

I'm attempting to use Hata with Fosscord, a reimplementation of the discord API, but currently my program refuses to work correctly due to errors. Here are the errors i have, the first one uses is_bot=False, but the result of the second error keeps is_bot to True

Traceback (most recent call last):
  File "/data/data/com.termux/files/home/hata-foss/main.py", line 18, in <module>
    acc.start()
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/hata/discord/client/client.py", line 14797, in start
    return task.sync_wrap().wait()
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/scarletio-1.0.5-py3.10.egg/scarletio/core/traps/future_sync_wrapper.py", line 392, in wait
    return self.result()
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/scarletio-1.0.5-py3.10.egg/scarletio/core/traps/future_sync_wrapper.py", line 221, in result
    raise exception
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/scarletio-1.0.5-py3.10.egg/scarletio/core/traps/task.py", line 480, in _step
    result = coroutine.send(None)
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/hata/discord/client/client.py", line 14884, in connect
    await self.client_gateway_reshard()
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/hata/discord/client/client.py", line 14685, in client_gateway_reshard
    new_shard_count = data['shards']
KeyError: 'shards'
Unexpected exception occurred at <Client id=920060660405632105 (partial)>._connect
Traceback (most recent call last):
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/hata/discord/client/client.py", line 14916, in _connect
    await self.gateway.run()
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/hata/discord/gateway/client_gateway.py", line 172, in run
    should_reconnect = await self._poll_event()
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/hata/discord/gateway/client_gateway.py", line 292, in _poll_event
    return (await self._received_message(message))
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/hata/discord/gateway/client_gateway.py", line 329, in _received_message
    sequence = message['s']
KeyError('s')
If you can reproduce this bug, Please send me a message or open an issue with your code, and with every detail how to reproduce it.
Thanks!

Reproduction Steps

No response

Reproduction Code

from os import environ

environ['HATA_API_ENDPOINT']     = "https://dev.fosscord.com/api/"
environ['HATA_CDN_ENDPOINT']     = "https://cdn.fosscord.com/"
environ['HATA_DISCORD_ENDPOINT'] = "https://dev.fosscord.com/"

from hata import Client

token = "MY TOKEN"

acc = Client(token, is_bot=False)


@acc.events
async def message_create(client, message):
    print(m.author.full_name+': '+m.clean_content)

acc.start()

Expected behaviour

The bot should connect successfully to the gateway

Actual behaviour

It failed to run

System information

Hata version: 1.1.127
Platform: Linux-4.14.180-perf-gaefbc3caa24c-aarch64-with-libc
Python implementation: cpython
Python version: 3.10 final

Pushed fix to github, will be alive next update 👍🏻

Still not fixed aha, just tried it right now:

Unexpected exception occurred at <Client id=920060660405632105 (partial)>._connect
Traceback (most recent call last):
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/hata/discord/client/client.py", line 15124, in _connect
    await self.gateway.run()
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/hata/discord/gateway/client_gateway.py", line 172, in run
    should_reconnect = await self._poll_event()
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/hata/discord/gateway/client_gateway.py", line 292, in _poll_event
    return (await self._received_message(message))
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/hata/discord/gateway/client_gateway.py", line 328, in _received_message
    data = message['d']
KeyError('d')
If you can reproduce this bug, Please send me a message or open an issue with your code, and with every detail how to reproduce it.
Thanks!

It's the same code as the snippet provided, with is_bot set to False

Hata version: 1.1.128
Platform: Linux-4.14.180-perf-gaefbc3caa24c-aarch64-with-libc
Python implementation: cpython
Python version: 3.10 final

Another issue when trying to connect, using latest Hata version

Exception occurred at calling Client.connect
Traceback (most recent call last):
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/hata/discord/client/client.py", line 15010, in connect
    data = await self.client_login_static()
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/hata/discord/client/client.py", line 2226, in client_login_static
    data = await self.http.client_user_get()
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/hata/discord/http/http_client.py", line 334, in client_user_get
    return await self.discord_request(
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/hata/discord/http/http_client.py", line 302, in discord_request
    raise DiscordException(response, response_data, data)
DiscordException Forbidden (403):
2021-12-17 10:47:17; GET https://dev.fosscord.com/api/users/@me

Same issue even if is_bot is True or False

Either your Token is bad, or your custom endpoint is incorrect. Dont you need the /v9/ part? :hmmm:

I'll double check rn

This issue will be pretty long 🔥

Traceback (most recent call last):
  File "/data/data/com.termux/files/home/hata-foss/main.py", line 7, in <module>
    from hata import Client
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/hata/__init__.py", line 110, in <module>
    from .discord import *
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/hata/discord/__init__.py", line 5, in <module>
    from .client import *
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/hata/discord/client/__init__.py", line 1, in <module>
    from .client import *
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/hata/discord/client/client.py", line 12901
    )
    ^
SyntaxError: f-string: invalid conversion character: expected 's', 'r', or 'a'

Same code as before but with the latest Hata version

Same code as before but with the latest Hata version

That is from github :KyaruPoint: And already fixed

But this one is not yet.

Ah okay then

I doubt hata will ever support Fosscord. It is not an intention either.

Closing the issue.