Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General cleanup of the library #3

Merged
merged 123 commits into from
Aug 2, 2024
Merged
Changes from 1 commit
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
b9f892b
Stuff
MCausc78 Jul 6, 2024
5dda0bd
Cache, Cache, and Cache!
MCausc78 Jul 6, 2024
c2a418d
Document State.settings add Client.settings
MCausc78 Jul 6, 2024
9806d67
More bloated docs
MCausc78 Jul 6, 2024
dc44fd9
Be consistent in routes.py
MCausc78 Jul 6, 2024
08f9df6
Correct DiscoveryTheme.variables doc
MCausc78 Jul 6, 2024
660e5e8
Add discovery test
MCausc78 Jul 6, 2024
984412c
Format discovery test
MCausc78 Jul 6, 2024
b9837f9
Use relative imports where possible
MCausc78 Jul 10, 2024
5dab858
Use relative imports in events.py and http.py
MCausc78 Jul 10, 2024
8661aae
Support `ServerMemberRemoveEvent`.reason
MCausc78 Jul 10, 2024
4974acd
General cleanup
MCausc78 Jul 11, 2024
ce87d58
Add TODO.md generator
MCausc78 Jul 11, 2024
3f4a8c6
Cleanup TODO generator
MCausc78 Jul 11, 2024
5fa7ae0
Try new TODO.md format
MCausc78 Jul 11, 2024
650fcc6
Another attempt at fixing bad TODO.md
MCausc78 Jul 11, 2024
bf5a1a1
Regenerate TODO.md
MCausc78 Jul 11, 2024
8a7afe1
And yet one failing attempt
MCausc78 Jul 11, 2024
d4eda52
Fix circular imports
MCausc78 Jul 11, 2024
be34c62
Refactor pyvolt a bit.
MCausc78 Jul 12, 2024
680ddeb
Fix user settings fetching. (Conflicts)
MCausc78 Jul 12, 2024
ba225f5
Change all :class:Error -> Error
MCausc78 Jul 13, 2024
5b0dca7
Remove core.ULID type
MCausc78 Jul 13, 2024
afdba3a
Remove ulid-py dependency 🎉
MCausc78 Jul 13, 2024
d97bdb1
Boost performance
MCausc78 Jul 13, 2024
f4b8052
Bring back performance (part 1)
MCausc78 Jul 13, 2024
821e206
Bring back performance (part 2)
MCausc78 Jul 13, 2024
d25aecc
Bring back performance (final part)
MCausc78 Jul 13, 2024
fc207e6
Add BaseEvent.cancel / BaseEvent.uncancel methods
MCausc78 Jul 13, 2024
8d5eac2
Keep TODO.md up to date
MCausc78 Jul 13, 2024
6db7c10
Use tables
MCausc78 Jul 13, 2024
2c6bf82
Add channels parsing benchmark
MCausc78 Jul 13, 2024
f744329
Fix circular imports usage (emojis moment)
MCausc78 Jul 14, 2024
6a3388f
Add DM/GDM channels parsing benchmark
MCausc78 Jul 14, 2024
d1198d3
Update typings and parsing
MCausc78 Jul 14, 2024
1934dc4
Update TODO list
MCausc78 Jul 14, 2024
53f0235
WIP: Convert Message -> MessageCreateEvent (short way)
MCausc78 Jul 15, 2024
04fdf54
Remove unused Server import in discovery.py and be consistent with he…
MCausc78 Jul 17, 2024
4f4acf1
Fix bugs in PR TODO.
MCausc78 Jul 17, 2024
194048d
Add get_emoji and get_member on Server
MCausc78 Jul 17, 2024
a40c2cf
Add Revolt#0000 sentinel
MCausc78 Jul 18, 2024
742ad6b
Refactor http.py docs.
MCausc78 Jul 19, 2024
02149ab
Refactor even more http.py docs.
MCausc78 Jul 20, 2024
3d4d8cb
Improve http.py docs, and check for system user in Message.get_author()
MCausc78 Jul 20, 2024
c6f5c2f
Partially finish up refactoring HTTPClient docs
MCausc78 Jul 20, 2024
51ab562
Rename `timed_out_until` parameter to `timeout`
MCausc78 Jul 20, 2024
65a4e7e
Add a few `fetch_` shortcut methods to Client.
MCausc78 Jul 20, 2024
035af17
Use `import typing` instead of `import typing as t`
MCausc78 Jul 20, 2024
22b76ce
Update TODO
MCausc78 Jul 20, 2024
66bd628
Add support for Android user settings
MCausc78 Jul 20, 2024
7dfcab8
Allow building Android user settings payload
MCausc78 Jul 20, 2024
b6260a9
WIP: Revite User Settings
MCausc78 Jul 20, 2024
bfee888
Add Revite user settings support.
MCausc78 Jul 20, 2024
4bdb0ac
Fix HTTPClient.edit_session not passing body
MCausc78 Jul 20, 2024
61aa520
WIP: Add `ReviteUserSettings.payload_for`
MCausc78 Jul 20, 2024
f4a2c5f
Fully support Revite User Settings
MCausc78 Jul 21, 2024
a6ea00c
Make system user always online
MCausc78 Jul 21, 2024
100d141
Rename `notification_servers` to `server_notifications`
MCausc78 Jul 21, 2024
9cfa4c7
Improve partial user settings updating
MCausc78 Jul 21, 2024
b3925cb
Fix UserSettingsUpdate removing android user settings
MCausc78 Jul 21, 2024
5ffed0d
Use ruff formatter
MCausc78 Jul 21, 2024
4e93a37
Add Ruff linting
MCausc78 Jul 22, 2024
b063180
Add pinned messages support
MCausc78 Jul 22, 2024
b90760c
Add RevoltConfig typings
MCausc78 Jul 22, 2024
1dffab2
Fully support pins
MCausc78 Jul 22, 2024
8e5e498
Fix throwing weird errors
MCausc78 Jul 22, 2024
4b8f918
Update message.py documentation
MCausc78 Jul 22, 2024
4ddd067
Properly resolve users in system events
MCausc78 Jul 22, 2024
d139979
Properly dispatch events
MCausc78 Jul 23, 2024
e83f0c2
Add more control over Revite user settings payloads
MCausc78 Jul 23, 2024
37ae9b4
Add `Theme.apply` method
MCausc78 Jul 23, 2024
3170651
Clear cached server emojis/members on ServerDelete
MCausc78 Jul 24, 2024
cc62051
Store authenticated user in cache upon joining server
MCausc78 Jul 24, 2024
cd16ccc
Set version to 0.7.0
MCausc78 Jul 24, 2024
8bab295
Temporary removal of docs/api
MCausc78 Jul 24, 2024
aedf0ac
Documentation for Client
MCausc78 Jul 24, 2024
4146d93
Document Shard
MCausc78 Jul 24, 2024
b151ed6
Document HTTPClient.request
MCausc78 Jul 24, 2024
423b745
Fix parsing error
MCausc78 Jul 24, 2024
17cc793
Regenerate TODO.md
MCausc78 Jul 24, 2024
58d06c2
Use `is` instead of `==` in `Shard.__init__`
MCausc78 Jul 24, 2024
b7cb6dd
Add copyright header
MCausc78 Jul 25, 2024
4c790de
Removal of `from . import core` imports
MCausc78 Jul 25, 2024
f6fc181
Add temporary event subscriptions
MCausc78 Jul 25, 2024
f2fadb4
Typo in EventSubscription**s**
MCausc78 Jul 25, 2024
289a9b0
Add 'pms_by_user' cache
MCausc78 Jul 26, 2024
fb92b13
Add 'Client.dm_channels'
MCausc78 Jul 26, 2024
cbd6d9f
Add examples
MCausc78 Jul 26, 2024
b203493
WIP: Cache contexts
MCausc78 Jul 26, 2024
994b194
Regenerate TODO.md
MCausc78 Jul 26, 2024
8fdb982
Add 'ProvideContextIn' variants
MCausc78 Jul 26, 2024
b640b5c
Add `User.default_avatar_url`
MCausc78 Jul 26, 2024
d4db56d
Add private channels cache
MCausc78 Jul 27, 2024
4e3abc4
Add `state.provide_cache_context_in`
MCausc78 Jul 27, 2024
9ce9400
Fix NameError in store_channel
MCausc78 Jul 27, 2024
a6c5f81
Fix circular imports in `Server.channels`
MCausc78 Jul 27, 2024
5458293
Rename `j` to `payload`
MCausc78 Jul 28, 2024
4dc1e1b
Don't compare all model fields anymore
MCausc78 Jul 28, 2024
9cda635
Add ``CDNClient.url_for`` and ``BaseEmoji.__str__``
MCausc78 Jul 28, 2024
97db4ab
Refactor http.py docs & handling.
MCausc78 Jul 28, 2024
f59b03b
Add CONTRIBUTING.md
MCausc78 Jul 29, 2024
5c63e35
Simplify resolve_emoji impl
MCausc78 Jul 29, 2024
e5113cf
Regenerate TODO
MCausc78 Jul 29, 2024
d6cb367
Add git hook
MCausc78 Jul 29, 2024
5743547
Format hook
MCausc78 Jul 29, 2024
371b70f
Delete hook as it bit of complex? (Or maybe skill issue)
MCausc78 Jul 29, 2024
bcd0712
Use :meth:`.bar` instead of :meth:`Foo.bar`
MCausc78 Jul 29, 2024
f8c7f8c
Clean up cache in ServerMemberRemoveEvent
MCausc78 Jul 29, 2024
5e4b4fb
Fix initiator_id
MCausc78 Jul 29, 2024
9994c41
Documentation for DMChannel
MCausc78 Jul 29, 2024
ad39fb4
Use .pop instead of del
MCausc78 Jul 29, 2024
5ef3a3d
Forgot in events.py and server.py
MCausc78 Jul 30, 2024
157ea5b
Allow use either `pyvolt.Client(token='token')` or `bot.run('token')`
MCausc78 Jul 30, 2024
95c3efb
Include pyvolt/pyvolt.raw/pyvolt.routes
MCausc78 Jul 31, 2024
052532c
Fix pip installation
MCausc78 Aug 1, 2024
ad9e347
Move all enums to enums
MCausc78 Aug 1, 2024
1272dec
Speed up flags
MCausc78 Aug 2, 2024
390b5dc
Fix typing error
MCausc78 Aug 2, 2024
1416367
Use ``FooFlags.__new__`` directly
MCausc78 Aug 2, 2024
bb709dc
Add support for ``AppleMusic`` embed specials
MCausc78 Aug 2, 2024
643d718
Add utility for getting user account token
MCausc78 Aug 2, 2024
af61ab7
Remove unused imports in examples/mfa.py
MCausc78 Aug 2, 2024
1e53731
Regenerate TODO.md
MCausc78 Aug 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Bring back performance (part 1)
MCausc78 committed Jul 13, 2024
commit f4b8052432001d24eaf299e38b3d3e0c947fc118
6 changes: 3 additions & 3 deletions bench/bench_user.py
Original file line number Diff line number Diff line change
@@ -50,9 +50,9 @@ def using_revoltpy():
def using_voltage():
return voltage.User(data=payload, cache=vpy_cache)

time_pyvolt = timeit.timeit(using_pyvolt, number=1_000_000)
time_revoltpy = timeit.timeit(using_revoltpy, number=1_000_000)
time_voltage = timeit.timeit(using_voltage, number=1_000_000)
time_pyvolt = timeit.timeit(using_pyvolt, number=100_000)
time_revoltpy = timeit.timeit(using_revoltpy, number=100_000)
time_voltage = timeit.timeit(using_voltage, number=100_000)

print(f"[User] Time using pyvolt ----: {time_pyvolt:.6f} seconds")
print(f"[User] Time using revolt.py -: {time_revoltpy:.6f} seconds")
32 changes: 17 additions & 15 deletions pyvolt/parser.py
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@
import logging
import typing as t

from . import cdn, core, discovery
from . import core, discovery
from .auth import (
PartialAccount,
MFATicket,
@@ -19,6 +19,11 @@
LoginResult,
)
from .bot import BotFlags, Bot, PublicBot
from .cdn import (
AssetMetadataType,
AssetMetadata,
StatelessAsset,
)
from .channel import (
PartialChannel,
SavedMessagesChannel,
@@ -182,25 +187,22 @@ def __init__(self, state: State) -> None:

# basic start

def parse_asset_metadata(self, d: raw.Metadata) -> cdn.AssetMetadata:
return cdn.AssetMetadata(
type=cdn.AssetMetadataType(d["type"]),
def parse_asset_metadata(self, d: raw.Metadata) -> AssetMetadata:
return AssetMetadata(
type=AssetMetadataType(d["type"]),
width=d.get("width"),
height=d.get("height"),
)

def parse_asset(self, d: raw.File) -> cdn.StatelessAsset:
deleted = d.get("deleted")
reported = d.get("reported")

return cdn.StatelessAsset(
def parse_asset(self, d: raw.File) -> StatelessAsset:
return StatelessAsset(
id=d["_id"],
filename=d["filename"],
metadata=self.parse_asset_metadata(d["metadata"]),
content_type=d["content_type"],
size=d["size"],
deleted=deleted or False,
reported=reported or False,
deleted=d.get("deleted", False),
reported=d.get("reported", False),
message_id=d.get("message_id"),
user_id=d.get("user_id"),
server_id=d.get("server_id"),
@@ -1030,8 +1032,8 @@ def parse_mfa_response_login(
return MFARequired(
ticket=d["ticket"],
allowed_methods=[MFAMethod(m) for m in d["allowed_methods"]],
internal_friendly_name=friendly_name,
state=self.state,
internal_friendly_name=friendly_name,
)

def parse_mfa_ticket(self, d: raw.a.MFATicket) -> MFATicket:
@@ -1170,11 +1172,11 @@ def parse_response_webhook(self, d: raw.ResponseWebhook) -> Webhook:
id=webhook_id,
name=d["name"],
internal_avatar=(
cdn.StatelessAsset(
StatelessAsset(
id=avatar,
filename="",
metadata=cdn.AssetMetadata(
type=cdn.AssetMetadataType.IMAGE,
metadata=AssetMetadata(
type=AssetMetadataType.IMAGE,
width=None,
height=None,
),