From 5232a4458acda275dd65147e1e470ed76d189cc7 Mon Sep 17 00:00:00 2001 From: Mikk155 Date: Sat, 12 Oct 2024 09:01:31 -0300 Subject: [PATCH] feliz jueves, hoy es viernes --- plugins.json | 16 ++++++++ plugins/feliz_jueves.py | 78 ++++++++++++++++++++++++++++++++++++++ plugins/hoy_es_viernes.py | 80 +++++++++++++++++++++++++++++++++++++++ sentences.json | 24 ++++++------ 4 files changed, 186 insertions(+), 12 deletions(-) create mode 100644 plugins/feliz_jueves.py create mode 100644 plugins/hoy_es_viernes.py diff --git a/plugins.json b/plugins.json index 5c72268..fc4bf93 100644 --- a/plugins.json +++ b/plugins.json @@ -43,6 +43,22 @@ "Plugin Name": "Electrocute a member", "Description": "Sends a member to mimir electrocuting him" }, + { + "File Name": "feliz_jueves.py", + "Plugin Name": "Wish a happy thursday", + "Hooks": + [ + "on_daily" + ] + }, + { + "File Name": "hoy_es_viernes.py", + "Plugin Name": "Reminder when friday", + "Hooks": + [ + "on_daily" + ] + }, { "File Name": "fix_embeeds.py", "Plugin Name": "Fix X and Instagram", diff --git a/plugins/feliz_jueves.py b/plugins/feliz_jueves.py new file mode 100644 index 0000000..0602f74 --- /dev/null +++ b/plugins/feliz_jueves.py @@ -0,0 +1,78 @@ +""" +The MIT License (MIT) + +Copyright (c) 2024 Mikk155 + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. +""" + +from plugins.main import * + +@bot.tree.command() +async def cfg_felizjueves( interaction: discord.Interaction, channel: discord.TextChannel ): + """Configure a channel to get feliz jueves every thursday""" + + try: + + if interaction.user.guild_permissions.administrator: + + cache = gpGlobals.cache.get(); + + cache[ str(interaction.guild_id) ] = channel.id; + + await interaction.response.send_message( AllocString( "feliz_jueves.set" , [ channel.name ], interaction.guild_id ) ); + + else: + + await interaction.response.send_message( AllocString( "no.permission", [ "administrator" ], interaction.guild_id ) ); + + except Exception as e: + + await interaction.response.send_message( f"Exception: {e}" ); + +async def on_daily(): + + date = datetime.now(); + + if date.isoweekday() != 4: + return Hook.Continue(); + + randoms = [ + "https://youtu.be/BvtUSsok4JA?si=ybKl3D8CX7aI5KAq", + "https://youtu.be/J9PHO6ZgW0Q?si=ID2WRe8Z9_PShFAV", + "https://www.youtube.com/watch?v=M1FcoVImTwk", + "https://www.youtube.com/watch?v=vMkMi3DV1tM", + "https://youtu.be/2gBFVGgknNg?si=tmWmrb-VRhMfWDja", + "https://youtu.be/E51pvhXgrHI?si=nfMXPlUuY6ER2WUd" + ]; + + # Pick a random one in 20% chance + url = randoms[ random.randint( 0, len( randoms ) - 1 ) ] if random.randint( 0, 100 ) > 80 else 'https://youtu.be/K0R9PIWiOuM?si=Gq-uORr1nGLnN6Ww'; + + cache = gpGlobals.cache.get(); + + for guild, channel_id in cache.items(): + + channel = bot.get_channel( channel_id ); + + if not channel: + cache.pop( guild, '' ); # Pop out + continue; + + await channel.send( url ); diff --git a/plugins/hoy_es_viernes.py b/plugins/hoy_es_viernes.py new file mode 100644 index 0000000..ec9eea1 --- /dev/null +++ b/plugins/hoy_es_viernes.py @@ -0,0 +1,80 @@ +""" +The MIT License (MIT) + +Copyright (c) 2024 Mikk155 + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. +""" + +from plugins.main import * + +@bot.tree.command() +async def cfg_hoyesviernes( interaction: discord.Interaction, channel: discord.TextChannel ): + """Configure a channel to get hoy es viernes""" + + try: + + if interaction.user.guild_permissions.administrator: + + cache = gpGlobals.cache.get(); + + cache[ str(interaction.guild_id) ] = channel.id; + + await interaction.response.send_message( AllocString( "viernes.set" , [ channel.name ], interaction.guild_id ) ); + + else: + + await interaction.response.send_message( AllocString( "no.permission", [ "administrator" ], interaction.guild_id ) ); + + except Exception as e: + + await interaction.response.send_message( f"Exception: {e}" ); + +async def on_daily(): + + date = datetime.now(); + + if date.isoweekday() != 5: + return Hook.Continue(); + + randoms = [ + "https://youtu.be/aSUuw5HY9eY?si=7ysIS1UeXbKyCk3V", + "https://youtu.be/_IN9q9tdHkQ?si=nMiOQm1oyUyyOOQl", + "https://youtu.be/KRaZAStC-Tc?si=B2eDnRz5GWDr4hhq", + "https://youtu.be/FkjQcbX-Ngk?si=fbK2PFv54QNBZp3k", + "https://youtu.be/teRJKOPSRts?si=6IWnZ5OKC8i6xwWW", + "https://youtu.be/PreudA3i6LI?si=YQNWiDAR2dIHzJhy", + "https://youtu.be/ui7hcmy6Dsk?si=qnLRIGrjl1_uqXAx", + "https://youtu.be/WLAlRCi8nz0?si=Q9HAd9JIl3IWvOcI", + "https://youtu.be/HE1K1iUsNSo?si=Xg6wBDdEVlGs9x1O" + ]; + + url = randoms[ random.randint( 0, len( randoms ) - 1 ) ]; + + cache = gpGlobals.cache.get(); + + for guild, channel_id in cache.items(): + + channel = bot.get_channel( channel_id ); + + if not channel: + cache.pop( guild, '' ); # Pop out + continue; + + await channel.send( url ); diff --git a/sentences.json b/sentences.json index 9e0906a..5612e5f 100644 --- a/sentences.json +++ b/sentences.json @@ -137,19 +137,19 @@ "spanish": "De ``{}``\nYo eligo ``{}``" }, + // feliz_jueves.py + "feliz_jueves.set": + { + "english": "I'll wish you all a happy Thursday in {}", + "spanish": "Ahora les deseare un feliz jueves en {}" + }, - - - - - - - - - - - - + // hoy_es_viernes.py + "viernes.set": + { + "english": "I'll remind all of you in {} when it's friday.", + "spanish": "Ahora les recordare en {} cuando sea viernes." + }, "EOF": true } \ No newline at end of file