Skip to content

Commit ec0b8db

Browse files
authored
Merge pull request #463 from davidhozic/develop
v3.0.x
2 parents 3f7d303 + 8f6b11b commit ec0b8db

File tree

129 files changed

+5583
-3392
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+5583
-3392
lines changed

.github/workflows/codeql.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636

3737
steps:
3838
- name: Checkout repository
39-
uses: actions/checkout@v3
39+
uses: actions/checkout@v4
4040

4141
# Initializes the CodeQL tools for scanning.
4242
- name: Initialize CodeQL

.github/workflows/python-publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- name: Checkout code
15-
uses: actions/checkout@v3
15+
uses: actions/checkout@v4
1616

1717
- name: Set up Python
1818
uses: actions/setup-python@v4

.github/workflows/python-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
matrix:
2121
python-version: ["3.8", "3.11"]
2222
steps:
23-
- uses: actions/checkout@v3
23+
- uses: actions/checkout@v4
2424
- name: Set up Python ${{ matrix.python-version }}
2525
uses: actions/setup-python@v4
2626
with:

Patches/2_http.patch

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/src/_discord/http.py b/src/_discord/http.py
2-
index 79455a0..4c16c2b 100644
2+
index 9eb7837..9ad7137 100644
33
--- a/src/_discord/http.py
44
+++ b/src/_discord/http.py
55
@@ -25,6 +25,8 @@ DEALINGS IN THE SOFTWARE.
@@ -11,7 +11,7 @@ index 79455a0..4c16c2b 100644
1111
import asyncio
1212
import logging
1313
import sys
14-
@@ -100,6 +102,22 @@ async def json_or_text(response: aiohttp.ClientResponse) -> dict[str, Any] | str
14+
@@ -101,6 +103,22 @@ async def json_or_text(response: aiohttp.ClientResponse) -> dict[str, Any] | str
1515
return text
1616

1717

@@ -34,7 +34,7 @@ index 79455a0..4c16c2b 100644
3434
class Route:
3535
def __init__(self, method: str, path: str, **parameters: Any) -> None:
3636
self.path: str = path
37-
@@ -166,7 +184,7 @@ class HTTPClient:
37+
@@ -167,7 +185,7 @@ class HTTPClient:
3838
proxy: str | None = None,
3939
proxy_auth: aiohttp.BasicAuth | None = None,
4040
loop: asyncio.AbstractEventLoop | None = None,
@@ -43,7 +43,7 @@ index 79455a0..4c16c2b 100644
4343
) -> None:
4444
self.loop: asyncio.AbstractEventLoop = (
4545
asyncio.get_event_loop() if loop is None else loop
46-
@@ -177,7 +195,7 @@ class HTTPClient:
46+
@@ -178,7 +196,7 @@ class HTTPClient:
4747
self._global_over: asyncio.Event = asyncio.Event()
4848
self._global_over.set()
4949
self.token: str | None = None
@@ -52,15 +52,15 @@ index 79455a0..4c16c2b 100644
5252
self.proxy: str | None = proxy
5353
self.proxy_auth: aiohttp.BasicAuth | None = proxy_auth
5454
self.use_clock: bool = not unsync_clock
55-
@@ -188,6 +206,7 @@ class HTTPClient:
55+
@@ -189,6 +207,7 @@ class HTTPClient:
5656
self.user_agent: str = user_agent.format(
5757
__version__, sys.version_info, aiohttp.__version__
5858
)
5959
+ self.user_limit = UserLimit(self.loop)
6060

6161
def recreate(self) -> None:
6262
if self.__session.closed:
63-
@@ -234,8 +253,23 @@ class HTTPClient:
63+
@@ -235,8 +254,23 @@ class HTTPClient:
6464
"User-Agent": self.user_agent,
6565
}
6666

@@ -85,7 +85,7 @@ index 79455a0..4c16c2b 100644
8585
# some checking if it's a JSON request
8686
if "json" in kwargs:
8787
headers["Content-Type"] = "application/json"
88-
@@ -279,6 +313,11 @@ class HTTPClient:
88+
@@ -280,6 +314,11 @@ class HTTPClient:
8989
kwargs["data"] = form_data
9090

9191
try:
@@ -97,16 +97,25 @@ index 79455a0..4c16c2b 100644
9797
async with self.__session.request(
9898
method, url, **kwargs
9999
) as response:
100-
@@ -316,7 +355,7 @@ class HTTPClient:
100+
@@ -319,7 +358,8 @@ class HTTPClient:
101101

102102
# we are being rate limited
103103
if response.status == 429:
104104
- if not response.headers.get("Via") or isinstance(data, str):
105-
+ if not response.headers.get("Via") or isinstance(data, str) or ("code" in data and data["code"] == 20016):
105+
+ retry_after: float = data.get("retry_after", 0)
106+
+ if not response.headers.get("Via") or isinstance(data, str) or ("code" in data and data["code"] == 20016) or retry_after > 30:
106107
# Banned by Cloudflare more than likely.
107108
raise HTTPException(response, data)
108109

109-
@@ -401,22 +440,28 @@ class HTTPClient:
110+
@@ -329,7 +369,6 @@ class HTTPClient:
111+
)
112+
113+
# sleep a bit
114+
- retry_after: float = data["retry_after"]
115+
_log.warning(fmt, retry_after, bucket)
116+
117+
# check if it's a global rate limit
118+
@@ -406,22 +445,28 @@ class HTTPClient:
110119

111120
# login management
112121

Patches/3_gateway.patch

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
diff --git a/src/_discord/gateway.py b/src/_discord/gateway.py
2-
index e3e7d1b..e847fc6 100644
2+
index bd13f22..0040f3a 100644
33
--- a/src/_discord/gateway.py
44
+++ b/src/_discord/gateway.py
5-
@@ -302,6 +302,7 @@ class DiscordWebSocket:
5+
@@ -304,6 +304,7 @@ class DiscordWebSocket:
66
self._buffer = bytearray()
77
self._close_code = None
88
self._rate_limiter = GatewayRatelimiter()
99
+ self.bot: bool = True
1010

1111
@property
1212
def open(self):
13-
@@ -338,6 +339,7 @@ class DiscordWebSocket:
13+
@@ -340,6 +341,7 @@ class DiscordWebSocket:
1414

1515
# dynamically add attributes needed
1616
ws.token = client.http.token
1717
+ ws.bot = client.http.bot_token
1818
ws._connection = client._connection
1919
ws._discord_parsers = client._connection.parsers
2020
ws._dispatch = client.dispatch
21-
@@ -398,23 +400,41 @@ class DiscordWebSocket:
21+
@@ -400,23 +402,40 @@ class DiscordWebSocket:
2222

2323
async def identify(self):
2424
"""Sends the IDENTIFY packet."""
@@ -68,7 +68,6 @@ index e3e7d1b..e847fc6 100644
6868
+ "browser_user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)",
6969
+ "browser_version":"109.0.0.0",
7070
+ },
71-
+ "presence": {"status":"online","since":0,"activities":[],"afk": False},
7271
+ "compress": True
7372
+ }
7473
+ }

Patches/6_embeds.patch

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,22 @@
11
diff --git a/src/_discord/embeds.py b/src/_discord/embeds.py
2-
index 39dc855..83c986b 100644
2+
index 44d51e8..7633330 100644
33
--- a/src/_discord/embeds.py
44
+++ b/src/_discord/embeds.py
5-
@@ -28,6 +28,8 @@ from __future__ import annotations
5+
@@ -28,6 +28,9 @@ from __future__ import annotations
66
import datetime
7-
from typing import TYPE_CHECKING, Any, Final, Mapping, Protocol, TypeVar, Union
7+
from typing import TYPE_CHECKING, Any, Mapping, TypeVar
88

99
+from _discord.types.embed import EmbedType
10+
+
1011
+
1112
from . import utils
1213
from .colour import Colour
1314

14-
@@ -69,13 +71,11 @@ class EmbedProxy:
15-
16-
17-
E = TypeVar("E", bound="Embed")
18-
+T = TypeVar("T")
19-
+MaybeEmpty = Union[T, _EmptyEmbed]
15+
@@ -45,7 +48,6 @@ E = TypeVar("E", bound="Embed")
2016

2117
if TYPE_CHECKING:
2218
from _discord.types.embed import Embed as EmbedData
2319
- from _discord.types.embed import EmbedType
24-
-
25-
- T = TypeVar("T")
26-
- MaybeEmpty = Union[T, _EmptyEmbed]
2720

28-
class _EmbedFooterProxy(Protocol):
29-
text: MaybeEmpty[str]
21+
22+
class EmbedAuthor:

docs/source/changelog.rst

Lines changed: 86 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ Changelog
55

66
.. |POTENT_BREAK_CH| replace:: **[Potentially breaking change]**
77

8+
.. |UNRELEASED| replace:: **[Not yet released]**
9+
810
------------------------
911
Info
1012
------------------------
@@ -28,9 +30,91 @@ Glossary
2830
The change could break functionality from previous versions but only if it
2931
was used in a certain way.
3032

31-
----------------------
33+
|UNRELEASED|
34+
Documented changes are not yet available to use.
35+
36+
---------------------
3237
Releases
33-
----------------------
38+
---------------------
39+
40+
v3.0.0
41+
====================
42+
- SQL analytics:
43+
44+
- Counts now have better error reporting when an invalid value was passed.
45+
46+
- GUI:
47+
48+
- Higher refresh rate due to threading redesign - instead of calling Tkinter's root.update inside an asyncio task,
49+
the root.mainroot is called directly, while the asyncio event loop is running inside another thread.
50+
- The GUI will not block the asyncio tasks (explained in previous bullet).
51+
- When saving a new object definition, if the type of a parameter is literal, the value will be pre-checked inside
52+
the GUI and an exception will be raised if a valid value is not given.
53+
- Properties that start with ``_`` will no longer be displayed when viewing live structured objects.
54+
- Toast notifications for :func:`~daf.logging.tracing.trace`.
55+
- Parameter validation for literals, enums and bool.
56+
- Copy / Paste globally for both drop-down menus and list menus.
57+
58+
- Core:
59+
60+
- New events system and module :ref:`Event reference`
61+
- Updated PyCord API wrapper to 2.5.0 RC5
62+
- New property :py:attr:`daf.client.ACCOUNT.removed_servers` for tracking removed servers.
63+
- New property :py:attr:`daf.guild.GUILD.removed_messages` :py:attr:`daf.guild.USER.removed_messages`
64+
for tracking removed messages.
65+
- New parameter ``removal_buffer_length`` to :class:`daf.client.ACCOUNT` for setting maximum amount of
66+
of servers to keep in the :py:attr:`daf.client.ACCOUNT.removed_servers` buffer.
67+
- New parameter ``removal_buffer_length`` to :class:`daf.guild.GUILD` and :class:`daf.guild.USER`
68+
for setting maximum amount of messages to keep in the :py:attr:`daf.guild.GUILD.removed_messages`
69+
/ :py:attr:`daf.guild.USER.removed_messages` buffer.
70+
71+
- Event loop based API - All API methods that get called now submit an event in the event loop, which causes
72+
the API call to happen asynchronously unless awaited with ``await`` keyword. This also makes DAF
73+
much more efficient.
74+
75+
- Remote:
76+
77+
- Persistent WebSocket connection for receiving events from the core server
78+
(eg. :func:`~daf.logging.tracing.trace()` events).
79+
80+
81+
- Removed ``remaining_before_removal`` property from all message classes.
82+
- Added ``remove_after`` property to :class:`~daf.guild.GUILD`, :class:`~daf.guild.USER`,
83+
:class:`~daf.message.TextMESSAGE`, :class:`~daf.message.VoiceMESSAGE` and :class:`~daf.message.DirectMESSAGE`.
84+
85+
86+
v2.10.4
87+
======================
88+
- Fixed prematurely exiting when waiting for captcha to be completed by user.
89+
90+
91+
v2.10.3
92+
======================
93+
- Fixed Chrome driver not working with newer Chrome versions (115+).
94+
- Fetching invite links better bypass.
95+
- Remove invalid presence
96+
- Fixed ``remaining_before_removal`` properties
97+
- Fixed SQL queries not working on direct messages.
98+
99+
100+
v2.10.2
101+
=======================
102+
- Fixed *Unclosed client session* warning when removing an user account.
103+
- Fixed documentation of :func:`daf.core.shutdown` - removed information about non existent parameters.
104+
- Selenium better waiting avoidance
105+
- Fixed ACCOUNT not being removed from the list if the update failed and the re-login after update failed.
106+
107+
108+
v2.10.1
109+
=======================
110+
- Fixed files in DirectMESSAGE.
111+
- Fixed file paths over remote not having the full patch when returned back.
112+
- Fixed files not having full path in the logs.
113+
- Added :py:attr:`daf.dtypes.FILE.fullpath` to support the previous fix.
114+
- Fixed exception when adding messages inside AutoGUILD, when one of the cached guilds fails initialization.
115+
- Fixed serialization for :class:`discord.VoiceChannel`, which included slowmode_delay,
116+
even though the attribute doesn't exist in the VoiceChannel.
117+
34118

35119
v2.10
36120
====================

docs/source/conf.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030
# -- General configuration ---------------------------------------------------
3131
root_doc = 'index'
3232

33+
rst_prolog = """
34+
.. |ASYNC_API| replace:: This is an asynchronous API operation. When returning from this function, the action is not immediately executed.
35+
"""
36+
3337
numfig = True
3438
# Add any Sphinx extension module names here, as strings. They can be
3539
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom

docs/source/scripts/generate_autodoc.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
)
8888

8989
for category, items in titles.items():
90+
export_enum_items = "" # All enum classes string
9091
export_c_items = "" # All classes string
9192
export_f_items = "" # All functions string
9293
for item, manual, path in items:
@@ -131,7 +132,7 @@
131132
elif inspect.isclass(item):
132133
# Fill properties
133134
if isinstance(item, EnumMeta):
134-
export_c_items += AUTO_ENUM_TEMPLATE.format(object_name=object_name, object_path=object_path) + "\n"
135+
export_enum_items += AUTO_ENUM_TEMPLATE.format(object_name=object_name, object_path=object_path) + "\n"
135136
else:
136137
export_c_items += AUTO_CLASS_TEMPLATE.format(object_name=object_name, object_path=object_path) + "\n"
137138

@@ -142,6 +143,7 @@
142143
# file_name = <...>/<output>/<Program/HTTP>/<category>.rst
143144
with open(file_name, "w", encoding="utf-8") as writer:
144145
writer.write(CATEGORY_TEMPLATE.format(category_name=category))
146+
writer.write(export_enum_items)
145147
writer.write(export_f_items)
146148
writer.write(export_c_items)
147149

docs/thesis/conf.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,14 @@
173173
\newpage
174174
}
175175
''',
176-
"maketitle": r"""
177-
\pagenumbering{roman}
178-
\includepdf{NaslovnaStranDiplome.pdf}
179-
\includepdf{IzjavaOAvtorstvu.pdf}
180-
\includepdf{NaslovnaStranDiplome.pdf}
176+
"maketitle": rf"""
177+
\includepdf{{NaslovnaStranDiplome.pdf}}
181178
\blankpage
179+
\includepdf{{IzjavaOAvtorstvu.pdf}}
180+
\blankpage
181+
{latex_title_page}
182+
\blankpage
183+
\pagenumbering{{roman}}
182184
""",
183185
"printindex": ''
184186
}

0 commit comments

Comments
 (0)