output "santization" and ping list fix
This commit is contained in:
parent
a04fe9e7a7
commit
d9c157cfab
20
bot.py
20
bot.py
|
@ -60,7 +60,13 @@ def remove_ping(term, user_id):
|
||||||
elif user_id not in ping_terms[term]:
|
elif user_id not in ping_terms[term]:
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
ping_terms[term].remove(user_id)
|
#if there is only one remaining person in the ping term list, delete the whole term
|
||||||
|
if len(ping_terms[term]) == 1 and ping_terms[term][0] == user_id:
|
||||||
|
del ping_terms[term]
|
||||||
|
#if there is more than on person in the ping term list, delete only that user_id
|
||||||
|
else:
|
||||||
|
ping_terms[term].remove(user_id)
|
||||||
|
|
||||||
config["ping_terms"] = ping_terms
|
config["ping_terms"] = ping_terms
|
||||||
save_config("config.json", config)
|
save_config("config.json", config)
|
||||||
return True
|
return True
|
||||||
|
@ -225,28 +231,28 @@ async def myLoop():
|
||||||
@bot.slash_command(description="Pings you when auction name contains the given term")
|
@bot.slash_command(description="Pings you when auction name contains the given term")
|
||||||
async def ping_me(interaction: nextcord.Interaction, term: str):
|
async def ping_me(interaction: nextcord.Interaction, term: str):
|
||||||
if add_ping(term, interaction.user.id):
|
if add_ping(term, interaction.user.id):
|
||||||
await interaction.response.send_message(f"Success! You will be pinged for {term}", ephemeral=False)
|
await interaction.response.send_message(f"Success! You will be pinged for `{term}`", ephemeral=False)
|
||||||
else:
|
else:
|
||||||
pings = get_user_pings(interaction.user.id)
|
pings = get_user_pings(interaction.user.id)
|
||||||
if len(pings) > 0:
|
if len(pings) > 0:
|
||||||
await interaction.response.send_message(f"Failed to add {term}. You are pinged for {', '.join(pings)}",
|
await interaction.response.send_message(f"Failed to add `{term}`. You are pinged for `{', '.join(pings)}`",
|
||||||
ephemeral=True)
|
ephemeral=True)
|
||||||
else:
|
else:
|
||||||
await interaction.response.send_message(f"Failed to add {term}. You are not pinged for anything",
|
await interaction.response.send_message(f"Failed to add `{term}`. You are not pinged for anything",
|
||||||
ephemeral=True)
|
ephemeral=True)
|
||||||
|
|
||||||
|
|
||||||
@bot.slash_command(description="No longer pings you when auction name contains the given term")
|
@bot.slash_command(description="No longer pings you when auction name contains the given term")
|
||||||
async def unping_me(interaction: nextcord.Interaction, term: str):
|
async def unping_me(interaction: nextcord.Interaction, term: str):
|
||||||
if remove_ping(term, interaction.user.id):
|
if remove_ping(term, interaction.user.id):
|
||||||
await interaction.response.send_message(f"Success! You will no longer be pinged for {term}", ephemeral=False)
|
await interaction.response.send_message(f"Success! You will no longer be pinged for `{term}`", ephemeral=False)
|
||||||
else:
|
else:
|
||||||
pings = get_user_pings(interaction.user.id)
|
pings = get_user_pings(interaction.user.id)
|
||||||
if len(pings) > 0:
|
if len(pings) > 0:
|
||||||
await interaction.response.send_message(f"Failed to remove {term}. You are pinged for {', '.join(pings)}",
|
await interaction.response.send_message(f"Failed to remove `{term}`. You are pinged for `{', '.join(pings)}`",
|
||||||
ephemeral=True)
|
ephemeral=True)
|
||||||
else:
|
else:
|
||||||
await interaction.response.send_message(f"Failed to remove {term}. You are not pinged for anything",
|
await interaction.response.send_message(f"Failed to remove `{term}`. You are not pinged for anything",
|
||||||
ephemeral=True)
|
ephemeral=True)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue