curious
is a Python 3.11+ library to interact with the
Discord API.
Not currently documented. Only uses trio. Etc.
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
curious
is a Python 3.11+ library to interact with the
Discord API.
Not currently documented. Only uses trio. Etc.
Gateway events
Channel editing
Guild editing
Role editing
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)
Make dataclasses use a ContextVar for the bot object.
Curious core changes:
Then, a distributed wrapper will be made.
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
The unwrapping in 0.7.0 is kind of bootleg.
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
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.
Stuff like removing the client, making plugins more featureful, etc.
Adding setting protection (i.e. making dataclasses read-only for user code) is relatively trivial with a 567 flag and some decorators.
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).
ContextVar support can be more useful than passing a context around everywhere.
Blocked by python-trio/trio#420 and curio support.
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.
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
Hi, My bot depends upon the ability to move a user between voice channels. Would it be possible to implement this feature from the API? I love your library +1
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.
Some examples:
Emoji.role_ids
Member.role_ids
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.