Skip to content

Commit 93551bf

Browse files
authored
remove_after, refactoring, documentation (#168)
* remove_after on guild, refactoring, documentation * remove_after on xMESSAGE & optimizations * Documentation * _update_state method, refactoring of auto-removal * Bug Fixes * Remove useless code * Fixed DirectMESSAGE counter
1 parent 95074f4 commit 93551bf

File tree

20 files changed

+556
-387
lines changed

20 files changed

+556
-387
lines changed

Examples/Dynamic Modification/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ async def user_task():
4646
await asyncio.sleep(10)
4747
fw.trace("Updating the TextMESSAGE object")
4848
# Update the object
49-
await text_msg.update(data="Updated Data", end_period=60)
49+
await text_msg.update(data="Updated Data", end_period=timedelta(seconds=60))
5050

5151
fw.trace("Now shilling 'Updated Data' with period of 60 seconds")
5252
#########################################################################

Examples/Message Types/DirectMESSAGE/main_send_string.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
# the previous message and then send a new one
2424
start_in=timedelta(seconds=0) # Start sending now (True) or wait until period
2525
),
26-
framework.TextMESSAGE(start_period=5, end_period=10, data="Second Message", channels=[12345], mode="send", start_in=timedelta(seconds=0))
26+
framework.TextMESSAGE(start_period=5, end_period=timedelta(10), data="Second Message", channels=[12345], mode="send", start_in=timedelta(seconds=0))
2727
],
2828
logging=True ## Generate file log of sent messages (and failed attempts) for this user
2929
)

Examples/Message Types/TextMESSAGE/main_send_string.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
# the previous message and then send a new one
2525
start_in=timedelta(seconds=0) # Start sending now (True) or wait until period
2626
),
27-
framework.TextMESSAGE(start_period=5, end_period=10, data="Second Message", channels=[12345], mode="send", start_in=timedelta(seconds=0))
27+
framework.TextMESSAGE(start_period=5, end_period=timedelta(10), data="Second Message", channels=[12345], mode="send", start_in=timedelta(seconds=0))
2828
],
2929
logging=True ## Generate file log of sent messages (and failed attempts) for this server
3030
)

docs/source/changelog.rst

Lines changed: 57 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,71 @@
1+
========================
12
Changelog
23
========================
4+
.. |BREAK_CH| replace:: **[Breaking change]**
5+
6+
.. |POTENT_BREAK_CH| replace:: **[Potentially breaking change]**
7+
8+
------------------------
9+
Info
10+
------------------------
11+
312
.. seealso::
4-
`Releases <https://github.com/davidhozic/discord-advertisement-framework/releases>`_
13+
`Releases <https://github.com/davidhozic/discord-advertisement-framework/releases>`_
514

615
.. note::
716
The library first started as a single file script that I didn't make versions of.
817
When I decided to turn it into a library, I've set the version number based on the amount of commits I have made since the start.
918

10-
v2.1
19+
20+
Glossary
21+
======================
22+
.. glossary::
23+
24+
|BREAK_CH|
25+
Means that the change will break functionality from previous version.
26+
27+
1128
----------------------
12-
- Proxy support
13-
- Removed discord.EmbedField class, it is now replaced with discord.EmbedField
14-
- ``timedelta`` object on ``start_period/end_period`` parameters
15-
- Replaced ``start_now`` with ``start_in`` parameter, deprecated use of bool value
16-
- :class:`framework.TextMESSAGE` and :class:`framework.VoiceMESSAGE` now check if the given channels are actually inside the guild
17-
- Optional dependencies `voice` and `proxy` - to install use ``pip install discord-advert-framework[voice]`` and ``pip install discord-advert-framework[proxy]``
18-
- Time slippage correction:
29+
Releases
30+
----------------------
31+
32+
v2.1
33+
===========
34+
:``remove_after`` parameter:
35+
Classes: :class:`framework.guild.GUILD`, :class:`framework.guild.USER`, :class:`framework.message.TextMESSAGE`, :class:`framework.message.VoiceMESSAGE`, :class:`framework.message.DirectMESSAGE`
36+
37+
now support the remove_after parameter which will remove the object from the shilling list when conditions met.
38+
39+
40+
:Proxies:
41+
Added support for using proxies.
42+
To use a proxy pass the :func:`framework.run` function with a ``proxy`` parameter
43+
:discord.EmbedField:
44+
|BREAK_CH| Replaced framework.EmbedFIELD with discord.EmbedField.
45+
:timedelta:
46+
start_period and end_period now support ``timedelta`` object to specify the send period.
47+
Use of ``int`` is deprecated
48+
49+
|POTENT_BREAK_CH| Replaced ``start_now`` with ``start_in`` parameter, deprecated use of bool value.
50+
51+
:Channel checking:
52+
:class:`framework.TextMESSAGE` and :class:`framework.VoiceMESSAGE` now check if the given channels are actually inside the guild
53+
54+
:Optionals:
55+
|POTENT_BREAK_CH| Made some functionality optional: ``voice``, ``proxy`` and ``sql`` - to install use ``pip install discord-advert-framework[dependency here]``
1956

20-
.. figure:: images/changelog_2_1_slippage_fix.png
57+
:Bug fixes:
58+
Time slippage correction:
59+
This occurred if too many messages were ready at once, which resulted in discord's rate limit,
60+
causing a permanent slip.
2161

22-
Time slippage correction
62+
.. figure:: images/changelog_2_1_slippage_fix.png
63+
64+
Time slippage correction
2365

24-
2566

2667
v2.0
27-
----------------------
68+
===========
2869
- New cool looking web documentation (the one you're reading now)
2970
- Added volume parameter to :class:`framework.VoiceMESSAGE`
3071
- Changed ``channel_ids`` to ``channels`` for :class:`framework.VoiceMESSAGE` and :class:`framework.TextMESSAGE`. It can now also accept discord.<Type>Channel objects.
@@ -35,20 +76,20 @@ v2.0
3576
- Bug fixes and other small improvements.
3677

3778
v1.9.0
38-
----------------------
79+
===========
3980
- Added support for logging into a SQL database (MS SQL Server only). See :ref:`relational database log (SQL)`.
4081
- :func:`framework.run` function now accepts discord.Intents.
4182
- :func:`framework.add_object` and :func:`framework.remove_object` functions created to allow for dynamic modification of the shilling list.
4283
- Other small improvements.
4384

4485
v1.8.1
45-
----------------------
86+
===========
4687
- JSON file logging.
4788
- Automatic channel removal if channel get's deleted and message removal if all channels are removed.
4889
- Improved debug messages.
4990

5091
v1.7.9
51-
----------------------
92+
===========
5293
- :class:`framework.DirectMESSAGE` and :class:`framework.USER` classes created for direct messaging.
5394

5495

docs/source/classes.rst

Lines changed: 18 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ GUILD
1616

1717
.. autoproperty:: snowflake
1818

19+
.. autoproperty:: created_at
20+
1921
USER
2022
=====================
2123
.. autoclass:: framework.guild.USER
@@ -25,6 +27,7 @@ USER
2527

2628
.. autoproperty:: snowflake
2729

30+
.. autoproperty:: created_at
2831

2932
-----------------------------
3033
Messages
@@ -35,22 +38,22 @@ TextMESSAGE
3538
.. autoclass:: framework.message.TextMESSAGE
3639
:members:
3740

38-
.. autoproperty:: deleted
41+
.. autoproperty:: created_at
3942

4043
VoiceMESSAGE
4144
=====================
4245
.. autoclass:: framework.message.VoiceMESSAGE
4346
:members:
4447

45-
.. autoproperty:: deleted
48+
.. autoproperty:: created_at
49+
4650

4751
DirectMESSAGE
4852
=====================
4953
.. autoclass:: framework.message.DirectMESSAGE
5054
:members:
5155

52-
.. autoproperty:: deleted
53-
56+
.. autoproperty:: created_at
5457

5558

5659
-----------------------------
@@ -152,77 +155,57 @@ Error codes
152155

153156
.. glossary::
154157

155-
DAF_GUILD_ALREADY_ADDED:
156-
Value: 0
157-
158-
Info: Guild with specified snowflake is already added.
159-
160-
DAF_GUILD_ID_REQUIRED:
158+
DAF_SNOWFLAKE_NOT_FOUND:
161159
Value: 1
162160

163-
Info: Guild ID is required but was not passed.
164-
165-
DAF_GUILD_ID_NOT_FOUND:
166-
Value: 2
167-
168161
Info: Guild with specified snowflake was not found (or user).
169162

170163
DAF_USER_CREATE_DM:
171-
Value: 3
164+
Value: 2
172165

173166
Info: Was unable to create DM with user (probably user not found).
174167

175168
DAF_YOUTUBE_STREAM_ERROR:
176-
Value: 5
169+
Value: 3
177170

178171
Info: The given youtube link could not be streamed (AUDIO, VoiceMESSAGE).
179172

180173
DAF_FILE_NOT_FOUND:
181-
Value: 6
174+
Value: 4
182175

183176
Info: The given file was not found.
184177

185-
DAF_MISSING_PARAMETER:
186-
Value: 7
187-
188-
Info: The parameter(s) is(are) missing.
189-
190-
DAF_CHANNEL_GUILD_MISMATCH_ERROR:
191-
Value: 8
192-
193-
Info: The channel with given ID does not belong into this guild but is part of a different guild.
194-
195178
DAF_SQL_CREATE_TABLES_ERROR:
196-
Value: 9
179+
Value: 5
197180

198181
Info: Unable to create all the tables.
199182

200183
DAF_SQL_LOOKUPTABLE_NOT_FOUND:
201-
Value: 10
184+
Value: 6
202185

203186
Info: The lookup table was not found.
204187

205188
DAF_SQL_BEGIN_ENGINE_ERROR:
206-
Value: 11
189+
Value: 7
207190

208191
Info: Unable to start engine.
209192

210193
DAF_SQL_CR_LT_VALUES_ERROR:
211-
Value: 12
194+
Value: 8
212195

213196
Info: Unable to create lookuptables' rows.
214197

215198
DAF_SQL_CREATE_DT_ERROR:
216-
Value: 13
199+
Value: 9
217200

218201
Info: Unable to create SQL data types.
219202

220203
DAF_SQL_CREATE_VPF_ERROR:
221-
Value: 14
204+
Value: 10
222205

223206
Info: Unable to create views, procedures and functions.
224207

225208
DAF_SQL_CURSOR_CONN_ERROR:
226-
Value: 15
209+
Value: 11
227210

228211
Info: Unable to connect the cursor.

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060

6161

6262
# Autodoc
63-
autodoc_typehints = "both"
63+
autodoc_typehints = "signature"
6464
autodoc_typehints_format = "short"
6565

6666

0 commit comments

Comments
 (0)