This commit is contained in:
2023-03-17 22:16:34 -04:00
parent 4acdca9c43
commit ea21f8bb69
4 changed files with 50 additions and 7 deletions

View File

@@ -4,6 +4,7 @@ from typing import Optional
import asyncio
import os
import requests as req
from bs4 import BeautifulSoup as soup
bot = commands.Bot()
@@ -12,7 +13,16 @@ async def search(txt):
'request':txt
})
return resp
doc = soup(resp.text, 'html_parser')
if 'not found' in doc.title:
return None
ref = doc.find("div", {'id': 'citation'}).get_text()
return {
'ref': ref
}
@bot.event
async def on_ready():
@@ -28,11 +38,11 @@ async def summarize(
resp = await search(article)
await interaction.followup.send(f"""Search Response:
```
{resp.text[:1000]}
```
""")
if resp is None:
await interaction.followup.send(f"Unable to find article: {article}")
return
await interaction.followup.send(f"Article Found: \n{resp['ref']}")
def main():
# TODO: Import bot token from env