text blocking and fixed accidental product_query showing up in the wrong places

This commit is contained in:
crate 2024-10-01 04:27:32 +00:00
parent ec1fd506d0
commit 9faafe70a6

View File

@ -174,7 +174,7 @@ async def generate_image(prompt):
image_url = response.data[0].url image_url = response.data[0].url
return image_url return image_url
except openai.BadRequestError as e: except openai.BadRequestError as e:
return f"`GarfBot Error: ({e.status_code}) - Your request was rejected as a product_query of our safety system.`" return f"`GarfBot Error: ({e.status_code}) - Your request was rejected as a result of our safety system.`"
except openai.InternalServerError as e: except openai.InternalServerError as e:
logger.error(e) logger.error(e)
print(e, flush=True) print(e, flush=True)
@ -254,7 +254,7 @@ async def on_message(message):
await message.channel.send(rejection) await message.channel.send(rejection)
else: else:
result = subprocess.run(['ping', '-c', '4', target], capture_output=True, text=True) result = subprocess.run(['ping', '-c', '4', target], capture_output=True, text=True)
await message.channel.send(f"`Ping result for {target}: {result.stdout}`") await message.channel.send(f"`Ping result for {target}:`\n```\n{result.stdout}\n```")
except Exception as e: except Exception as e:
await message.channel.send(f"`GarfBot Error: {str(e)}`") await message.channel.send(f"`GarfBot Error: {str(e)}`")
@ -270,7 +270,7 @@ async def on_message(message):
await message.channel.send(rejection) await message.channel.send(rejection)
else: else:
result = subprocess.run(['nslookup', target], capture_output=True, text=True) result = subprocess.run(['nslookup', target], capture_output=True, text=True)
await message.channel.send(f"`NSLookup result for {target}: {result.stdout}`") await message.channel.send(f"`NSLookup result for {target}:`\n```\n{result.stdout}\n```")
except Exception as e: except Exception as e:
await message.channel.send(f"`GarfBot Error: {str(e)}`") await message.channel.send(f"`GarfBot Error: {str(e)}`")
@ -287,7 +287,7 @@ async def on_message(message):
else: else:
await message.channel.send(f"`Scanning {target}...`") await message.channel.send(f"`Scanning {target}...`")
result = subprocess.run(['nmap', '-Pn', '-O', '-v', target], capture_output=True, text=True) result = subprocess.run(['nmap', '-Pn', '-O', '-v', target], capture_output=True, text=True)
await message.channel.send(f"`Ping result for {target}: {result.stdout}`") await message.channel.send(f"`Ping result for {target}:`\n```\n{result.stdout}\n```")
except Exception as e: except Exception as e:
await message.channel.send(f"`GarfBot Error: {str(e)}`") await message.channel.send(f"`GarfBot Error: {str(e)}`")
@ -397,7 +397,7 @@ async def send_gif(message, search_term):
r = requests.get(f"https://tenor.googleapis.com/v2/search?q={search_term}&key={gapikey}&client_key={ckey}&limit={lmt}") r = requests.get(f"https://tenor.googleapis.com/v2/search?q={search_term}&key={gapikey}&client_key={ckey}&limit={lmt}")
if r.status_code == 200: if r.status_code == 200:
top_50gifs = json.loads(r.content) top_50gifs = json.loads(r.content)
gif_url = random.choice(top_50gifs["product_querys"])["itemurl"] gif_url = random.choice(top_50gifs["results"])["itemurl"]
print(gif_url) print(gif_url)
try: try:
await message.channel.send(gif_url) await message.channel.send(gif_url)