Created
October 7, 2021 18:05
-
-
Save harsh183/46ad6e694c8f32ae694e5fc7a8acadd2 to your computer and use it in GitHub Desktop.
DRES chatbot for looking up resources. Powered by google and discord.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from discord.ext import commands | |
| from googlesearch import search | |
| bot = commands.Bot(command_prefix='!') | |
| @bot.command(name="uiuc", help="Find a UIUC specific resources") | |
| async def uiuc(ctx, *, question): | |
| # breakpoint() | |
| search_text = f"UIUC {question}" | |
| await ctx.send("You've come to the right place for help! :slight_smile:") | |
| possible_links = search(search_text, num_results=1) # the num results isn't the array length for reasons | |
| unique_links = set(possible_links) | |
| await ctx.send("I looked around and I found a few links that might be a good starting point :thinking:") | |
| for link in unique_links: | |
| await ctx.send(link) | |
| with open("BOT_TOKEN.txt", "r") as token_file: | |
| TOKEN = token_file.read() | |
| print("Token file read") | |
| bot.run(TOKEN) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| discord.py | |
| googlesearch-python |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment


MIT License
Setup
Assuming working python
BOT_TOKEN.txtpip install -r requirements.txtpython bot.py