rewrite: More restructuring.
This commit is contained in:
6
run.py
6
run.py
@@ -1,6 +0,0 @@
|
||||
import sys
|
||||
import os
|
||||
|
||||
sys.path.insert(0, os.path.join(os.getcwd(), "bot"))
|
||||
|
||||
from bot import main
|
||||
@@ -1,12 +0,0 @@
|
||||
import sys
|
||||
import os
|
||||
import asyncio
|
||||
|
||||
sys.path.insert(0, os.path.join(os.getcwd(), "bot"))
|
||||
|
||||
from bot.analytics.server import AnalyticsServer
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
server = AnalyticsServer()
|
||||
asyncio.run(server.run())
|
||||
@@ -1,20 +0,0 @@
|
||||
import sys
|
||||
import os
|
||||
import argparse
|
||||
import asyncio
|
||||
|
||||
|
||||
sys.path.insert(0, os.path.join(os.getcwd(), "bot"))
|
||||
|
||||
from bot.meta.ipc.server import AppServer
|
||||
from bot.meta import conf
|
||||
|
||||
|
||||
async def main():
|
||||
address = {'host': conf.appipc['server_host'], 'port': int(conf.appipc['server_port'])}
|
||||
server = AppServer()
|
||||
await server.start(address)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
asyncio.run(main())
|
||||
3
scripts/makestrings.sh
Executable file
3
scripts/makestrings.sh
Executable file
@@ -0,0 +1,3 @@
|
||||
xgettext bot/modules/sysadmin/exec_cog.py -o locales/templates/exec.pot --keyword=_p:1c,2 --keyword=_n:1,2 --keyword=_np:1c,2,3
|
||||
xgettext bot/babel/*.py -o locales/templates/babel.pot --keyword=_p:1c,2 --keyword=_n:1,2 --keyword=_np:1c,2,3
|
||||
xgettext bot/modules/reminders/*.py -o locales/templates/reminders.pot --keyword=_p:1c,2 --keyword=_n:1,2 --keyword=_np:1c,2,3
|
||||
14
scripts/start_analytics.py
Executable file
14
scripts/start_analytics.py
Executable file
@@ -0,0 +1,14 @@
|
||||
# !/bin/python3
|
||||
|
||||
import sys
|
||||
import os
|
||||
import asyncio
|
||||
|
||||
sys.path.insert(0, os.path.join(os.getcwd()))
|
||||
sys.path.insert(0, os.path.join(os.getcwd(), "src"))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from analytics.server import AnalyticsServer
|
||||
server = AnalyticsServer()
|
||||
asyncio.run(server.run())
|
||||
6
scripts/start_gui.py
Executable file
6
scripts/start_gui.py
Executable file
@@ -0,0 +1,6 @@
|
||||
import asyncio
|
||||
from src.server import main
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
asyncio.run(main())
|
||||
12
scripts/start_leo.py
Executable file
12
scripts/start_leo.py
Executable file
@@ -0,0 +1,12 @@
|
||||
# !/bin/python3
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
||||
sys.path.insert(0, os.path.join(os.getcwd()))
|
||||
sys.path.insert(0, os.path.join(os.getcwd(), "src"))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from bot import _main
|
||||
_main()
|
||||
16
scripts/start_registry.py
Executable file
16
scripts/start_registry.py
Executable file
@@ -0,0 +1,16 @@
|
||||
# !/bin/python3
|
||||
|
||||
import sys
|
||||
import os
|
||||
import asyncio
|
||||
|
||||
sys.path.insert(0, os.path.join(os.getcwd()))
|
||||
sys.path.insert(0, os.path.join(os.getcwd(), "src"))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from meta.ipc.server import AppServer
|
||||
from meta import conf
|
||||
address = {'host': conf.appipc['server_host'], 'port': int(conf.appipc['server_port'])}
|
||||
server = AppServer()
|
||||
asyncio.run(server.start(address))
|
||||
2
src/gui
2
src/gui
Submodule src/gui updated: 76659f1193...fd34ea70d6
0
tests/gui/cards/__init__.py
Normal file
0
tests/gui/cards/__init__.py
Normal file
12
tests/gui/cards/goal_sample.py
Normal file
12
tests/gui/cards/goal_sample.py
Normal file
@@ -0,0 +1,12 @@
|
||||
import asyncio
|
||||
import datetime as dt
|
||||
from src.cards import WeeklyGoalCard
|
||||
|
||||
|
||||
async def get_card():
|
||||
card = await WeeklyGoalCard.generate_sample()
|
||||
with open('samples/weekly-sample.png', 'wb') as image_file:
|
||||
image_file.write(card.fp.read())
|
||||
|
||||
if __name__ == '__main__':
|
||||
asyncio.run(get_card())
|
||||
12
tests/gui/cards/leaderboard_sample.py
Normal file
12
tests/gui/cards/leaderboard_sample.py
Normal file
@@ -0,0 +1,12 @@
|
||||
import asyncio
|
||||
import datetime as dt
|
||||
from src.cards import LeaderboardCard
|
||||
|
||||
|
||||
async def get_card():
|
||||
card = await LeaderboardCard.generate_sample()
|
||||
with open('samples/leaderboard-sample.png', 'wb') as image_file:
|
||||
image_file.write(card.fp.read())
|
||||
|
||||
if __name__ == '__main__':
|
||||
asyncio.run(get_card())
|
||||
45
tests/gui/cards/leaderboard_spec_sample.py
Normal file
45
tests/gui/cards/leaderboard_spec_sample.py
Normal file
@@ -0,0 +1,45 @@
|
||||
import asyncio
|
||||
import random
|
||||
import datetime as dt
|
||||
from src.cards import LeaderboardCard as _Card
|
||||
|
||||
|
||||
highlights = [
|
||||
"header_text_colour",
|
||||
"subheader_name_colour",
|
||||
"subheader_value_colour",
|
||||
"top_position_colour",
|
||||
"top_name_colour",
|
||||
"top_hours_colour",
|
||||
"entry_position_colour",
|
||||
"entry_position_highlight_colour",
|
||||
"entry_name_colour",
|
||||
"entry_hours_colour",
|
||||
"entry_bg_colour",
|
||||
"entry_bg_highlight_colour"
|
||||
]
|
||||
highlight_colour = "#E84727"
|
||||
card_name = "leaderboard"
|
||||
|
||||
|
||||
async def get_cards():
|
||||
strings = []
|
||||
random.seed(0)
|
||||
for highlight in highlights:
|
||||
card = await _Card.generate_sample(
|
||||
skin={highlight: highlight_colour}
|
||||
)
|
||||
with open(f"../skins/spec/images/{card_name}/{highlight}.png", 'wb') as image_file:
|
||||
image_file.write(card.fp.read())
|
||||
|
||||
esc_highlight = highlight.replace('_', '\\_')
|
||||
string = f"""\
|
||||
\\hypertarget{{{card_name}-{highlight.replace('_', '-')}}}{{\\texttt{{{esc_highlight}}}}} & &
|
||||
\\includegraphics[width=.25\\textwidth,valign=m]{{images/{card_name}/{highlight}.png}}
|
||||
\\\\"""
|
||||
strings.append(string)
|
||||
|
||||
print('\n'.join(strings))
|
||||
|
||||
if __name__ == '__main__':
|
||||
asyncio.run(get_cards())
|
||||
54
tests/gui/cards/monthly_spec_sample.py
Normal file
54
tests/gui/cards/monthly_spec_sample.py
Normal file
@@ -0,0 +1,54 @@
|
||||
import asyncio
|
||||
import random
|
||||
import datetime as dt
|
||||
from src.cards import MonthlyStatsCard as _Card
|
||||
|
||||
|
||||
highlights = [
|
||||
'title_colour',
|
||||
'top_hours_colour',
|
||||
'top_hours_bg_colour',
|
||||
'top_line_colour',
|
||||
'top_date_colour',
|
||||
'top_this_colour',
|
||||
'top_last_colour',
|
||||
'top_this_hours_colour',
|
||||
'top_last_hours_colour',
|
||||
'this_month_colour',
|
||||
'last_month_colour',
|
||||
'heatmap_empty_colour',
|
||||
'weekday_background_colour',
|
||||
'weekday_colour',
|
||||
'month_background_colour',
|
||||
'month_colour',
|
||||
'stats_key_colour',
|
||||
'stats_value_colour',
|
||||
'footer_colour',
|
||||
]
|
||||
highlight_colour = "#E84727"
|
||||
card_name = "monthly"
|
||||
|
||||
highlights = ['heatmap_colours']
|
||||
highlight_colour = ["#E84727"]
|
||||
|
||||
async def get_cards():
|
||||
strings = []
|
||||
random.seed(0)
|
||||
for highlight in highlights:
|
||||
card = await _Card.generate_sample(
|
||||
skin={highlight: highlight_colour}
|
||||
)
|
||||
with open(f"../skins/spec/images/{card_name}/{highlight}.png", 'wb') as image_file:
|
||||
image_file.write(card.fp.read())
|
||||
|
||||
esc_highlight = highlight.replace('_', '\\_')
|
||||
string = f"""\
|
||||
\\hypertarget{{{card_name}-{highlight.replace('_', '-')}}}{{\\texttt{{{esc_highlight}}}}} & &
|
||||
\\includegraphics[width=.25\\textwidth,valign=m]{{images/{card_name}/{highlight}.png}}
|
||||
\\\\"""
|
||||
strings.append(string)
|
||||
|
||||
print('\n'.join(strings))
|
||||
|
||||
if __name__ == '__main__':
|
||||
asyncio.run(get_cards())
|
||||
44
tests/gui/cards/profile_spec_sample.py
Normal file
44
tests/gui/cards/profile_spec_sample.py
Normal file
@@ -0,0 +1,44 @@
|
||||
import asyncio
|
||||
import datetime as dt
|
||||
from src.cards import ProfileCard as _Card
|
||||
|
||||
|
||||
highlights = [
|
||||
"header_colour_1",
|
||||
"header_colour_2",
|
||||
"counter_bg_colour",
|
||||
"counter_colour",
|
||||
"subheader_colour",
|
||||
"badge_text_colour",
|
||||
"badge_blob_colour",
|
||||
"rank_name_colour",
|
||||
"rank_hours_colour",
|
||||
"bar_full_colour",
|
||||
"bar_empty_colour",
|
||||
"next_rank_colour"
|
||||
]
|
||||
highlight_colour = "#E84727"
|
||||
card_name = "profile"
|
||||
|
||||
|
||||
async def get_cards():
|
||||
strings = []
|
||||
for highlight in highlights:
|
||||
card = await _Card.generate_sample(
|
||||
skin={highlight: highlight_colour}
|
||||
)
|
||||
with open(f"../skins/spec/images/{card_name}/{highlight}.png", 'wb') as image_file:
|
||||
image_file.write(card.fp.read())
|
||||
|
||||
esc_highlight = highlight.replace('_', '\\_')
|
||||
string = f"""
|
||||
\\hypertarget{{{card_name}-{highlight.replace('_', '-')}}}{{\\texttt{{{esc_highlight}}}}} & &
|
||||
\\includegraphics[width=.25\\textwidth,valign=m]{{images/{card_name}/{highlight}.png}}
|
||||
\\\\
|
||||
"""
|
||||
strings.append(string)
|
||||
|
||||
print('\n'.join(strings))
|
||||
|
||||
if __name__ == '__main__':
|
||||
asyncio.run(get_cards())
|
||||
30
tests/gui/cards/stats_spec_sample.py
Normal file
30
tests/gui/cards/stats_spec_sample.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import asyncio
|
||||
import datetime as dt
|
||||
from src.cards import StatsCard
|
||||
|
||||
|
||||
highlights = [
|
||||
'header_colour',
|
||||
'stats_subheader_colour',
|
||||
'stats_text_colour',
|
||||
'col2_date_colour',
|
||||
'col2_hours_colour',
|
||||
'cal_weekday_colour',
|
||||
'cal_number_colour',
|
||||
'cal_number_end_colour',
|
||||
'cal_streak_end_colour',
|
||||
'cal_streak_middle_colour',
|
||||
]
|
||||
highlight_colour = "#E84727"
|
||||
|
||||
|
||||
async def get_cards():
|
||||
for highlight in highlights:
|
||||
card = await StatsCard.generate_sample(
|
||||
skin={highlight: highlight_colour}
|
||||
)
|
||||
with open('../skins/spec/images/stats/{}.png'.format(highlight), 'wb') as image_file:
|
||||
image_file.write(card.fp.read())
|
||||
|
||||
if __name__ == '__main__':
|
||||
asyncio.run(get_cards())
|
||||
17
tests/gui/cards/tasklist_sample.py
Normal file
17
tests/gui/cards/tasklist_sample.py
Normal file
@@ -0,0 +1,17 @@
|
||||
import asyncio
|
||||
import datetime as dt
|
||||
from src.cards import TasklistCard
|
||||
|
||||
|
||||
highlight = "mini_profile_badge_text_colour"
|
||||
highlight_colour = "#E84727"
|
||||
|
||||
async def get_card():
|
||||
card = await TasklistCard.generate_sample(
|
||||
skin={highlight: highlight_colour}
|
||||
)
|
||||
with open('samples/tasklist-sample.png', 'wb') as image_file:
|
||||
image_file.write(card.fp.read())
|
||||
|
||||
if __name__ == '__main__':
|
||||
asyncio.run(get_card())
|
||||
28
tests/gui/cards/tasklist_spec_sample.py
Normal file
28
tests/gui/cards/tasklist_spec_sample.py
Normal file
@@ -0,0 +1,28 @@
|
||||
import asyncio
|
||||
import datetime as dt
|
||||
from src.cards import TasklistCard
|
||||
|
||||
|
||||
highlights = [
|
||||
'mini_profile_badge_colour',
|
||||
'mini_profile_name_colour',
|
||||
'mini_profile_discrim_colour',
|
||||
'task_done_number_colour',
|
||||
'task_done_text_colour',
|
||||
'task_undone_text_colour',
|
||||
'task_undone_number_colour',
|
||||
'footer_colour'
|
||||
]
|
||||
highlight_colour = "#E84727"
|
||||
|
||||
|
||||
async def get_cards():
|
||||
for highlight in highlights:
|
||||
card = await TasklistCard.generate_sample(
|
||||
skin={highlight: highlight_colour}
|
||||
)
|
||||
with open('../skins/spec/images/tasklist/{}.png'.format(highlight), 'wb') as image_file:
|
||||
image_file.write(card.fp.read())
|
||||
|
||||
if __name__ == '__main__':
|
||||
asyncio.run(get_cards())
|
||||
49
tests/gui/cards/weekly_spec_sample.py
Normal file
49
tests/gui/cards/weekly_spec_sample.py
Normal file
@@ -0,0 +1,49 @@
|
||||
import asyncio
|
||||
import datetime as dt
|
||||
from src.cards import WeeklyStatsCard as _Card
|
||||
|
||||
|
||||
highlights = [
|
||||
'title_colour',
|
||||
'top_hours_colour',
|
||||
'top_hours_bg_colour',
|
||||
'top_line_colour',
|
||||
'top_weekday_colour',
|
||||
'top_date_colour',
|
||||
'top_this_colour',
|
||||
'top_last_colour',
|
||||
'btm_weekly_background_colour',
|
||||
'btm_this_colour',
|
||||
'btm_last_colour',
|
||||
'btm_weekday_colour',
|
||||
'btm_day_colour',
|
||||
'btm_bar_horiz_colour',
|
||||
'btm_bar_vert_colour',
|
||||
'this_week_colour',
|
||||
'last_week_colour',
|
||||
'footer_colour'
|
||||
]
|
||||
highlight_colour = "#E84727"
|
||||
card_name = "weekly"
|
||||
|
||||
|
||||
async def get_cards():
|
||||
strings = []
|
||||
for highlight in highlights:
|
||||
card = await _Card.generate_sample(
|
||||
skin={highlight: highlight_colour}
|
||||
)
|
||||
with open(f"../skins/spec/images/{card_name}/{highlight}.png", 'wb') as image_file:
|
||||
image_file.write(card.fp.read())
|
||||
|
||||
esc_highlight = highlight.replace('_', '\\_')
|
||||
string = f"""\
|
||||
\\hypertarget{{{card_name}-{highlight.replace('_', '-')}}}{{\\texttt{{{esc_highlight}}}}} & &
|
||||
\\includegraphics[width=.25\\textwidth,valign=m]{{images/{card_name}/{highlight}.png}}
|
||||
\\\\"""
|
||||
strings.append(string)
|
||||
|
||||
print('\n'.join(strings))
|
||||
|
||||
if __name__ == '__main__':
|
||||
asyncio.run(get_cards())
|
||||
54
tests/gui/cards/weeklygoals_spec_sample.py
Normal file
54
tests/gui/cards/weeklygoals_spec_sample.py
Normal file
@@ -0,0 +1,54 @@
|
||||
import asyncio
|
||||
import random
|
||||
import datetime as dt
|
||||
from src.cards import WeeklyGoalCard as _Card
|
||||
|
||||
|
||||
highlights = [
|
||||
'title_colour',
|
||||
'mini_profile_name_colour',
|
||||
'mini_profile_discrim_colour',
|
||||
'mini_profile_badge_colour',
|
||||
'mini_profile_badge_text_colour',
|
||||
'progress_bg_colour',
|
||||
'progress_colour',
|
||||
'task_count_colour',
|
||||
'task_done_colour',
|
||||
'task_goal_colour',
|
||||
'task_goal_number_colour',
|
||||
'attendance_rate_colour',
|
||||
'attendance_colour',
|
||||
'studied_text_colour',
|
||||
'studied_hour_colour',
|
||||
'task_header_colour',
|
||||
'task_done_number_colour',
|
||||
'task_done_text_colour',
|
||||
'task_undone_number_colour',
|
||||
'task_undone_text_colour',
|
||||
'footer_colour'
|
||||
]
|
||||
highlight_colour = "#E84727"
|
||||
card_name = "weeklygoals"
|
||||
|
||||
|
||||
async def get_cards():
|
||||
strings = []
|
||||
random.seed(0)
|
||||
for highlight in highlights:
|
||||
card = await _Card.generate_sample(
|
||||
skin={highlight: highlight_colour}
|
||||
)
|
||||
with open(f"../skins/spec/images/{card_name}/{highlight}.png", 'wb') as image_file:
|
||||
image_file.write(card.fp.read())
|
||||
|
||||
esc_highlight = highlight.replace('_', '\\_')
|
||||
string = f"""\
|
||||
\\hypertarget{{{card_name}-{highlight.replace('_', '-')}}}{{\\texttt{{{esc_highlight}}}}} & &
|
||||
\\includegraphics[width=.25\\textwidth,valign=m]{{images/{card_name}/{highlight}.png}}
|
||||
\\\\"""
|
||||
strings.append(string)
|
||||
|
||||
print('\n'.join(strings))
|
||||
|
||||
if __name__ == '__main__':
|
||||
asyncio.run(get_cards())
|
||||
BIN
tests/gui/output/example_avatar.png
Normal file
BIN
tests/gui/output/example_avatar.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 54 KiB |
19
tests/gui/output/profile_sample.py
Normal file
19
tests/gui/output/profile_sample.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from profile import ProfileCard
|
||||
|
||||
|
||||
card = ProfileCard(
|
||||
name='ARI HORESH',
|
||||
discrim='#0001',
|
||||
avatar=open('samples/example_avatar.png', 'rb'),
|
||||
coins=58596,
|
||||
time=3750 * 3600,
|
||||
answers=10,
|
||||
attendance=0.9,
|
||||
badges=('MEDICINE', 'NEUROSCIENCE', 'BIO', 'MATHS', 'BACHELOR\'S DEGREE', 'VEGAN SOMETIMES', 'EUROPE'),
|
||||
achievements=(0, 2, 5, 7),
|
||||
current_rank=('VAMPIRE', 3000, 4000),
|
||||
next_rank=('WIZARD', 4000, 8000),
|
||||
draft=False
|
||||
)
|
||||
image = card.draw()
|
||||
image.save('profilecard.png', dpi=(150, 150))
|
||||
BIN
tests/gui/output/profilecard.png
Normal file
BIN
tests/gui/output/profilecard.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 214 KiB |
27
tests/gui/output/stats_sample.py
Normal file
27
tests/gui/output/stats_sample.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import datetime as dt
|
||||
from stats import StatsCard
|
||||
|
||||
|
||||
card = StatsCard(
|
||||
(21, 123),
|
||||
(3600, 5 * 24 * 3600, 1.5 * 24 * 3600, 100 * 24 * 3600),
|
||||
50,
|
||||
[(1, 3), (7, 8), (10, 10), (12, 16), (18, 25), (27, 31)],
|
||||
date=dt.datetime(2022, 1, 1),
|
||||
# draft=True
|
||||
)
|
||||
|
||||
image = card.draw()
|
||||
image.save('statscard_alt.png', dpi=(150, 150))
|
||||
|
||||
card = StatsCard(
|
||||
(21, 123),
|
||||
(3600, 5 * 24 * 3600, 1.5 * 24 * 3600, 100 * 24 * 3600),
|
||||
50,
|
||||
[(1, 3), (7, 8), (10, 10), (12, 16), (18, 25), (27, 31)],
|
||||
date=dt.datetime(2022, 2, 1),
|
||||
# draft=True
|
||||
)
|
||||
|
||||
image = card.draw()
|
||||
image.save('statscard.png', dpi=(150, 150))
|
||||
BIN
tests/gui/output/statscard.png
Normal file
BIN
tests/gui/output/statscard.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 119 KiB |
BIN
tests/gui/output/statscard_alt.png
Normal file
BIN
tests/gui/output/statscard_alt.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 124 KiB |
Reference in New Issue
Block a user