pasar de secrets a variables de entorno
Some checks failed
Update Bot / restart-bot (push) Has been cancelled
Update Bot / deploy-via-sftp (push) Has been cancelled

This commit is contained in:
2025-10-27 09:18:38 +01:00
parent 2bd0b4152a
commit c0ff2a6819

10
main.py
View File

@@ -32,7 +32,7 @@ async def on_ready():
async def send_log(msg): #Mandar log
channel = bot.get_channel(secrets.IDcanalLogs) #Canal al que se envía el log
channel = bot.get_channel(os.environ["IDcanalLogs"]) #Canal al que se envía el log
await channel.send(msg)
@@ -41,7 +41,7 @@ async def mandar_noticia():
global ultimaurl
try:
channel = bot.get_channel(secrets.IDcanalNoticias) #Canal al que se envía el mensaje
channel = bot.get_channel(os.environ["IDcanalNoticias"]) #Canal al que se envía el mensaje
r = requests.get(url)
xml = xmltodict.parse(r.text)
@@ -54,7 +54,7 @@ async def mandar_noticia():
nuevas.append(loc)
if nuevas: #Si el array no está vacío
await channel.send(f"Atención <@&{secrets.IDrol}> hay nuevas noticias:") #Luego hay que cambiar el rol
await channel.send(f"Atención <@&{os.environ['IDRol']}> hay nuevas noticias:") #Luego hay que cambiar el rol
for loc in reversed(nuevas): #Recorre el array hacia atrás para mandarlas en orden.
await channel.send(f"\n{loc}")
ultimaurl = urls[0] #Actualizamos la url vieja
@@ -64,7 +64,7 @@ async def mandar_noticia():
@bot.command()
async def noticias(ctx):
rol = ctx.guild.get_role(secrets.IDrol)
rol = ctx.guild.get_role(os.environ["IDRol"])
user = ctx.author
if rol in user.roles:
@@ -97,4 +97,4 @@ async def noticias(ctx):
if __name__ == '__main__':
bot.run(secrets.TOKEN)
bot.run(os.environ["TOKEN"])