Skip to content

Commit 05b522f

Browse files
authored
Linting, doc, examples (#57)
- Linting - Split documentation into a shorter README.md and a longer DOC.md
1 parent 9db1d31 commit 05b522f

File tree

20 files changed

+1053
-589
lines changed

20 files changed

+1053
-589
lines changed

DOC.md

Lines changed: 452 additions & 0 deletions
Large diffs are not rendered by default.

Examples/Additional Application Layer Example/Coffee/main_coffee.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
guild_id=123456789,
1616
messages_to_send=[
1717

18-
fw.MESSAGE(start_period=None, end_period=10, data=app.app.get_data(), channel_ids=[123456789], mode="send", start_now=True)
18+
fw.TextMESSAGE(start_period=None, end_period=10, data=app.app.get_data(), channel_ids=[123456789], mode="send", start_now=True)
1919
],
2020
generate_log=True
2121
)
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import framework, datetime, secret
2+
from framework import discord
3+
4+
5+
6+
############################################################################################
7+
# It's VERY IMPORTANT that you use @framework.data_function!
8+
############################################################################################
9+
10+
11+
@framework.data_function
12+
def get_data(parameter):
13+
l_time = datetime.datetime.now()
14+
return f"Parameter: {parameter}\nTimestamp: {l_time.day}.{l_time.month}.{l_time.year} :: {l_time.hour}:{l_time.minute}:{l_time.second}"
15+
16+
guilds = [
17+
framework.USER(
18+
user_id=123456789, # ID of server (guild)
19+
messages_to_send=[ # List MESSAGE objects
20+
framework.DirectMESSAGE(
21+
start_period=None, # If None, messages will be send on a fixed period (end period)
22+
end_period=15, # If start_period is None, it dictates the fixed sending period,
23+
# If start period is defined, it dictates the maximum limit of randomized period
24+
data=get_data(123), # Data you want to sent to the function (Can be of types : str, embed, file, list of types to the left
25+
# or function that returns any of above types(or returns None if you don't have any data to send yet),
26+
# where if you pass a function you need to use the framework.FUNCTION decorator on top of it ).
27+
mode="send", # "send" will send a new message every time, "edit" will edit the previous message, "clear-send" will delete
28+
# the previous message and then send a new one
29+
start_now=True # Start sending now (True) or wait until period
30+
),
31+
],
32+
generate_log=True ## Generate file log of sent messages (and failed attempts) for this user
33+
)
34+
]
35+
36+
############################################################################################
37+
38+
if __name__ == "__main__":
39+
framework.run( token=secret.C_TOKEN, # MANDATORY,
40+
server_list=guilds, # MANDATORY
41+
is_user=False, # OPTIONAL
42+
user_callback=None, # OPTIONAL
43+
server_log_output="History", # OPTIONAL
44+
debug=True) # OPTIONAL
45+
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import framework as fw, secret
2+
############################################################################################
3+
# EMBED VARIABLE DEFINITON #
4+
############################################################################################
5+
# NOTE! There can only be one embed per message but you can add more fields inside that embed!
6+
7+
8+
# framework.EMBED example
9+
test_embed1 = fw.EMBED(
10+
author_name="Developer",
11+
author_icon="https://solarsystem.nasa.gov/system/basic_html_elements/11561_Sun.png",
12+
fields=\
13+
[
14+
fw.EmbedFIELD("Test 1", "Hello World", True),
15+
fw.EmbedFIELD("Test 2", "Hello World 2", True),
16+
fw.EmbedFIELD("Test 3", "Hello World 3", True),
17+
fw.EmbedFIELD("No Inline", "This is without inline", False),
18+
fw.EmbedFIELD("Test 4", "Hello World 4", True),
19+
fw.EmbedFIELD("Test 5", "Hello World 5", True)
20+
],
21+
## ... for other arguments, see https://github.com/davidhozic/discord-advertisement-framework
22+
)
23+
24+
25+
# pycord (discord.py) Embed
26+
test_embed2 = fw.discord.Embed(
27+
color= fw.discord.Color.dark_orange(),
28+
title="Test Embed Title",
29+
description="This is a discord embed",
30+
# ... other, refer to Pycord documentation
31+
)
32+
33+
# framework.EMBED from discord.Embed
34+
test_embed_fw_2 = fw.EMBED.from_discord_embed(test_embed2) ## Converts discord.Embed into framework.EMBED
35+
36+
37+
38+
############################################################################################
39+
# GUILD MESSAGES DEFINITION #
40+
############################################################################################
41+
guilds = [
42+
fw.USER(
43+
user_id=123456789, # ID of server (guild)
44+
messages_to_send=[ # List MESSAGE objects
45+
fw.DirectMESSAGE(
46+
start_period=None, # If None, messages will be send on a fixed period (end period)
47+
end_period=15, # If start_period is None, it dictates the fixed sending period,
48+
# If start period is defined, it dictates the maximum limit of randomized period
49+
data=test_embed1, # Data you want to sent to the function (Can be of types : str, embed, file, list of types to the left
50+
# or function that returns any of above types(or returns None if you don't have any data to send yet),
51+
# where if you pass a function you need to use the fw.FUNCTION decorator on top of it ).
52+
mode="send", # "send" will send a new message every time, "edit" will edit the previous message, "clear-send" will delete
53+
# the previous message and then send a new one
54+
start_now=True # Start sending now (True) or wait until period
55+
),
56+
57+
fw.DirectMESSAGE(
58+
start_period=None,
59+
end_period=15,
60+
61+
data=test_embed_fw_2,
62+
63+
mode="send",
64+
start_now=True
65+
),
66+
],
67+
generate_log=True ## Generate file log of sent messages (and failed attempts) for this user
68+
)
69+
]
70+
71+
############################################################################################
72+
73+
if __name__ == "__main__":
74+
fw.run( token=secret.C_TOKEN, # MANDATORY,
75+
server_list=guilds, # MANDATORY
76+
is_user=False, # OPTIONAL
77+
user_callback=None, # OPTIONAL
78+
server_log_output="History", # OPTIONAL
79+
debug=True) # OPTIONAL
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import framework, secret
2+
from framework import discord
3+
4+
5+
6+
############################################################################################
7+
# GUILD MESSAGES DEFINITION #
8+
############################################################################################
9+
10+
# File object representing file that will be sent
11+
l_file = framework.FILE("./Examples/main_send_file.py")
12+
13+
guilds = [
14+
framework.USER(
15+
user_id=123456789, # ID of server (guild)
16+
messages_to_send=[ # List MESSAGE objects
17+
framework.DirectMESSAGE(
18+
start_period=None, # If None, messages will be send on a fixed period (end period)
19+
end_period=15, # If start_period is None, it dictates the fixed sending period,
20+
# If start period is defined, it dictates the maximum limit of randomized period
21+
data=l_file, # Data you want to sent to the function (Can be of types : str, embed, file, list of types to the left
22+
# or function that returns any of above types(or returns None if you don't have any data to send yet),
23+
# where if you pass a function you need to use the framework.FUNCTION decorator on top of it ).
24+
mode="send", # "send" will send a new message every time, "edit" will edit the previous message, "clear-send" will delete
25+
# the previous message and then send a new one
26+
start_now=True # Start sending now (True) or wait until period
27+
),
28+
],
29+
generate_log=True ## Generate file log of sent messages (and failed attempts) for this user
30+
)
31+
]
32+
33+
############################################################################################
34+
35+
if __name__ == "__main__":
36+
framework.run( token=secret.C_TOKEN, # MANDATORY,
37+
server_list=guilds, # MANDATORY
38+
is_user=False, # OPTIONAL
39+
user_callback=None, # OPTIONAL
40+
server_log_output="History", # OPTIONAL
41+
debug=True) # OPTIONAL
42+
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import framework, secret
2+
from framework import discord
3+
4+
5+
6+
############################################################################################
7+
# GUILD MESSAGES DEFINITION #
8+
############################################################################################
9+
10+
# File object representing file that will be sent
11+
l_file1 = framework.FILE("./Examples/main_send_file.py")
12+
l_file2 = framework.FILE("./Examples/main_send_multiple.py")
13+
14+
## Embedded
15+
l_embed = framework.EMBED(
16+
author_name="Developer",
17+
author_icon="https://solarsystem.nasa.gov/system/basic_html_elements/11561_Sun.png",
18+
fields=\
19+
[
20+
framework.EmbedFIELD("Test 1", "Hello World", True),
21+
framework.EmbedFIELD("Test 2", "Hello World 2", True),
22+
framework.EmbedFIELD("Test 3", "Hello World 3", True),
23+
framework.EmbedFIELD("No Inline", "This is without inline", False),
24+
framework.EmbedFIELD("Test 4", "Hello World 4", True),
25+
framework.EmbedFIELD("Test 5", "Hello World 5", True)
26+
]
27+
)
28+
29+
guilds = [
30+
framework.USER(
31+
user_id=123456789, # ID of server (guild)
32+
messages_to_send=[ # List MESSAGE objects
33+
framework.DirectMESSAGE(
34+
start_period=None, # If None, messages will be send on a fixed period (end period)
35+
end_period=15, # If start_period is None, it dictates the fixed sending period,
36+
# If start period is defined, it dictates the maximum limit of randomized period
37+
data=["Hello World", # Data you want to sent to the function (Can be of types : str, embed, file, list of types to the left
38+
l_file1, # or function that returns any of above types(or returns None if you don't have any data to send yet),
39+
l_file2, # where if you pass a function you need to use the framework.FUNCTION decorator on top of it ).
40+
l_embed],
41+
mode="send", # "send" will send a new message every time, "edit" will edit the previous message, "clear-send" will delete
42+
# the previous message and then send a new one
43+
start_now=True # Start sending now (True) or wait until period
44+
),
45+
],
46+
generate_log=True ## Generate file log of sent messages (and failed attempts) for this user
47+
)
48+
]
49+
50+
51+
############################################################################################
52+
53+
if __name__ == "__main__":
54+
framework.run( token=secret.C_TOKEN, # MANDATORY,
55+
server_list=guilds, # MANDATORY
56+
is_user=False, # OPTIONAL
57+
user_callback=None, # OPTIONAL
58+
server_log_output="History", # OPTIONAL
59+
debug=True) # OPTIONAL
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import framework, secret
2+
from framework import discord
3+
4+
5+
6+
############################################################################################
7+
# GUILD MESSAGES DEFINITION #
8+
############################################################################################
9+
10+
guilds = [
11+
framework.USER(
12+
user_id=123456789, # ID of server (guild)
13+
messages_to_send=[ # List MESSAGE objects
14+
framework.DirectMESSAGE(
15+
start_period=None, # If None, messages will be send on a fixed period (end period)
16+
end_period=15, # If start_period is None, it dictates the fixed sending period,
17+
# If start period is defined, it dictates the maximum limit of randomized period
18+
data="First message", # Data you want to sent to the function (Can be of types : str, embed, file, list of types to the left
19+
# or function that returns any of above types(or returns None if you don't have any data to send yet),
20+
# where if you pass a function you need to use the framework.FUNCTION decorator on top of it ).
21+
channel_ids=[123456789], # List of ids of all the channels you want this message to be sent into
22+
mode="send", # "send" will send a new message every time, "edit" will edit the previous message, "clear-send" will delete
23+
# the previous message and then send a new one
24+
start_now=True # Start sending now (True) or wait until period
25+
),
26+
framework.TextMESSAGE(start_period=5, end_period=10, data="Second Message", channel_ids=[12345], mode="send", start_now=True)
27+
],
28+
generate_log=True ## Generate file log of sent messages (and failed attempts) for this user
29+
)
30+
]
31+
32+
############################################################################################
33+
34+
if __name__ == "__main__":
35+
framework.run( token=secret.C_TOKEN, # MANDATORY,
36+
server_list=guilds, # MANDATORY
37+
is_user=False, # OPTIONAL
38+
user_callback=None, # OPTIONAL
39+
server_log_output="History", # OPTIONAL
40+
debug=True) # OPTIONAL

Examples/TextMESSAGE/main_data_function.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ def get_data(parameter):
2525
# or function that returns any of above types(or returns None if you don't have any data to send yet),
2626
# where if you pass a function you need to use the framework.FUNCTION decorator on top of it ).
2727
channel_ids=[123456789], # List of ids of all the channels you want this message to be sent into
28-
mode="send", # Clear all discord messages that originated from this MESSAGE object
28+
mode="send", # "send" will send a new message every time, "edit" will edit the previous message, "clear-send" will delete
29+
# the previous message and then send a new one
2930
start_now=True # Start sending now (True) or wait until period
3031
),
3132
],

Examples/TextMESSAGE/main_send_embed.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@
5050
# or function that returns any of above types(or returns None if you don't have any data to send yet),
5151
# where if you pass a function you need to use the fw.FUNCTION decorator on top of it ).
5252
channel_ids=[123456789], # List of ids of all the channels you want this message to be sent into
53-
mode="send", # Clear all discord messages that originated from this MESSAGE object
53+
mode="send", # "send" will send a new message every time, "edit" will edit the previous message, "clear-send" will delete
54+
# the previous message and then send a new one
5455
start_now=True # Start sending now (True) or wait until period
5556
),
5657

Examples/TextMESSAGE/main_send_file.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
# or function that returns any of above types(or returns None if you don't have any data to send yet),
2323
# where if you pass a function you need to use the framework.FUNCTION decorator on top of it ).
2424
channel_ids=[123456789], # List of ids of all the channels you want this message to be sent into
25-
mode="send", # Clear all discord messages that originated from this MESSAGE object
25+
mode="send", # "send" will send a new message every time, "edit" will edit the previous message, "clear-send" will delete
26+
# the previous message and then send a new one
2627
start_now=True # Start sending now (True) or wait until period
2728
),
2829
],

0 commit comments

Comments
 (0)