Coder Social home page Coder Social logo

fuyukai / curious Goto Github PK

View Code? Open in Web Editor NEW
21.0 21.0 7.0 1.78 MB

A curio/trio-based library for the Discord API

Home Page: https://curious.readthedocs.io/en/latest/

License: GNU Lesser General Public License v3.0

Python 100.00%
curio discord discord-api trio

curious's People

Contributors

brakhane avatar emzi0767 avatar fuyukai avatar tildebeta avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

curious's Issues

Distributed Roadmap

I want to add the ability to split a bot up into several co-ordinating parts.

Essential processes:

  • Add ContextVar support to curio (see: dabeaz/curio#254)

    • Trio already has this (thanks to yours truly), so that's not an issue.
  • Make dataclasses use a ContextVar for the bot object.

    • This makes them pickable, which means they can uploaded somewhere or sent over a network.

Curious core changes:

  • Change the eventbus API significantly.
    • To be decided on.

Then, a distributed wrapper will be made.

Add set protection

Adding setting protection (i.e. making dataclasses read-only for user code) is relatively trivial with a 567 flag and some decorators.

Current 0.7 branch crashes on WEBHOOK_UPDATE event

0.7.9 worked fine, the current 0.7 branch seems to crash when WEBHOOKS_UPDATE is received

2019-01-24 03:54:37,805 ERROR curious.client: Error decoding event WEBHOOKS_UPDATE with data {'guild_id': '312742719237914624', 'channel_id': '537808121335250955'}!
Traceback (most recent call last):
  File "/home/dennis/.local/share/virtualenvs/orisa-C9I4W0oe/lib/python3.7/site-packages/curious/core/client.py", line 600, in handle_dispatches
    await self.events.fire_event(item, gateway=ctx.gateway, client=self)
  File "/home/dennis/.local/share/virtualenvs/orisa-C9I4W0oe/lib/python3.7/site-packages/curious/core/event.py", line 278, in fire_event
    for handler in self.event_listeners.getall(event_name, []):
  File "multidict/_multidict.pyx", line 39, in multidict._multidict._Base.getall
TypeError: MultiDict keys should be either str or subclasses of str
2019-01-24 03:54:37,808 ERROR curious.events: Unhandled exception in handle_dispatches!
Traceback (most recent call last):
  File "/home/dennis/.local/share/virtualenvs/orisa-C9I4W0oe/lib/python3.7/site-packages/curious/core/event.py", line 159, in _safety_wrapper
    await func(*args, **kwargs)
  File "/home/dennis/.local/share/virtualenvs/orisa-C9I4W0oe/lib/python3.7/site-packages/curious/core/client.py", line 600, in handle_dispatches
    await self.events.fire_event(item, gateway=ctx.gateway, client=self)
  File "/home/dennis/.local/share/virtualenvs/orisa-C9I4W0oe/lib/python3.7/site-packages/curious/core/event.py", line 278, in fire_event
    for handler in self.event_listeners.getall(event_name, []):
  File "multidict/_multidict.pyx", line 39, in multidict._multidict._Base.getall
TypeError: MultiDict keys should be either str or subclasses of str
2019-01-24 03:54:37,912 INFO  curious.gateway:shard-0: The websocket has closed

After that, no discord events are handled, so the bot is basically offline

message_update events disappear in private channels that are not newly created

This time, no PR, as I'm not yet sure what the correct way to handle it is.

handle_message_update in State crashes when a private message is updated, because make_message tries to check message.channel.type. However, message.channel can return None if the channel is a private channel that we haven't seen yet (because it was created before a restart of the Bot, for example)

I think message.channel should, if it can't find a channel in the cache, call the Discord channel/{id} endpoint to get the necessary information

This is a pretty serious bug, BTW, because once it occurs, the bot basically stops handling any events and has to be restarted

joined_at is randomly None

Noted in my bot today:

Traceback (most recent call last):
  File "/home/eyes/.local/share/virtualenvs/Jokusoramame-25ROq1gv/lib/python3.6/site-packages/curious/commands/context.py", line 278, in invoke
    return await matched_command(self, *converted_args, **converted_kwargs)
  File "/home/eyes/bots/Jokusoramame/jokusoramame/plugins/autoprune.py", line 177, in report
    activity_data = await self.get_member_activity_data(ctx.guild)
  File "/home/eyes/bots/Jokusoramame/jokusoramame/plugins/autoprune.py", line 137, in get_member_activity_data
    if (now - member.joined_at).days < 3:
TypeError: unsupported operand type(s) for -: 'datetime.datetime' and 'NoneType'

Maybe it's a bug in the code, in which case this is here so I'll remember it.

If not, considering making some sort of "consistency checker" background task in 0.8 that when it finds something that shouldn't happen (member having None joined_at, no owner_id, etc) just requests a rechunk (or downloads the data over HTTP).

Request multiple guilds in chunking

API docs are bad and don't document that you can send multiple guild_ids in a chunk request, which would prevent you from ever getting a 4008 due to too many chunking packets.

Would need to rewrite chunk handling so that it batches up guilds to send.

"can't release a Lock you don't own" in httpclient when using trio

httpclient works fine with curio, when switching to trio I seem to get this error from time to time; haven't analysed it yet:

    File "/home/dennis/curious/curious/dataclasses/user.py", line 215, in send
      message = await channel.messages.send(content, *args, **kwargs)
    File "/home/dennis/curious/curious/dataclasses/channel.py", line 292, in send
      tts=tts, embed=embed)
    File "/home/dennis/curious/curious/core/httpclient.py", line 684, in send_message
      data = await self.post(url, "messages:{}".format(channel_id), json=payload)
    File "/home/dennis/curious/curious/core/httpclient.py", line 487, in post
      return await self.request(("POST", bucket), method="POST", path=url, *args, **kwargs)
    File "/home/dennis/curious/curious/core/httpclient.py", line 464, in request
      await lock.release()
    File "/home/dennis/.local/share/virtualenvs/orisa-C9I4W0oe/lib/python3.6/site-packages/multio/__init__.py", line 148, in release
      return await _maybe_await(self.lock.release(*args, **kwargs))
    File "/home/dennis/.local/share/virtualenvs/orisa-C9I4W0oe/lib/python3.6/site-packages/trio/_core/_ki.py", line 164, in wrapper
      return fn(*args, **kwargs)
    File "/home/dennis/.local/share/virtualenvs/orisa-C9I4W0oe/lib/python3.6/site-packages/trio/_sync.py", line 570, in release
      raise RuntimeError("can't release a Lock you don't own")
  RuntimeError: can't release a Lock you don't own

0.7.8 release?

My bot currently requires the checked out 0.7 branch because it runs into the 0.7.7 bugs.

It would be nice to have a 0.7.8 with the bugfixes to depend on.

TODO List

  • Gateway events

    • Reactions
    • Emojis
    • Guild update
  • Channel editing

  • Guild editing

  • Role editing

Release 0.7.9

0.7.8 was released in May, since then, quite a few bugs have been fixed and features added; my bot cannot run without them.

The current 0.7 seems to be quite stable now, and a 0.7.9 would remove my dependency on the git version.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.