Skip to content

Commit 00c5ae9

Browse files
authored
Refactored imports, update examples
This commit refactors some of the module imports inside the package and also changes the package name from framework to daf. Closes #173
2 parents 93551bf + 9bfdfa4 commit 00c5ae9

Some content is hidden

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

53 files changed

+525
-524
lines changed

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

Lines changed: 0 additions & 29 deletions
This file was deleted.

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

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,36 @@
33
This is an example of an additional application layer you can build with this framework.
44
The application sends a message saying 'Good morning' every day at 10 AM and then sends a picture of a coffe cup from a randomized list.
55
"""
6-
from datetime import timedelta
7-
import framework as fw
8-
import app.app
9-
from framework import discord
10-
6+
import os
7+
import daf
8+
import random
9+
from datetime import datetime, timedelta
1110

11+
@daf.data_function
12+
def get_data(storage: list):
13+
now = datetime.now()
14+
if not len(storage):
15+
storage += [os.path.join("./images", x) for x in os.listdir("./images")]
16+
random.shuffle(storage)
1217

18+
image = storage.pop()
19+
text = "Good morning ({:02d}.{:02d}.{:02d} - {:02d}:{:02d}:{:02d})".format(now.day, now.month,now.year,now.hour,now.minute, now.second)
20+
return text, daf.FILE(image) # Return message to be sent
1321

22+
now = datetime.now()
1423
servers = [
15-
fw.GUILD(
24+
daf.GUILD(
1625
snowflake=123456789,
1726
messages=[
1827

19-
fw.TextMESSAGE(start_period=None, end_period=timedelta(seconds=10), data=app.app.get_data(), channels=[123456789], mode="send", start_in=timedelta(seconds=0))
28+
daf.TextMESSAGE(start_period=None, end_period=timedelta(days=1), data=get_data([]), channels=[123456789], mode="send", start_in=now.replace(second=0, microsecond=0, minute=0, hour=10) + timedelta(days=1) - now)
2029
],
2130
logging=True
2231
)
2332
]
2433

2534

2635
############################################################################################
27-
fw.run( token="YOUR TOKEN", server_list=servers)
36+
daf.run( token="YOUR TOKEN", server_list=servers)
2837

2938

0 commit comments

Comments
 (0)