iterate values of the dict items

This commit is contained in:
deflax 2024-01-16 19:11:09 +02:00
parent d93992b198
commit c77c91dbe1

View file

@ -45,17 +45,15 @@ async def epg(ctx):
response.raise_for_status() response.raise_for_status()
content = response.json() content = response.json()
await ctx.channel.send('epg:') await ctx.channel.send('epg:')
await ctx.channel.send(type(content))
await ctx.channel.send(f'`{content}`')
if content != {}: if content != {}:
for item in content: for key, value in content.items():
if item['start_at'] == 'now' or item['start_at'] == 'never': if value['start_at'] == 'now' or value['start_at'] == 'never':
await ctx.channel.send('x') await ctx.channel.send('x')
continue continue
else: else:
await ctx.channel.send('x') await ctx.channel.send('x')
await ctx.channel.send(item['start_at']) await ctx.channel.send(value['start_at'])
else: else:
await ctx.channel.send('Empty database!') await ctx.channel.send('Empty database!')
except Exception as e: except Exception as e:
@ -70,6 +68,10 @@ async def start_task(ctx):
# Schedule a task to run every 5 seconds # Schedule a task to run every 5 seconds
scheduler.add_job(func=my_task, id='my_task_id') scheduler.add_job(func=my_task, id='my_task_id')
#scheduler.add_job(func=tick, id='tick_id', args=(ctx)) #scheduler.add_job(func=tick, id='tick_id', args=(ctx))
#channel = bot.get_channel(channel_id)
#if channel:
# # Send the message to the specified channel
# await channel.send(message)
@bot.command(name='show') @bot.command(name='show')
async def show_task(ctx): async def show_task(ctx):