@@ -106,7 +106,7 @@ We will not cover :class:`daf.guild.USER` separately as the definition process i
106106the same.
107107We will also not cover :class: `daf.guild.AutoGUILD ` here, as it is covered in :ref: `Automatic Generation (core) `.
108108
109- Let's define our :class: `daf.guild.GUILD ` object now. Its most important parameters are:
109+ Let's define our :class: `daf.guild.GUILD ` object now. Its most important (but not all) parameters are:
110110
111111- ``snowflake ``: An integer parameter. Represents a unique identifier, which identifies every Discord resource.
112112 Snowflake can be obtained by
@@ -146,6 +146,8 @@ Let's expand our example from :ref:`Definition of accounts (core)`.
146146 daf.run(accounts = accounts)
147147
148148
149+
150+
149151 Now let's define our messages.
150152
151153--------------------------------------
@@ -178,13 +180,20 @@ The most important parameters inside :class:`daf.message.TextMESSAGE` are:
178180 multiple specified days at a specific time.
179181 - :class: `~daf.message.messageperiod.DailyPeriod `: A period that sends every day at a specific time.
180182
183+ - ``constraints ``: A list of constraints that only allow a message to be sent when they are fulfilled. This can for
184+ example be used to only send messages to channels when the last message in that channel is not or own, thus
185+ **preventing unnecessary spam **. Currently a single constraint is supported:
186+
187+ - :class: `daf.message.constraints.AntiSpamMessageConstraint `
188+
181189Now that we have an overview of the most important parameters, let's define our message.
182190We will define a message that sends fixed data into a single channel, with a fixed time (duration) period.
183191
184192.. code-block :: python
185193 :linenos:
186- :emphasize- lines: 1 - 3 , 19 - 23
194+ :emphasize- lines: 1 - 4 , 19 - 24
187195
196+ from daf.message.constraints import AntiSpamMessageConstraint
188197 from daf.message.messageperiod import FixedDurationPeriod
189198 from daf.messagedata import TextMessageData
190199 from daf.message import TextMESSAGE
@@ -201,12 +210,13 @@ We will define a message that sends fixed data into a single channel, with a fix
201210 is_user = False , # Above token is user account's token and not a bot token.
202211 servers = [
203212 GUILD(
204- snowflake = 863071397207212052 ,
213+ snowflake = 2312312312312312313123 ,
205214 messages = [
206215 TextMESSAGE(
207216 data = TextMessageData(content = " Looking for NFT?" ),
208- channels = [1159224699830677685 ],
209- period = FixedDurationPeriod(duration = timedelta(seconds = 15 ))
217+ channels = [3215125123123123123123 ],
218+ period = FixedDurationPeriod(duration = timedelta(seconds = 5 )),
219+ constraints = [AntiSpamMessageConstraint(per_channel = True )]
210220 )
211221 ]
212222 )
@@ -217,6 +227,7 @@ We will define a message that sends fixed data into a single channel, with a fix
217227 daf.run(accounts = accounts)
218228
219229
230+
220231 .. image :: ./images/message_definition_example_output.png
221232 :width: 20cm
222233
@@ -233,7 +244,7 @@ Additionally, it contains a ``volume`` parameter.
233244Message advertisement examples
234245--------------------------------------
235246
236- The following examples show a complete core script setup needed to advertise periodic messages.
247+ The following examples show a complete core script (without message constraints) setup needed to advertise periodic messages.
237248
238249.. dropdown :: TextMESSAGE
239250
0 commit comments