Test Search Func

This commit is contained in:
2023-03-17 21:31:40 -04:00
parent 81bd2e43ed
commit 9238babde7
2 changed files with 26 additions and 7 deletions

View File

@@ -3,9 +3,25 @@ from nextcord.ext import commands
from typing import Optional
import asyncio
import os
import requests as req
bot = commands.Bot()
user = os.environ["OPENSEARCH_USER"]
pswd = os.environ["OPENSEARCH_PASS"]
async def search(txt):
ses = req.Session()
ses.auth = (user, pswd)
resp = ses.get("https://scihub.copernicus.eu/dhus/search", params = {
'q': txt
})
return resp
@bot.event
async def on_ready():
print(f'We have logged in as {bot.user}')
@@ -18,10 +34,13 @@ async def summarize(
):
await interaction.response.defer(ephemeral=False, with_message=True)
await asyncio.sleep(5)
await interaction.followup.send(f"I'll summarize {article} for you {interaction.user}")
print("Will summarize article.")
resp = search(article)
interaction.followup.send("""Search Response:
```
{resp.text[:1000]}
```
""")
def main():
# TODO: Import bot token from env