diff --git a/.idea/modules.xml b/.idea/modules.xml index 8f3c7c989576f00dbfa4e302079ae1806071164c..1a03783f2b3d14eecbc4fe87f6979d2c51e01fd3 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -2,7 +2,7 @@ <project version="4"> <component name="ProjectModuleManager"> <modules> - <module fileurl="file://$PROJECT_DIR$/.idea/fernuni-bot.iml" filepath="$PROJECT_DIR$/.idea/fernuni-bot.iml" /> + <module fileurl="file://$PROJECT_DIR$/.idea/strolly.iml" filepath="$PROJECT_DIR$/.idea/strolly.iml" /> </modules> </component> </project> \ No newline at end of file diff --git a/.idea/fernuni-bot.iml b/.idea/strolly.iml similarity index 100% rename from .idea/fernuni-bot.iml rename to .idea/strolly.iml diff --git a/advent_calendar.json b/advent_calendar.json deleted file mode 100644 index 6c9da04e07ff52027261906ad7c7c634311b20ba..0000000000000000000000000000000000000000 --- a/advent_calendar.json +++ /dev/null @@ -1,122 +0,0 @@ -[ - { - "name": "T\u00fcrchen 1", - "emote": "\ud83e\udd19", - "role": "783097423567519764" - }, - { - "name": "T\u00fcrchen 2", - "emote": "\ud83d\udc7e", - "role": "783097424977199125" - }, - { - "name": "T\u00fcrchen 3", - "emote": "\ud83d\udca9", - "role": "783097427132940288" - }, - { - "name": "T\u00fcrchen 4", - "emote": "\ud83e\udd17", - "role": "783097429129297930" - }, - { - "name": "T\u00fcrchen 5", - "emote": "\ud83c\udfb9", - "role": "783097430719201291" - }, - { - "name": "T\u00fcrchen 6", - "emote": "\ud83c\udf84", - "role": "783097433294110731" - }, - { - "name": "T\u00fcrchen 7", - "emote": "\ud83e\udd65", - "role": "783097435194130492" - }, - { - "name": "T\u00fcrchen 8", - "emote": "\ud83d\udc7d", - "role": "783097437370843166" - }, - { - "name": "T\u00fcrchen 9", - "emote": "\ud83c\udf15", - "role": "783097439414386698" - }, - { - "name": "T\u00fcrchen 10", - "emote": "\ud83d\udc40", - "role": "783097441209286687" - }, - { - "name": "T\u00fcrchen 11", - "emote": "\ud83e\udd5d", - "role": "783097443628875816" - }, - { - "name": "T\u00fcrchen 12", - "emote": "\ud83d\udc51", - "role": "783097445374623775" - }, - { - "name": "T\u00fcrchen 13", - "emote": "\ud83c\udf46", - "role": "783097447307804673" - }, - { - "name": "T\u00fcrchen 14", - "emote": "\u2728", - "role": "783097449450307625" - }, - { - "name": "T\u00fcrchen 15", - "emote": "\ud83c\udf20", - "role": "783097451917213706" - }, - { - "name": "T\u00fcrchen 16", - "emote": "\ud83d\udc4d", - "role": "783097453913440267" - }, - { - "name": "T\u00fcrchen 17", - "emote": "\ud83d\udc4b", - "role": "783097455860383795" - }, - { - "name": "T\u00fcrchen 18", - "emote": "\ud83c\udf81", - "role": "783097458376441878" - }, - { - "name": "T\u00fcrchen 19", - "emote": "\ud83d\ude3a", - "role": "783097460477263872" - }, - { - "name": "T\u00fcrchen 20", - "emote": "\ud83c\udf4c", - "role": "783097462637461527" - }, - { - "name": "T\u00fcrchen 21", - "emote": "\ud83e\ude91", - "role": "783097465250906122" - }, - { - "name": "T\u00fcrchen 22", - "emote": "\ud83e\uddba", - "role": "783097467708637224" - }, - { - "name": "T\u00fcrchen 23", - "emote": "\ud83c\udf0d", - "role": "783097470003445760" - }, - { - "name": "T\u00fcrchen 24", - "emote": "\u2b50", - "role": "783097471718522921" - } -] \ No newline at end of file diff --git a/appointments_cog.py b/appointments_cog.py deleted file mode 100644 index 5afbe39def3c70c9e4a9824c2821074efebe9a65..0000000000000000000000000000000000000000 --- a/appointments_cog.py +++ /dev/null @@ -1,212 +0,0 @@ -import asyncio -import datetime -import json -import os -import re - -import discord -from discord.ext import tasks, commands - - -def is_valid_time(time): - return re.match(r"^\d+[mhd]?$", time) - - -def to_minutes(time): - if time[-1:] == "m": - return int(time[:-1]) - elif time[-1:] == "h": - h = int(time[:-1]) - return h * 60 - elif time[-1:] == "d": - d = int(time[:-1]) - h = d * 24 - return h * 60 - - return int(time) - - -class AppointmentsCog(commands.Cog): - def __init__(self, bot): - self.bot = bot - self.fmt = os.getenv("DISCORD_DATE_TIME_FORMAT") - self.timer.start() - self.appointments = {} - self.app_file = os.getenv("DISCORD_APPOINTMENTS_FILE") - self.load_appointments() - - def load_appointments(self): - """ Loads all appointments from APPOINTMENTS_FILE """ - - appointments_file = open(self.app_file, mode='r') - self.appointments = json.load(appointments_file) - - @tasks.loop(minutes=1) - async def timer(self): - delete = [] - - for channel_id, channel_appointments in self.appointments.items(): - channel = None - for message_id, appointment in channel_appointments.items(): - now = datetime.datetime.now() - date_time = datetime.datetime.strptime(appointment["date_time"], self.fmt) - remind_at = date_time - datetime.timedelta(minutes=appointment["reminder"]) - - if now >= remind_at: - try: - channel = await self.bot.fetch_channel(int(channel_id)) - message = await channel.fetch_message(int(message_id)) - reactions = message.reactions - diff = int(round(((date_time - now).total_seconds() / 60), 0)) - answer = f"Benachrichtigung!\nDer Termin \"{appointment['title']}\" ist " - - if appointment["reminder"] > 0 and diff > 0: - answer += f"in {diff} Minuten fällig." - appointment["reminder"] = 0 - else: - answer += f"jetzt fällig. :loudspeaker: " - delete.append(message_id) - - answer += f"\n" - for reaction in reactions: - if reaction.emoji == "👍": - async for user in reaction.users(): - if user != self.bot.user: - answer += f"<@!{str(user.id)}>" - - await channel.send(answer) - - if str(message.id) in delete: - await message.delete() - except discord.errors.NotFound: - delete.append(message_id) - - if len(delete) > 0: - for key in delete: - channel_appointment = channel_appointments.get(key) - if channel_appointment: - if channel_appointment["recurring"]: - recurring = channel_appointment["recurring"] - date_time_str = channel_appointment["date_time"] - date_time = datetime.datetime.strptime(date_time_str, self.fmt) - new_date_time = date_time + datetime.timedelta(minutes=recurring) - new_date_time_str = new_date_time.strftime(self.fmt) - splitted_new_date_time_str = new_date_time_str.split(" ") - await self.add_appointment(channel, channel_appointment["author_id"], - splitted_new_date_time_str[0], - splitted_new_date_time_str[1], - str(channel_appointment["reminder"]), - channel_appointment["title"], - str(channel_appointment["recurring"])) - channel_appointments.pop(key) - self.save_appointments() - - @timer.before_loop - async def before_timer(self): - await asyncio.sleep(60 - datetime.datetime.now().second) - - @commands.command(name="add-appointment") - async def cmd_add_appointment(self, ctx, date, time, reminder, title, recurring=None): - await self.add_appointment(ctx.channel, ctx.author.id, date, time, reminder, title, recurring) - - async def add_appointment(self, channel, author_id, date, time, reminder, title, recurring=None): - """ Add appointment to a channel """ - - try: - date_time = datetime.datetime.strptime(f"{date} {time}", self.fmt) - except ValueError: - await channel.send("Fehler! Ungültiges Datums und/oder Zeit Format!") - return - - if not is_valid_time(reminder): - await channel.send("Fehler! Benachrichtigung in ungültigem Format!") - return - else: - reminder = to_minutes(reminder) - - if recurring: - if not is_valid_time(recurring): - await channel.send("Fehler! Wiederholung in ungültigem Format!") - return - else: - recurring = to_minutes(recurring) - - embed = discord.Embed(title="Neuer Termin hinzugefügt!", - description=f"Wenn du eine Benachrichtigung zum Beginn des Termins" - f"{f', sowie {reminder} Minuten vorher, ' if reminder > 0 else f''} " - f"erhalten möchtest, reagiere mit :thumbsup: auf diese Nachricht.", - color=19607) - - embed.add_field(name="Titel", value=title, inline=False) - embed.add_field(name="Startzeitpunkt", value=f"{date_time.strftime(self.fmt)}", inline=False) - if reminder > 0: - embed.add_field(name="Benachrichtigung", value=f"{reminder} Minuten vor dem Start", inline=False) - if recurring: - embed.add_field(name="Wiederholung", value=f"Alle {recurring} Minuten", inline=False) - - message = await channel.send(embed=embed) - await message.add_reaction("👍") - await message.add_reaction("🗑️") - - if str(channel.id) not in self.appointments: - self.appointments[str(channel.id)] = {} - - channel_appointments = self.appointments.get(str(channel.id)) - channel_appointments[str(message.id)] = {"date_time": date_time.strftime(self.fmt), "reminder": reminder, - "title": title, "author_id": author_id, "recurring": recurring} - - self.save_appointments() - - @commands.command(name="appointments") - async def cmd_appointments(self, ctx): - """ List (and link) all Appointments in the current channel """ - - if str(ctx.channel.id) in self.appointments: - channel_appointments = self.appointments.get(str(ctx.channel.id)) - answer = f'Termine dieses Channels:\n' - delete = [] - - for message_id, appointment in channel_appointments.items(): - try: - message = await ctx.channel.fetch_message(int(message_id)) - answer += f'{appointment["date_time"]}: {appointment["title"]} => ' \ - f'{message.jump_url}\n' - except discord.errors.NotFound: - delete.append(message_id) - - if len(delete) > 0: - for key in delete: - channel_appointments.pop(key) - self.save_appointments() - - await ctx.channel.send(answer) - else: - await ctx.send("Für diesen Channel existieren derzeit keine Termine") - - def save_appointments(self): - appointments_file = open(self.app_file, mode='w') - json.dump(self.appointments, appointments_file) - - async def handle_reactions(self, payload): - channel = await self.bot.fetch_channel(payload.channel_id) - channel_appointments = self.appointments.get(str(payload.channel_id)) - if channel_appointments: - appointment = channel_appointments.get(str(payload.message_id)) - if appointment: - if payload.user_id == appointment["author_id"]: - message = await channel.fetch_message(payload.message_id) - await message.delete() - channel_appointments.pop(str(payload.message_id)) - - self.save_appointments() - - @commands.Cog.listener() - async def on_raw_reaction_add(self, payload): - if payload.user_id == self.bot.user.id: - return - - if payload.emoji.name in ["🗑️"]: - channel = await self.bot.fetch_channel(payload.channel_id) - message = await channel.fetch_message(payload.message_id) - if len(message.embeds) > 0 and message.embeds[0].title == "Neuer Termin hinzugefügt!": - await self.handle_reactions(payload) diff --git a/bati_cog.py b/bati_cog.py new file mode 100644 index 0000000000000000000000000000000000000000..4c81532529ddad81997632802458f9a9fc2b6e22 --- /dev/null +++ b/bati_cog.py @@ -0,0 +1,23 @@ +import os +import random +from time import time, sleep + +from discord.ext import commands + + +class BatiCog(commands.Cog): + def __init__(self, bot): + self.bot = bot + self.bati_id = int(os.getenv("BATI_ID")) + self.last_bati = 0 + self.bati_probability = float(os.getenv("BATI_PROBABILITY")) + self.bati_delay = int(os.getenv("BATI_DELAY")) + + @commands.Cog.listener() + async def on_message(self, message): + if message.author.id == self.bati_id: + if random.random() < self.bati_probability and time() >= self.last_bati + (self.bati_delay * 3600): + sleep(random.random() * 2) + await message.channel.send("bati") + self.last_bati = time() + print(message.content) diff --git a/christmas_cog.py b/christmas_cog.py deleted file mode 100644 index 30f4fb0e9e27e153f861820aa9aa01e7422ff813..0000000000000000000000000000000000000000 --- a/christmas_cog.py +++ /dev/null @@ -1,54 +0,0 @@ -import json -import os -from datetime import datetime - -from discord.ext import commands - -import utils - - -class ChristmasCog(commands.Cog): - def __init__(self, bot): - self.bot = bot - self.channel_id = int(os.getenv("DISCORD_ADVENT_CALENDAR_CHANNEL")) - self.advent_calendar = [] - self.load_advent_calendar() - - def load_advent_calendar(self): - advent_calendar_file = open("advent_calendar.json", mode='r') - self.advent_calendar = json.load(advent_calendar_file) - - @commands.command("story") - async def cmd_update_welcome(self, ctx, *args): - channel = await self.bot.fetch_channel(self.channel_id) - message = f"Einreichung von <@!{ctx.author.id}>:\n" - - for arg in args: - message += f"{arg} " - - await channel.send(message) - - @commands.Cog.listener() - async def on_raw_reaction_add(self, payload): - if payload.message_id == int(os.getenv("DISCORD_ADVENT_CALENDAR_MESSAGE")): - roles = {} - guild = await self.bot.fetch_guild(payload.guild_id) - member = await guild.fetch_member(payload.user_id) - channel = await self.bot.fetch_channel(payload.channel_id) - message = await channel.fetch_message(payload.message_id) - await message.clear_reactions() - - for role in guild.roles: - roles[str(role.id)] = role - - today = datetime.now() - day = today.day if today.day <= 24 else 24 - - if today < datetime(year=2020, month=12, day=1): - return - - for i in range(0, day): - door = self.advent_calendar[i] - if payload.emoji.name == door["emote"]: - await member.add_roles(roles[door["role"]]) - await utils.send_dm(member, f"Glückwunsch, du hast gerade {door['name']} geöffnet") diff --git a/emojis/AK.jpeg b/emojis/AK.jpeg deleted file mode 100644 index 35fd627f4b513edd25458bfbc9e6f03f8e2fe7f6..0000000000000000000000000000000000000000 Binary files a/emojis/AK.jpeg and /dev/null differ diff --git a/emojis/BI3.png b/emojis/BI3.png deleted file mode 100644 index 41fa2f529dabaf19b85c924fa683d639896ba53a..0000000000000000000000000000000000000000 Binary files a/emojis/BI3.png and /dev/null differ diff --git a/emojis/BM.jpeg b/emojis/BM.jpeg deleted file mode 100644 index b853ac3d1ead43aeec63b57cb509714e782f964a..0000000000000000000000000000000000000000 Binary files a/emojis/BM.jpeg and /dev/null differ diff --git a/emojis/BMTS.png b/emojis/BMTS.png deleted file mode 100644 index 124c51699bd5e03f27fd3ea200ebc3e6103e0ca9..0000000000000000000000000000000000000000 Binary files a/emojis/BMTS.png and /dev/null differ diff --git a/emojis/BWI2.jpeg b/emojis/BWI2.jpeg deleted file mode 100644 index 415702131158280704d5f4af614fe49cd45fc2f2..0000000000000000000000000000000000000000 Binary files a/emojis/BWI2.jpeg and /dev/null differ diff --git a/emojis/Color-Blau.png b/emojis/Color-Blau.png deleted file mode 100644 index 9b6041518c56039f16547ecf22df5a610832f45b..0000000000000000000000000000000000000000 Binary files a/emojis/Color-Blau.png and /dev/null differ diff --git "a/emojis/Color-Gr\303\274n.png" "b/emojis/Color-Gr\303\274n.png" deleted file mode 100644 index bcb4b7c968d57a6a90895d67c85fbed0815a0d41..0000000000000000000000000000000000000000 Binary files "a/emojis/Color-Gr\303\274n.png" and /dev/null differ diff --git a/emojis/Color-Lila.png b/emojis/Color-Lila.png deleted file mode 100644 index a9a073a68cf577a90082ef828532864c760f7409..0000000000000000000000000000000000000000 Binary files a/emojis/Color-Lila.png and /dev/null differ diff --git a/emojis/Color-Orange.png b/emojis/Color-Orange.png deleted file mode 100644 index 094987bc5897be6a24526d0ad9cbf0dc0cafe7ef..0000000000000000000000000000000000000000 Binary files a/emojis/Color-Orange.png and /dev/null differ diff --git a/emojis/Color-Pink.png b/emojis/Color-Pink.png deleted file mode 100644 index 05c5176612b94f4c7b35b7b4b99c7cc9b9c1774b..0000000000000000000000000000000000000000 Binary files a/emojis/Color-Pink.png and /dev/null differ diff --git a/emojis/Color-Sonnengelb.png b/emojis/Color-Sonnengelb.png deleted file mode 100644 index 85bc964aa19eaaa19b3183cbbd48c51e14a30bed..0000000000000000000000000000000000000000 Binary files a/emojis/Color-Sonnengelb.png and /dev/null differ diff --git "a/emojis/Color-T\303\274rkis.png" "b/emojis/Color-T\303\274rkis.png" deleted file mode 100644 index fda51d2a309da1b11b055400142b1222a4fd3b9d..0000000000000000000000000000000000000000 Binary files "a/emojis/Color-T\303\274rkis.png" and /dev/null differ diff --git a/emojis/MI2.png b/emojis/MI2.png deleted file mode 100644 index 64cf55e735a92cee8af8627df7f6d4fa8dbda381..0000000000000000000000000000000000000000 Binary files a/emojis/MI2.png and /dev/null differ diff --git a/emojis/MM.jpeg b/emojis/MM.jpeg deleted file mode 100644 index c7567b14738d431320e470828b72790e1e46506d..0000000000000000000000000000000000000000 Binary files a/emojis/MM.jpeg and /dev/null differ diff --git a/emojis/MPI.jpeg b/emojis/MPI.jpeg deleted file mode 100644 index 670c2faa7f2b5e8dc12715c75936309a94aa70e5..0000000000000000000000000000000000000000 Binary files a/emojis/MPI.jpeg and /dev/null differ diff --git a/emojis/MPI2.jpeg b/emojis/MPI2.jpeg deleted file mode 100644 index 1ea43299a4df38df22c1a91e0e599718162d695f..0000000000000000000000000000000000000000 Binary files a/emojis/MPI2.jpeg and /dev/null differ diff --git a/emojis/MWI.jpeg b/emojis/MWI.jpeg deleted file mode 100644 index 6228bc438d66cd2b05fda032f0adae50235160fc..0000000000000000000000000000000000000000 Binary files a/emojis/MWI.jpeg and /dev/null differ diff --git a/emojis/S.jpeg b/emojis/S.jpeg deleted file mode 100644 index 268e107e6d09a4a5f7df0de562a252a918b0e7e1..0000000000000000000000000000000000000000 Binary files a/emojis/S.jpeg and /dev/null differ diff --git a/fernuni_bot.py b/fernuni_bot.py deleted file mode 100644 index 8d8fc2251a27ac7eb0216998b8ea66e90725d4bc..0000000000000000000000000000000000000000 --- a/fernuni_bot.py +++ /dev/null @@ -1,127 +0,0 @@ -import json -import os - -import discord -from discord.ext import commands -from dotenv import load_dotenv - -# from welcome_cog import WelcomeCog -import utils -from appointments_cog import AppointmentsCog -from christmas_cog import ChristmasCog -from news_cog import NewsCog -from poll_cog import PollCog -from roles_cog import RolesCog -from support_cog import SupportCog -from text_commands_cog import TextCommandsCog -from tops_cog import TopsCog -from welcome_cog import WelcomeCog - -# .env file is necessary in the same directory, that contains several strings. -load_dotenv() -TOKEN = os.getenv('DISCORD_TOKEN') -GUILD = int(os.getenv('DISCORD_GUILD')) -ACTIVITY = os.getenv('DISCORD_ACTIVITY') -OWNER = int(os.getenv('DISCORD_OWNER')) -ROLES_FILE = os.getenv('DISCORD_ROLES_FILE') -HELP_FILE = os.getenv('DISCORD_HELP_FILE') -CATEGORY_LERNGRUPPEN = os.getenv("DISCORD_CATEGORY_LERNGRUPPEN") -PIN_EMOJI = "📌" - -intents = discord.Intents.default() -intents.members = True -bot = commands.Bot(command_prefix='!', help_command=None, activity=discord.Game(ACTIVITY), owner_id=OWNER, intents=intents) -poll_cog = PollCog(bot) -appointments_cog = AppointmentsCog(bot) -text_commands_cog = TextCommandsCog(bot) -tops_cog = TopsCog(bot) -roles_cog = RolesCog(bot) -welcome_cog = WelcomeCog(bot) -christmas_cog = ChristmasCog(bot) -bot.add_cog(appointments_cog) -bot.add_cog(text_commands_cog) -bot.add_cog(poll_cog) -bot.add_cog(tops_cog) -bot.add_cog(roles_cog) -bot.add_cog(welcome_cog) -bot.add_cog(christmas_cog) -bot.add_cog(SupportCog(bot)) -bot.add_cog(NewsCog(bot)) - - -def get_reaction(reactions): - """ Returns the reaction, that is equal to the specified PIN_EMOJI, - or if that reaction does not exist in list of reactions, None will be returned""" - - for reaction in reactions: - if reaction.emoji == PIN_EMOJI: - return reaction - return None - - -@bot.command(name="help") -async def cmd_help(ctx): - """ Send help message as DM """ - - help_file = open(HELP_FILE, mode='r') - help_dict = json.load(help_file) - embed = discord.Embed.from_dict(help_dict) - await utils.send_dm(ctx.author, "", embed=embed) - - -async def pin_message(message): - """ Pin the given message, if it is not already pinned """ - - if not message.pinned: - await message.pin() - await message.channel.send(f'Folgende Nachricht wurde gerade angepinnt: {message.jump_url}') - - -async def unpin_message(message): - """ Unpin the given message, if it is pinned, and it has no pin reaction remaining. """ - - if message.pinned: - reaction = get_reaction(message.reactions) - if reaction is None: - await message.unpin() - await message.channel.send(f'Folgende Nachricht wurde gerade losgelöst: {message.jump_url}') - - -@bot.event -async def on_ready(): - print("Client started!") - - -@bot.event -async def on_raw_reaction_add(payload): - if payload.user_id == bot.user.id: - return - - if payload.emoji.name == PIN_EMOJI: - channel = await bot.fetch_channel(payload.channel_id) - message = await channel.fetch_message(payload.message_id) - await pin_message(message) - - -@bot.event -async def on_raw_reaction_remove(payload): - if payload.emoji.name == PIN_EMOJI: - channel = await bot.fetch_channel(payload.channel_id) - message = await channel.fetch_message(payload.message_id) - await unpin_message(message) - - -@bot.event -async def on_voice_state_update(member, before, after): - if before.channel != after.channel and after.channel and "Lerngruppen-Voice" in after.channel.name: - category = await bot.fetch_channel(CATEGORY_LERNGRUPPEN) - voice_channels = category.voice_channels - - for voice_channel in voice_channels: - if len(voice_channel.members) == 0: - return - - await category.create_voice_channel(f"Lerngruppen-Voice-{len(voice_channels) + 1}") - - -bot.run(TOKEN) diff --git a/images/background.png b/images/background.png deleted file mode 100644 index 344166ef50081e62a0e67a4704208f82a8833ea1..0000000000000000000000000000000000000000 Binary files a/images/background.png and /dev/null differ diff --git a/images/background.xcf b/images/background.xcf deleted file mode 100644 index 88e75c5596955fb2e3e2066f24f166c11855e56e..0000000000000000000000000000000000000000 Binary files a/images/background.xcf and /dev/null differ diff --git a/images/logo.png b/images/logo.png deleted file mode 100644 index fad509f56b5c920dac2df5da28a2361a6c6364d4..0000000000000000000000000000000000000000 Binary files a/images/logo.png and /dev/null differ diff --git a/images/logo.xcf b/images/logo.xcf deleted file mode 100644 index 4fc3cef05721e61a8e7fee0bbcf96ecc09f8fe90..0000000000000000000000000000000000000000 Binary files a/images/logo.xcf and /dev/null differ diff --git a/images/logo_halloween.jpg b/images/logo_halloween.jpg deleted file mode 100644 index ec8a029e0165e22283e94fe177891a8be6e6e912..0000000000000000000000000000000000000000 Binary files a/images/logo_halloween.jpg and /dev/null differ diff --git a/news_cog.py b/news_cog.py deleted file mode 100644 index 10f56a9ab6165c35596ae03d49499f3ffc5aa961..0000000000000000000000000000000000000000 --- a/news_cog.py +++ /dev/null @@ -1,52 +0,0 @@ -import json -import os - -import requests -from bs4 import BeautifulSoup -from discord.ext import commands, tasks - - -class NewsCog(commands.Cog): - def __init__(self, bot): - self.bot = bot - self.channel_id = int(os.getenv("DISCORD_NEWS_CHANNEL")) - self.news_role = int(os.getenv("DISCORD_NEWS_ROLE")) - self.url = "https://www.fernuni-hagen.de/mi/studium/aktuelles/index.shtml" - self.news = {} - self.load_news() - self.news_loop.start() - - def load_news(self): - news_file = open("news.json", mode="r") - self.news = json.load(news_file) - - def save_news(self): - news_file = open("news.json", mode="w") - json.dump(self.news, news_file) - - @tasks.loop(minutes=1) - async def news_loop(self): - req = requests.get(self.url) - soup = BeautifulSoup(req.content, "html.parser") - channel = await self.bot.fetch_channel(self.channel_id) - - for news in soup.find("ul", attrs={"class": "fu-link-list"}).find_all("li"): - date = news.span.text - title = str(news.a.text) - link = news.a['href'] - - if link[0] == "/": - link = f"https://www.fernuni-hagen.de" + link - - if not self.news.get(link): - self.news[link] = date - await channel.send( - f":loudspeaker: <@&{self.news_role}> Neues aus der Fakultät vom {date} :loudspeaker: \n{title} \n{link}") - else: - prev_date = self.news[link] - if date != prev_date: - self.news[link] = date - await channel.send( - f":loudspeaker: Neues aus der Fakultät vom {date} :loudspeaker: \n{title} \n{link}") - - self.save_news() diff --git a/poll_cog.py b/poll_cog.py index d1bde3e35f08c81db2aa917e63de096685389a0b..50fc600289a1155f6ec0e18099b713bfff98252d 100644 --- a/poll_cog.py +++ b/poll_cog.py @@ -1,40 +1,12 @@ -import os - import discord from discord.ext import commands -import utils - OPTIONS = ["🇦", "🇧", "🇨", "🇩", "🇪", "🇫", "🇬", "🇭", "🇮", "🇯", "🇰", "🇱", "🇲", "🇳", "🇴", "🇵", "🇶", "🇷"] class PollCog(commands.Cog): def __init__(self, bot): self.bot = bot - self.poll_sugg_channel = int(os.getenv("DISCORD_POLL_SUGG_CHANNEL")) - - @commands.command(name="add-poll") - async def cmd_add_poll(self, ctx, question, *answers): - channel = await self.bot.fetch_channel(self.poll_sugg_channel) - msg = f"<@!{ctx.author.id}> hat folgende Umfrage vorgeschlagen:\nFrage:{question}\n\nAntwortoptionen:\n" - - for answer in answers: - msg += f"{answer}\n" - - await channel.send(msg) - - @commands.command(name="edit-poll") - @commands.check(utils.is_mod) - async def cmd_edit_poll(self, ctx, message_id, question, *answers): - message = await ctx.fetch_message(message_id) - if message: - if message.embeds[0].title == "Umfrage": - old_poll = Poll(self.bot, message=message) - new_poll = Poll(self.bot, question=question, answers=answers, author=old_poll.author) - await new_poll.send_poll(ctx.channel, message=message) - else: - ctx.send("Fehler! Umfrage nicht gefunden!") - pass @commands.command(name="poll") async def cmd_poll(self, ctx, question, *answers): @@ -123,16 +95,10 @@ class Poll: else: message = await channel.send("", embed=embed) - await message.clear_reaction("🗑️") - await message.clear_reaction("🛑") - if not result: for i in range(0, len(self.answers)): await message.add_reaction(OPTIONS[i]) - for i in range(len(self.answers), len(OPTIONS)): - await message.clear_reaction(OPTIONS[i]) - await message.add_reaction("🗑️") await message.add_reaction("🛑") diff --git a/roles_cog.py b/roles_cog.py deleted file mode 100644 index c25d6fa2da08a8d876fdae12d9633c2f697a49ea..0000000000000000000000000000000000000000 --- a/roles_cog.py +++ /dev/null @@ -1,246 +0,0 @@ -import json -import os - -import discord -from discord.ext import commands - -import utils - - -def get_student_role(guild): - student_role_id = int(os.getenv("DISCORD_STUDENTIN_ROLE")) - - for role in guild.roles: - if role.id == student_role_id: - return role - - return None - - -class RolesCog(commands.Cog): - def __init__(self, bot): - self.bot = bot - self.roles_file = os.getenv("DISCORD_ROLES_FILE") - self.channel_id = int(os.getenv("DISCORD_ROLLEN_CHANNEL")) - self.degree_program_message_id = int(os.getenv("DISCORD_DEGREE_PROGRAM_MSG")) - self.color_message_id = int(os.getenv("DISCORD_COLOR_MSG")) - self.special_message_id = int(os.getenv("DISCORD_SPECIAL_MSG")) - self.assignable_roles = {} - self.load_roles() - - def load_roles(self): - """ Loads all assignable roles from ROLES_FILE """ - - roles_file = open(self.roles_file, mode='r') - self.assignable_roles = json.load(roles_file) - - def get_degree_program_emojis(self): - """ Creates a dict for degree program role emojis """ - - tmp_emojis = {} - emojis = {} - degree_program_assignable = self.assignable_roles[0] - - # start with getting all emojis that are used in those roles as a dict - for emoji in self.bot.emojis: - if emoji.name in degree_program_assignable: - tmp_emojis[emoji.name] = emoji - - # bring them in desired order - for key in degree_program_assignable.keys(): - emojis[key] = tmp_emojis.get(key) - - return emojis - - def get_color_emojis(self): - """ Creates a dict for color role emojis """ - - emojis = {} - color_assignable = self.assignable_roles[1] - - # start with getting all emojis that are used in those roles as a dict - for emoji in self.bot.emojis: - if emoji.name in color_assignable: - emojis[emoji.name] = emoji - - return emojis - - def get_special_emojis(self): - """ Creates a dict for special role emojis """ - - return self.assignable_roles[2] - - def get_key(self, role): - """ Get the key for a given role. This role is used for adding or removing a role from a user. """ - - for key, role_name in self.assignable_roles[0].items(): - if role_name == role.name: - return key - - @commands.command(name="add-role") - @commands.is_owner() - async def cmd_add_role(self, ctx, key, role): - """ Add a Role to be assignable (Admin-Command only) """ - - self.assignable_roles[key] = role - roles_file = open(self.roles_file, mode='w') - json.dump(self.assignable_roles, roles_file) - - if key in self.assignable_roles: - await utils.send_dm(ctx.author, f"Rolle {role} wurde hinzugefügt") - else: - await utils.send_dm(ctx.author, f"Fehler beim Hinzufügen der Rolle {role}") - - @commands.command(name="stats") - async def cmd_stats(self, ctx): - """ Sends stats in Chat. """ - - guild = ctx.guild - members = await guild.fetch_members().flatten() - answer = f'' - embed = discord.Embed(title="Statistiken", - description=f'Wir haben aktuell {len(members)} Mitglieder auf diesem Server, verteilt auf folgende Rollen:') - - for role in guild.roles: - if not self.get_key(role): - continue - role_members = role.members - if len(role_members) > 0 and not role.name.startswith("Farbe"): - embed.add_field(name=role.name, value=f'{len(role_members)} Mitglieder', inline=False) - - no_role = 0 - for member in members: - # ToDo Search for study roles only! - if len(member.roles) == 1: - no_role += 1 - - embed.add_field(name="\u200B", value="\u200b", inline=False) - embed.add_field(name="Mitglieder ohne Rolle", value=str(no_role), inline=False) - - await ctx.channel.send(answer, embed=embed) - - @commands.command("update-degree-program") - @commands.check(utils.is_mod) - async def cmd_update_degree_program(self, ctx): - channel = await self.bot.fetch_channel(self.channel_id) - message = await channel.fetch_message(self.degree_program_message_id) - degree_program_emojis = self.get_degree_program_emojis() - - embed = discord.Embed(title="Vergabe von Studiengangs-Rollen", - description="Durch klicken auf die entsprechende Reaktion kannst du dir die damit assoziierte Rolle zuweisen, oder entfernen. Dies funktioniert so, dass ein Klick auf die Reaktion die aktuelle Zuordnung dieser Rolle ändert. Das bedeutet, wenn du die Rolle, die mit <:St:763126549327118366> assoziiert ist, schon hast, aber die Reaktion noch nicht ausgewählt hast, dann wird dir bei einem Klick auf die Reaktion diese Rolle wieder weggenommen. ") - - value = f"" - for key, emoji in degree_program_emojis.items(): - if emoji: - value += f"<:{key}:{emoji.id}> : {self.assignable_roles[0].get(key)}\n" - - embed.add_field(name="Rollen", - value=value, - inline=False) - - await message.edit(content="", embed=embed) - await message.clear_reactions() - - for emoji in degree_program_emojis.values(): - if emoji: - await message.add_reaction(emoji) - - @commands.command("update-color") - @commands.check(utils.is_mod) - async def cmd_update_color(self, ctx): - channel = await self.bot.fetch_channel(self.channel_id) - message = await channel.fetch_message(self.color_message_id) - color_emojis = self.get_color_emojis() - - embed = discord.Embed(title="Vergabe von Farb-Rollen", - description="Durch klicken auf die entsprechende Reaktion kannst du dir die damit assoziierte Rolle zuweisen, oder entfernen. Dies funktioniert so, dass ein Klick auf die Reaktion die aktuelle Zuordnung dieser Rolle ändert. Das bedeutet, wenn du die Rolle, die mit <:FarbeGruen:771451407916204052> assoziiert ist, schon hast, aber die Reaktion noch nicht ausgewählt hast, dann wird dir bei einem Klick auf die Reaktion diese Rolle wieder weggenommen. ") - - await message.edit(content="", embed=embed) - await message.clear_reactions() - - for emoji in color_emojis.values(): - if emoji: - await message.add_reaction(emoji) - - @commands.command("update-special") - @commands.check(utils.is_mod) - async def cmd_update_special(self, ctx): - channel = await self.bot.fetch_channel(self.channel_id) - message = await channel.fetch_message(self.special_message_id) - special_emojis = self.get_special_emojis() - - embed = discord.Embed(title="Vergabe von Spezial-Rollen", - description="Durch klicken auf die entsprechende Reaktion kannst du dir die damit assoziierte Rolle zuweisen, oder entfernen. Dies funktioniert so, dass ein Klick auf die Reaktion die aktuelle Zuordnung dieser Rolle ändert. Das bedeutet, wenn du die Rolle, die mit :exclamation: assoziiert ist, schon hast, aber die Reaktion noch nicht ausgewählt hast, dann wird dir bei einem Klick auf die Reaktion diese Rolle wieder weggenommen. ") - - value = f"" - for emoji, role in special_emojis.items(): - value += f"{emoji} : {role}\n" - - embed.add_field(name="Rollen", - value=value, - inline=False) - - await message.edit(content="", embed=embed) - await message.clear_reactions() - - for emoji in special_emojis.keys(): - await message.add_reaction(emoji) - - @commands.Cog.listener() - async def on_raw_reaction_add(self, payload): - if payload.user_id == self.bot.user.id or payload.message_id not in [self.degree_program_message_id, - self.color_message_id, - self.special_message_id]: - return - - if payload.emoji.name not in self.assignable_roles[0] and payload.emoji.name not in self.assignable_roles[ - 1] and payload.emoji.name not in self.assignable_roles[2]: - return - - role_name = "" - student_role = None - guild = await self.bot.fetch_guild(payload.guild_id) - member = await guild.fetch_member(payload.user_id) - channel = await self.bot.fetch_channel(payload.channel_id) - message = await channel.fetch_message(payload.message_id) - roles = member.roles - - await message.remove_reaction(payload.emoji, member) - - if payload.emoji.name in self.assignable_roles[0]: - role_name = self.assignable_roles[0].get(payload.emoji.name) - student_role = get_student_role(guild) - elif payload.emoji.name in self.assignable_roles[1]: - role_name = self.assignable_roles[1].get(payload.emoji.name) - else: - role_name = self.assignable_roles[2].get(payload.emoji.name) - - for role in roles: - if role.name == role_name: - if not role == student_role: - await member.remove_roles(role) - await utils.send_dm(member, f"Rolle \"{role.name}\" erfolgreich entfernt") - break - else: - guild_roles = guild.roles - - for role in guild_roles: - if role.name == role_name: - await member.add_roles(role) - await utils.send_dm(member, f"Rolle \"{role.name}\" erfolgreich hinzugefügt") - if student_role and not role == student_role: - await member.add_roles(student_role) - - @commands.Cog.listener() - async def on_member_update(self, before, after): - if len(before.roles) != len(after.roles): - roles_before = before.roles - roles_after = after.roles - for role in roles_before: - if role in roles_after: - roles_after.remove(role) - - if len(roles_after) > 0: - if roles_after[0].id == int(os.getenv("DISCORD_STUDENTIN_ROLE")): - channel = await self.bot.fetch_channel(int(os.getenv("DISCORD_GREETING_CHANNEL"))) - await channel.send(f"Herzlich Willkommen <@!{before.id}> im Kreise der Studentinnen :wave:") diff --git a/strolly.py b/strolly.py new file mode 100644 index 0000000000000000000000000000000000000000..ab108e7c72a721736bb6784ed01d454a393ac3ab --- /dev/null +++ b/strolly.py @@ -0,0 +1,38 @@ +import os + +import discord +from discord.ext import commands +from dotenv import load_dotenv + +from bati_cog import BatiCog +from poll_cog import PollCog + +# .env file is necessary in the same directory, that contains several strings. +load_dotenv() +TOKEN = os.getenv('DISCORD_TOKEN') +ACTIVITY = os.getenv('DISCORD_ACTIVITY') +# HELP_FILE = os.getenv('DISCORD_HELP_FILE') + +intents = discord.Intents.default() +intents.members = True +bot = commands.Bot(command_prefix='!', help_command=None, activity=discord.Game(ACTIVITY), intents=intents) +bot.add_cog(PollCog(bot)) +bot.add_cog(BatiCog(bot)) + + +# @bot.command(name="help") +# async def cmd_help(ctx): +# """ Send help message as DM """ +# +# help_file = open(HELP_FILE, mode='r') +# help_dict = json.load(help_file) +# embed = discord.Embed.from_dict(help_dict) +# await utils.send_dm(ctx.author, "", embed=embed) + + +@bot.event +async def on_ready(): + print("Client started!") + + +bot.run(TOKEN) diff --git a/support_cog.py b/support_cog.py deleted file mode 100644 index ebde6b67bc1b9b8319614def1ddf506fc3f37576..0000000000000000000000000000000000000000 --- a/support_cog.py +++ /dev/null @@ -1,28 +0,0 @@ -import io -import os - -import discord -from discord.ext import commands - - -class SupportCog(commands.Cog): - def __init__(self, bot): - self.bot = bot - self.channel_id = int(os.getenv("DISCORD_SUPPORT_CHANNEL")) - - @commands.Cog.listener() - async def on_message(self, message): - if message.author == self.bot.user: - return - - if type(message.channel) is discord.DMChannel: - channel = await self.bot.fetch_channel(self.channel_id) - files = [] - - for attachment in message.attachments: - fp = io.BytesIO() - await attachment.save(fp) - files.append(discord.File(fp, filename=attachment.filename)) - - await channel.send(f"Support Nachricht von <@!{message.author.id}>:") - await channel.send(message.content, files=files) diff --git a/text_commands_cog.py b/text_commands_cog.py deleted file mode 100644 index ca344c6d4fa86774a79532b156222a9b1d90199e..0000000000000000000000000000000000000000 --- a/text_commands_cog.py +++ /dev/null @@ -1,172 +0,0 @@ -import json -import os -import random - -import discord -from discord.ext import commands, tasks - -import utils - -motivation_channels = [566329830682132502, 666937772879249409, 693194667075960875] - - -class TextCommandsCog(commands.Cog): - def __init__(self, bot): - self.bot = bot - self.text_commands = {} - self.cmd_file = os.getenv("DISCORD_TEXT_COMMANDS_FILE") - self.load_text_commands() - self.motivation_loop.start() - - def load_text_commands(self): - """ Loads all appointments from APPOINTMENTS_FILE """ - - text_commands_file = open(self.cmd_file, mode='r') - self.text_commands = json.load(text_commands_file) - - def save_text_commands(self): - text_commands_file = open(self.cmd_file, mode='w') - json.dump(self.text_commands, text_commands_file) - - @commands.Cog.listener(name="on_message") - async def process_text_commands(self, message): - if message.author == self.bot.user: - return - - cmd = message.content.split(" ")[0] - texts = self.text_commands.get(cmd) - - if texts: - await message.channel.send(random.choice(texts)) - - @commands.command(name="add-text-command") - @commands.check(utils.is_mod) - async def cmd_add_text_command(self, ctx, cmd, text): - texts = self.text_commands.get(cmd) - - if texts: - texts.append(text) - else: - self.text_commands[cmd] = [text] - - self.save_text_commands() - - await ctx.send(f"[{cmd}] => [{text}] erfolgreich hinzugefügt.") - - @commands.command(name="text-commands") - @commands.check(utils.is_mod) - async def cmd_text_commands(self, ctx): - answer = f"Text Commands:\n" - - ctr = 0 - for command in self.text_commands: - answer += f"{ctr}: {command}\n" - ctr += 1 - - await ctx.send(answer) - - @commands.command(name="texts") - @commands.check(utils.is_mod) - async def cmd_texts(self, ctx, cmd): - texts = self.text_commands.get(cmd) - answer = f"Für {cmd} hinterlegte Texte: \n" - - for i in range(0, len(texts)): - text = texts[i] - if len(answer) + len(text) > 2000: - await ctx.send(answer) - answer = f"" - - answer += f"{i}: {text}\n" - - await ctx.send(answer) - - @commands.command(name="edit-text") - @commands.check(utils.is_mod) - async def cmd_edit_text(self, ctx, cmd, id, text): - texts = self.text_commands.get(cmd) - - if texts: - i = int(id) - if i < len(texts): - texts[i] = text - await ctx.send(f"Text {i} für Command {cmd} wurde erfolgreich geändert") - self.save_text_commands() - else: - await ctx.send(f"Ungültiger Index") - else: - await ctx.send("Command {cmd} nicht vorhanden!") - - @commands.command(name="remove-text") - @commands.check(utils.is_mod) - async def cmd_remove_text(self, ctx, cmd, id): - texts = self.text_commands.get(cmd) - - if texts: - i = int(id) - if i < len(texts): - del texts[i] - await ctx.send(f"Text {i} für Command {cmd} wurde erfolgreich entfernt") - - if len(texts) == 0: - self.text_commands.pop(cmd) - - self.save_text_commands() - else: - await ctx.send(f"Ungültiger Index") - else: - await ctx.send("Command {cmd} nicht vorhanden!") - - @commands.command(name="remove-text-command") - @commands.check(utils.is_mod) - async def cmd_remove_text_command(self, ctx, cmd): - if cmd in self.text_commands: - self.text_commands.pop(cmd) - await ctx.send(f"Text Command {cmd} wurde erfolgreich entfernt") - self.save_text_commands() - else: - await ctx.send(f"Text Command {cmd} nicht vorhanden") - - @commands.command(name="add-motivation") - async def cmd_add_motivation(self, ctx, text): - mod_channel = await self.bot.fetch_channel(int(os.getenv("DISCORD_MOD_CHANNEL"))) - - embed = discord.Embed(title="Neuer Motivations Text", - description=f"<@!{ctx.author.id}> Möchte folgenden Motivationstext hinzufügen:") - embed.add_field(name="\u200b", value=f"{text}") - - message = await mod_channel.send(embed=embed) - await message.add_reaction("👍") - - async def motivation_approved(self, message): - embed = message.embeds[0] - text = embed.fields[0].value - ctx = await self.bot.get_context(message) - - await self.cmd_add_text_command(ctx, "!motivation", text) - await message.delete() - - @commands.Cog.listener() - async def on_raw_reaction_add(self, payload): - if payload.user_id == self.bot.user.id: - return - - if payload.emoji.name in ["👍"]: - channel = await self.bot.fetch_channel(payload.channel_id) - message = await channel.fetch_message(payload.message_id) - if len(message.embeds) > 0 and message.embeds[0].title == "Neuer Motivations Text": - await self.motivation_approved(message) - - @tasks.loop(hours=1 + (random.random() * 24)) - async def motivation_loop(self): - channel_id = random.choice(motivation_channels) - channel = await self.bot.fetch_channel(channel_id) - texts = self.text_commands.get("!motivation") - - await channel.send(random.choice(texts)) - - self.motivation_loop.change_interval(hours=1 + (random.random() * 12)) - - @motivation_loop.before_loop - async def before_motivation_loop(self): - await self.bot.wait_until_ready() diff --git a/tops_cog.py b/tops_cog.py deleted file mode 100644 index 1c5f54a09f44018cf978361db9e93563d5dad75a..0000000000000000000000000000000000000000 --- a/tops_cog.py +++ /dev/null @@ -1,86 +0,0 @@ -import json -import os -import re - -import discord -from discord.ext import commands - - -class TopsCog(commands.Cog): - def __init__(self, bot): - self.bot = bot - self.tops_file = os.getenv('DISCORD_TOPS_FILE') - self.tops = {} - self.load_tops() - - def load_tops(self): - """ Loads all TOPs from TOPS_FILE """ - - tops_file = open(self.tops_file, mode='r') - self.tops = json.load(tops_file) - - @commands.command(name="add-top") - async def cmd_add_top(self, ctx, top): - """ Add TOP to a channel """ - - channel = ctx.channel - - if str(channel.id) not in self.tops: - self.tops[str(channel.id)] = [] - - channel_tops = self.tops.get(str(channel.id)) - channel_tops.append(top) - - tops_file = open(self.tops_file, mode='w') - json.dump(self.tops, tops_file) - - @commands.command(name="remove-top") - async def cmd_remove_top(self, ctx, top): - """ Remove TOP from a channel """ - channel = ctx.channel - - if not re.match(r'^-?\d+$', top): - await ctx.send("Fehler! Der übergebene Parameter muss eine Zahl sein") - else: - if str(channel.id) in self.tops: - channel_tops = self.tops.get(str(channel.id)) - - if 0 < int(top) <= len(channel_tops): - del channel_tops[int(top) - 1] - - if len(channel_tops) == 0: - self.tops.pop(str(channel.id)) - - tops_file = open(self.tops_file, mode='w') - json.dump(self.tops, tops_file) - - @commands.command(name="clear-tops") - async def cmd_clear_tops(self, ctx): - """ Clear all TOPs from a channel """ - - channel = ctx.channel - - if str(channel.id) in self.tops: - self.tops.pop(str(channel.id)) - tops_file = open(self.tops_file, mode='w') - json.dump(self.tops, tops_file) - - @commands.command(name="tops") - async def cmd_tops(self, ctx): - """ Get all TOPs from a channel """ - - channel = ctx.channel - - embed = discord.Embed(title="Tagesordnungspunkte", - color=19607) - embed.add_field(name="\u200B", value="\u200B", inline=False) - - if str(channel.id) in self.tops: - channel_tops = self.tops.get(str(channel.id)) - - for i in range(0, len(channel_tops)): - embed.add_field(name=f"TOP {i + 1}", value=channel_tops[i], inline=False) - else: - embed.add_field(name="Keine Tagesordnungspunkte vorhanden", value="\u200B", inline=False) - - await ctx.send(embed=embed) diff --git a/welcome_cog.py b/welcome_cog.py deleted file mode 100644 index 7bae2d7ed11163a53e320a43b2bbe1c52fdb3d40..0000000000000000000000000000000000000000 --- a/welcome_cog.py +++ /dev/null @@ -1,53 +0,0 @@ -import os - -import discord -from discord.ext import commands - -import utils - - -class WelcomeCog(commands.Cog): - def __init__(self, bot): - self.bot = bot - self.channel_id = int(os.getenv("DISCORD_WELCOME_CHANNEL")) - self.message_id = int(os.getenv("DISCORD_WELCOME_MSG")) - - @commands.command("update-welcome") - @commands.check(utils.is_mod) - async def cmd_update_welcome(self, ctx): - channel = await self.bot.fetch_channel(self.channel_id) - message = await channel.fetch_message(self.message_id) - - embed = discord.Embed(title="Herzlich Willkommen auf dem Discord von Studierenden für Studierende.", - description="Disclaimer: Das hier ist kein offizieller Kanal der Fernuni. Hier findet auch keine offizielle Betreuung durch die Fernuni statt. Dieser Discord dient zum Austausch unter Studierenden über einzelne Kurse, um sich gegenseitig helfen zu können, aber auch um über andere Themen in einen Austausch zu treten. Es soll KEIN Ersatz für die Kanäle der Lehrgebiete sein, wie die Newsgroups, Moodle-Foren und was es noch so gibt. Der Discord soll die Möglichkeit bieten, feste Lerngruppen zu finden und sich in diesen gegenseitig zu helfen und zu treffen. Zudem soll er durch den Austausch in den Kanälen auch eine Art flexible Lerngruppe zu einzelnen Kursen ermöglichen. Daher ist unser Apell an euch: Nutzt bitte auch die Betreuungsangebote der entsprechenden Kurse, in die ihr eingeschrieben seid. ") - embed.set_thumbnail( - url="https://cdn.discordapp.com/avatars/697842294279241749/c7d3063f39d33862e9b950f72ab71165.webp") - embed.add_field(name="Lerngruppen", - value="Wenn ihr eine feste Lerngruppe gründen möchtet, dann könnt ihr dafür gerne einen eigenen Textchannel bekommen. Sagt einfach bescheid, dann kann dieser erstellt werden. Ihr könnt dann auch entscheiden, ob nur ihr Zugang zu diesem Channel haben möchtet, oder ob dieser für alle zugänglich sein soll.", - inline=False) - - embed.add_field(name="Vorstellung", - value=f"Es gibt einen <#{os.getenv('DISCORD_VORSTELLUNGSCHANNEL')}>. Wir würden uns freuen, wenn ihr euch kurz vorstellen würdet. So ist es möglich, Gemeinsamkeiten zu entdecken und man weiß ungefähr, mit wem man es zu tun hat. Hier soll auch gar nicht der komplette Lebenslauf stehen, schreibt einfach das, was ihr so über euch mitteilen möchtet.", - inline=False) - - embed.add_field(name="Regeln", - value="Es gibt hier auch ein paar, wenige Regeln, an die wir uns alle halten wollen. Diese findet ihr hier https://discordapp.com/channels/353315134678106113/697729059173433344/709475694157234198", - inline=False) - - embed.add_field(name="Nachrichten anpinnen", - value="Wenn ihr Nachrichten in einem Channel anpinnen möchtet, könnt ihr dafür unseren Bot verwenden. Setzt einfach eine :pushpin: Reaktion auf die entsprechende Nachricht und der pin-bot erledigt den Rest.", - inline=False) - - embed.add_field(name="Rollen", - value=f"Es gibt verschiedene Rollen hier. Derzeit sind das zum einen Rollen zu den verschiedenen Studiengängen unserer Fakultät (sowie allgemeinere Rollen), oder Farbrollen. Wirf doch mal einen Blick in <#{os.getenv('DISCORD_ROLLEN_CHANNEL')}>", - inline=False) - - await message.edit(content="", embed=embed) - - @commands.Cog.listener() - async def on_member_join(self, member): - await utils.send_dm(member, - f"Herzlich Willkommen auf diesem Discord-Server. Wir hoffen sehr, dass du dich hier wohl fühlst. Alle notwendigen Informationen, die du für den Einstieg brauchst, findest du in <#{self.channel_id}>\n" - f"Wir würden uns sehr freuen, wenn du dich in <#{os.getenv('DISCORD_VORSTELLUNGSCHANNEL')}> allen kurz vorstellen würdest. Es gibt nicht viele Regeln zu beachten, doch die Regeln, die aufgestellt sind, findest du hier: https://discordapp.com/channels/353315134678106113/697729059173433344/709475694157234198 .\n" - f"Dir dürfte außerdem schon aufgefallen sein, dass du derzeit nur drei Channels siehst. Wir haben natürlich mehr als diese drei. Um die restlichen Channels angezeigt zu bekommen, müsstest du dir lediglich eine Studiengangs-Rolle im Channel <#{os.getenv('DISCORD_ROLLEN_CHANNEL')}> zuweisen. Wir würden uns natürlich am meisten darüber freuen, wenn du dir die Rolle, die zu deinem Studiengang passt zuweisen würdest, falls du das aber nicht möchtest, ist mindestens die Rolle Studentin notwendig.\n\n" - f"Abschließend bleibt mir nur noch, dir hier viel Spaß zu wünschen, und falls du bei etwas hilfe brauchen solltest, schreib mir doch eine private Nachricht, das Moderatoren Team wird sich dann darum kümmern.")