mirror of
https://github.com/polyjitter/searchbot-discord.git
synced 2024-08-14 22:46:55 +00:00
Vote, config-example, search changes
- Added vote command to botlist cog - Added aliases for categories to search cog - Added blank tokens to config example
This commit is contained in:
parent
d91d092a9d
commit
7943cd930c
5 changed files with 128 additions and 18 deletions
|
@ -1,10 +1,15 @@
|
|||
{
|
||||
"VERSION": "1.3 redist",
|
||||
"DESCRIPTION": "a minimalist search utility bot for discord, designed by taciturasa.",
|
||||
"VERSION": "x.x type",
|
||||
"DESCRIPTION": "a basic base for bots, designed by taciturasa.",
|
||||
"MAINTENANCE": false,
|
||||
"TOKEN": "",
|
||||
"PREFIX": ["search!"],
|
||||
"DBL": "",
|
||||
"DBOTS": "",
|
||||
"BOD": "",
|
||||
"DBLCOM": "",
|
||||
"PREFIX": ["basicbot!"],
|
||||
"PREFIXLESS_DMS": true,
|
||||
"PERMS": 378944,
|
||||
"MENTION_ASSIST": true,
|
||||
"PERMS": null,
|
||||
"BLOCKED": []
|
||||
}
|
Binary file not shown.
|
@ -78,7 +78,27 @@ class Botlist(commands.Cog):
|
|||
# Finishing up
|
||||
return responses
|
||||
|
||||
@commands.command(aliases=['review'])
|
||||
async def vote(self, ctx):
|
||||
"""Review and vote for us on various botlists!"""
|
||||
|
||||
msg = (
|
||||
"**Thank you for wanting to help us out!**\n"
|
||||
"You can find us on the following lists:\n\n"
|
||||
)
|
||||
if self.dbots_token != '':
|
||||
msg += f"_bots.discord.gg_ <https://bots.discord.gg/bots/{self.bot.user.id}/>\n"
|
||||
if self.bod_token != '':
|
||||
msg += f"_bots.ondiscord.xyz_ <https://bots.ondiscord.xyz/bots/{self.bot.user.id}/>\n"
|
||||
if self.dblcom_token != '':
|
||||
msg += f"_discordbotlist.com_ <https://discordbotlist.com/bots/{self.bot.user.id}/>\n"
|
||||
if self.dbl_token != '':
|
||||
msg += f"_top.gg_ <https://top.gg/bot/{self.bot.user.id}/>\n"
|
||||
|
||||
await ctx.send(msg)
|
||||
|
||||
@commands.command()
|
||||
@commands.is_owner()
|
||||
async def listupdate(self, ctx):
|
||||
"""Updates statistics on botlists."""
|
||||
|
||||
|
@ -89,12 +109,11 @@ class Botlist(commands.Cog):
|
|||
|
||||
@tasks.loop(minutes=15.0)
|
||||
async def update_stats(self):
|
||||
"""Automatically updates statistics every 15 minutes."""
|
||||
|
||||
responses = await self._update_logic()
|
||||
print(responses)
|
||||
|
||||
async def cog_check(self, ctx):
|
||||
return (ctx.author.id == self.bot.appinfo.owner.id)
|
||||
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(Botlist(bot))
|
||||
|
|
|
@ -72,9 +72,12 @@ class Core(commands.Cog):
|
|||
msg = (
|
||||
"**Thanks for checking me out!**\n\n"
|
||||
"Use the following link to add me:\n"
|
||||
f"*<https://discordapp.com/oauth2/authorize?client_id={self.bot.user.id}&permissions={self.bot.config['PERMS']}&scope=bot>*"
|
||||
f"*<https://discordapp.com/oauth2/authorize?client_id={self.bot.user.id}&scope=bot>*"
|
||||
)
|
||||
|
||||
if self.bot.config['PERMS'] is not None:
|
||||
msg += f"&permissions={self.bot.config['PERMS']}"
|
||||
|
||||
await ctx.send(msg)
|
||||
|
||||
@commands.command()
|
||||
|
|
|
@ -21,6 +21,7 @@ class Search(commands.Cog):
|
|||
async def _search_logic(self, query: str, is_nsfw: bool = False, category: str = None):
|
||||
"""Provides search logic for all search commands."""
|
||||
|
||||
# NSFW Filtering
|
||||
# WARNING - This list includes slurs.
|
||||
nono_words = [
|
||||
'tranny', 'faggot', 'fag',
|
||||
|
@ -32,7 +33,9 @@ class Search(commands.Cog):
|
|||
'bdsm'
|
||||
]
|
||||
nono_sites = [
|
||||
'xvideos', 'pornhub'
|
||||
'xvideos', 'pornhub',
|
||||
'xhamster', 'xnxx',
|
||||
'youporn'
|
||||
]
|
||||
|
||||
if not is_nsfw:
|
||||
|
@ -52,21 +55,29 @@ class Search(commands.Cog):
|
|||
print(f"Attempting to use {instance}")
|
||||
|
||||
# Error Template
|
||||
error_msg = ("**An error occured!**\n\n"
|
||||
f"There was a problem with `{instance}`. Please try again later.\n"
|
||||
f"_If problems with this instance persist, contact`{self.bot.appinfo.owner}` to have it removed._")
|
||||
error_msg = (
|
||||
"**An error occured!**\n\n"
|
||||
f"There was a problem with `{instance}`. Please try again later.\n"
|
||||
f"_If problems with this instance persist, contact`{self.bot.appinfo.owner}` to have it removed._"
|
||||
)
|
||||
|
||||
# Create the URL to make an API call to
|
||||
call = f'{instance}/search?q={query}&format=json&language=en-US'
|
||||
|
||||
# If a type is provided, add that type to the call URL
|
||||
if category:
|
||||
call += f'&category={category}'
|
||||
call += f'&categories={category}'
|
||||
|
||||
if is_nsfw:
|
||||
call += f'&safesearch=0'
|
||||
call += '&safesearch=0'
|
||||
else:
|
||||
call += f'&safesearch=1'
|
||||
call += '&safesearch=1'
|
||||
|
||||
# Figure out engines for different categories to get decent results.
|
||||
if category == 'videos':
|
||||
call += '&engines=bing+videos,google+videos'
|
||||
|
||||
print(call)
|
||||
|
||||
# Make said API call
|
||||
try:
|
||||
|
@ -117,7 +128,7 @@ class Search(commands.Cog):
|
|||
return msg
|
||||
|
||||
async def _instance_check(self, instance, info):
|
||||
'''Checks the quality of an instance.'''
|
||||
"""Checks the quality of an instance."""
|
||||
|
||||
# Makes sure proper values exist
|
||||
if 'error' in info:
|
||||
|
@ -154,7 +165,7 @@ class Search(commands.Cog):
|
|||
|
||||
@commands.command()
|
||||
async def search(self, ctx, *, query: str):
|
||||
"""Search online for results."""
|
||||
"""Search online for general results."""
|
||||
|
||||
# Logging
|
||||
print(f"\n\nNEW CALL: {ctx.author} from {ctx.guild}.\n")
|
||||
|
@ -164,10 +175,82 @@ class Search(commands.Cog):
|
|||
msg = await self._search_logic(query, ctx.channel.is_nsfw())
|
||||
await ctx.send(msg)
|
||||
|
||||
@commands.command(aliases=['video'])
|
||||
async def videos(self, ctx, *, query: str):
|
||||
"""Search online for videos."""
|
||||
|
||||
# Logging
|
||||
print(f"\n\nNEW VIDEO CALL: {ctx.author} from {ctx.guild}.\n")
|
||||
|
||||
# Handling
|
||||
async with ctx.typing():
|
||||
msg = await self._search_logic(query, ctx.channel.is_nsfw(), 'videos')
|
||||
await ctx.send(msg)
|
||||
|
||||
@commands.command()
|
||||
async def music(self, ctx, *, query: str):
|
||||
"""Search online for music."""
|
||||
|
||||
# Logging
|
||||
print(f"\n\nNEW MUSIC CALL: {ctx.author} from {ctx.guild}.\n")
|
||||
|
||||
# Handling
|
||||
async with ctx.typing():
|
||||
msg = await self._search_logic(query, ctx.channel.is_nsfw(), 'music')
|
||||
await ctx.send(msg)
|
||||
|
||||
@commands.command(aliases=['file'])
|
||||
async def files(self, ctx, *, query: str):
|
||||
"""Search online for files."""
|
||||
|
||||
# Logging
|
||||
print(f"\n\nNEW FILES CALL: {ctx.author} from {ctx.guild}.\n")
|
||||
|
||||
# Handling
|
||||
async with ctx.typing():
|
||||
msg = await self._search_logic(query, ctx.channel.is_nsfw(), 'files')
|
||||
await ctx.send(msg)
|
||||
|
||||
@commands.command(aliases=['image'])
|
||||
async def images(self, ctx, *, query: str):
|
||||
"""Search online for images."""
|
||||
|
||||
# Logging
|
||||
print(f"\n\nNEW IMAGES CALL: {ctx.author} from {ctx.guild}.\n")
|
||||
|
||||
# Handling
|
||||
async with ctx.typing():
|
||||
msg = await self._search_logic(query, ctx.channel.is_nsfw(), 'images')
|
||||
await ctx.send(msg)
|
||||
|
||||
@commands.command()
|
||||
async def it(self, ctx, *, query: str):
|
||||
"""Search online for IT-related information."""
|
||||
|
||||
# Logging
|
||||
print(f"\n\nNEW IT CALL: {ctx.author} from {ctx.guild}.\n")
|
||||
|
||||
# Handling
|
||||
async with ctx.typing():
|
||||
msg = await self._search_logic(query, ctx.channel.is_nsfw(), 'it')
|
||||
await ctx.send(msg)
|
||||
|
||||
@commands.command(aliases=['map'])
|
||||
async def maps(self, ctx, *, query: str):
|
||||
"""Search online for map information."""
|
||||
|
||||
# Logging
|
||||
print(f"\n\nNEW MAP CALL: {ctx.author} from {ctx.guild}.\n")
|
||||
|
||||
# Handling
|
||||
async with ctx.typing():
|
||||
msg = await self._search_logic(query, ctx.channel.is_nsfw(), 'map')
|
||||
await ctx.send(msg)
|
||||
|
||||
@commands.command()
|
||||
@commands.is_owner()
|
||||
async def rejson(self, ctx):
|
||||
'''Refreshes the list of instances for searx.'''
|
||||
"""Refreshes the list of instances for searx."""
|
||||
|
||||
msg = await ctx.send('<a:updating:403035325242540032> Refreshing instance list...\n\n'
|
||||
'(Due to extensive quality checks, this may take a bit.)')
|
||||
|
|
Loading…
Reference in a new issue