Skip to content

Commit

Permalink
feliz jueves, hoy es viernes
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikk155 committed Oct 12, 2024
1 parent a69e8ff commit 5232a44
Show file tree
Hide file tree
Showing 4 changed files with 186 additions and 12 deletions.
16 changes: 16 additions & 0 deletions plugins.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
78 changes: 78 additions & 0 deletions plugins/feliz_jueves.py
Original file line number Diff line number Diff line change
@@ -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 );
80 changes: 80 additions & 0 deletions plugins/hoy_es_viernes.py
Original file line number Diff line number Diff line change
@@ -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 );
24 changes: 12 additions & 12 deletions sentences.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 5232a44

Please sign in to comment.