diff --git a/.env.template b/.env.template index f69a7ea35dcb32638b0ca75c41d7760f7321fd96..e3bff4f4b5ea990217d9c12f25d20705556c7903 100644 --- a/.env.template +++ b/.env.template @@ -30,6 +30,8 @@ DISCORD_ELM_STREET_CHANNEL=<ID of elm street channel> DISCORD_HALLOWEEN_CATEGORY=<ID of Halloween category> DISCORD_SEASONAL_EVENTS_CATEGORY=<ID of Seasonal Events Category> DISCORD_ADVENT_CALENDAR_CHANNEL_2021=<ID of advent calendar chanel for 2021> +DISCORD_TIMER_LEADERBOARD_CHANNEL= <ID where to post weekly stats, not necessary if DISCORD_TIMER_LEADERBOARD="no"> + # Wichtig für Welcome Extension @@ -51,8 +53,10 @@ DISCORD_CALMDOWN_FILE=<File name for calmdowns JSON file> DISCORD_MODULE_COURSE_FILE=<File name for module course JSON file> DISCORD_MODULE_DATA_FILE=<File name for module data JSON file> DISCORD_TIMER_FILE=<File name for running timers JSON file> +DISCORD_TIMER_STATS_FILE=<File name for timer statistics JSON file> DISCORD_ADVENT_CALENDAR_FILE=<File name for advent calendar JSON file> # Misc DISCORD_DATE_TIME_FORMAT=<Date and time format used for commands like %d.%m.%Y %H:%M> DISCORD_ADVENT_CALENDAR_START=<Start date and time for advent calendar. Something like "01.12.2021 00:00"> +DISCORD_TIMER_LEADERBOARD=<should a weekly Leaderboard be posted? "yes"|"no"> \ No newline at end of file diff --git a/cogs/sounds/standard/learning.mp3 b/cogs/sounds/standard/learning.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..88f3d083cd9752640453a5b57ff4f328f6d35f6f Binary files /dev/null and b/cogs/sounds/standard/learning.mp3 differ diff --git a/cogs/sounds/standard/pause.mp3 b/cogs/sounds/standard/pause.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..04167cbe13a0645ac95d13494d10dfaa7d16316c Binary files /dev/null and b/cogs/sounds/standard/pause.mp3 differ diff --git a/cogs/sounds/violine/learning.mp3 b/cogs/sounds/violine/learning.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..ac36a4246e41dd0bde812f87a148c7adbc6bc47d Binary files /dev/null and b/cogs/sounds/violine/learning.mp3 differ diff --git a/cogs/sounds/violine/pause.mp3 b/cogs/sounds/violine/pause.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..9d3b7f266076c3d300550738f291247244c87b2d Binary files /dev/null and b/cogs/sounds/violine/pause.mp3 differ diff --git a/views/timer_view.py b/views/timer_view.py index 35bdf31d63d8076848f3734f98c38593c6d2c65f..6220452b55c3756fbe5d8f5387743ac31e4632a4 100644 --- a/views/timer_view.py +++ b/views/timer_view.py @@ -2,12 +2,34 @@ import discord from discord import ButtonStyle, Interaction from discord.ui import Button, View +VOICY = "timerview:voicy" +SOUND = "timerview:sound" +STATS = "timerview:stats" +MANUAL = "timerview:manual" + SUBSCRIBE = "timerview:subscribe" -UNSUBSCRIBE = "timerview:unsubscribe" +RESTART = "timerview:restart" SKIP = "timverview:skip" -RESTART = "timverview:restart" STOP = "timverview:stop" +RESTART_YES = "timerview:restart_yes" +RESTART_NO = "timerview:restart_no" + +EDITDROPDOWN = "timer:editselectview:edit_dropdown" +MANUALDROPDOWN = "timer:manualselectview:manual_dropdowm" + +TIME = "timer:edit:time" +SESSIONS = "timer:edit:sessions" + + +class TimerButton(Button): + def __init__(self, emoji, custom_id, row, disabled, callback): + super().__init__(emoji=emoji, custom_id=custom_id, row=row, disabled=disabled) + self.callback = callback + + async def callback(self, interaction): + await self.callback(interaction) + class TimerView(View): def __init__(self, timer): @@ -116,3 +138,53 @@ class TimerView(View): def disable(self): for button in self.children: button.disabled = True + + +class EditSelectView(View): + def __init__(self, callback, label_list, value_list, further_info=None): + super().__init__(timeout=None) + self.callback = callback + self.label_list = label_list + self.value_list = value_list + self.further_info = further_info + + select_menu = self.children[0] + for i in range(len(label_list)): + select_menu.add_option(label=self.value_list[i], value=self.label_list[i]) + + @disnake.ui.select(custom_id=EDITDROPDOWN, + placeholder="Wähle aus", + min_values=1, + max_values=1) + async def sel_manual(self, option: SelectOption, interaction: MessageInteraction): + if self.further_info: + await self.callback(option, interaction, self.further_info) + else: + await self.callback(option, interaction) + + +class StatsEditModal(Modal): + def __init__(self, callback, infos): + + time_input = TextInput(label="Gelernte Zeit in Minuten:", + value=f"{infos['time']}", + custom_id=TIME, + style=TextInputStyle.short, + max_length=3) + + session_input = TextInput(label="Anzahl der Sessions:", + value=f"{infos['sessions']}", + custom_id=SESSIONS, + style=TextInputStyle.short, + max_length=1) + + components = [time_input, session_input] + + super().__init__(title=f"Statistik vom {infos['date']} für {infos['name']}", + custom_id=f"{infos['id']}:{infos['date']}:{infos['name']}", + components=components) + self.callback = callback + self.infos = infos + + async def callback(self, interaction: disnake.ModalInteraction): + await self.callback(interaction=interaction)