mirror of
https://github.com/myned/modufur.git
synced 2024-12-23 22:27:27 +00:00
Add comments
This commit is contained in:
parent
41b3577bd8
commit
ab1cd302cc
5 changed files with 13 additions and 0 deletions
|
@ -57,6 +57,7 @@ async def reverse(context):
|
|||
await _reverse(context, urls, selector=selector)
|
||||
|
||||
|
||||
# Listener for reverse exceptions
|
||||
@reverse.set_error_handler()
|
||||
async def on_reverse_error(event):
|
||||
error = None
|
||||
|
@ -84,6 +85,7 @@ async def on_reverse_error(event):
|
|||
return True
|
||||
|
||||
|
||||
# Reverse images and respond
|
||||
async def _reverse(context, urls, *, selector=None):
|
||||
if not selector:
|
||||
await context.respond(hikari.ResponseType.DEFERRED_MESSAGE_CREATE)
|
||||
|
|
|
@ -2,8 +2,12 @@ import toml
|
|||
import hikari
|
||||
|
||||
|
||||
# Hikari activity type
|
||||
# https://www.hikari-py.dev/hikari/presences.html#hikari.presences.ActivityType
|
||||
ACTIVITY = hikari.ActivityType.LISTENING
|
||||
# Global command error response
|
||||
ERROR = "```❗ An internal error has occurred. This has been reported to my master 🐺```"
|
||||
# Local bot configuration
|
||||
CONFIG = """\
|
||||
guilds = [] # guild IDs to register commands, empty for global
|
||||
master = 0 # guild ID to register owner commands
|
||||
|
@ -12,9 +16,11 @@ token = "" # bot token
|
|||
activity = "" # bot status
|
||||
saucenao = "" # saucenao token
|
||||
e621 = "" # e621 token
|
||||
|
||||
"""
|
||||
|
||||
|
||||
# Load or create config.toml
|
||||
try:
|
||||
config = toml.load("config.toml")
|
||||
except FileNotFoundError:
|
||||
|
@ -24,6 +30,7 @@ except FileNotFoundError:
|
|||
exit()
|
||||
|
||||
|
||||
# Global command error response for owner
|
||||
def error(event):
|
||||
exception = event.exception.__cause__ or event.exception
|
||||
|
||||
|
|
1
run.py
1
run.py
|
@ -21,6 +21,7 @@ bot = lightbulb.BotApp(
|
|||
)
|
||||
|
||||
|
||||
# Listener for global command exceptions
|
||||
@bot.listen(lightbulb.CommandErrorEvent)
|
||||
async def on_error(event):
|
||||
await bot.application.owner.send(c.error(event))
|
||||
|
|
|
@ -49,6 +49,7 @@ class Select(nav.NavButton):
|
|||
else:
|
||||
self._button(selected=True)
|
||||
|
||||
# Flip button state
|
||||
def _button(self, *, selected=False):
|
||||
self.style = hikari.ButtonStyle.SUCCESS if selected else hikari.ButtonStyle.DANGER
|
||||
self.label = "✔" if selected else "✗"
|
||||
|
@ -77,6 +78,7 @@ class Selector(nav.NavigatorView):
|
|||
|
||||
self.timed_out = True
|
||||
|
||||
# Resend new navigator as edit of previous
|
||||
async def send_edit(self, interaction):
|
||||
self._inter = interaction
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ plugin = lightbulb.Plugin("scraper")
|
|||
sauce = pysaucenao.SauceNao(api_key=c.config["saucenao"], priority=(29, 40, 41)) # e621 > Fur Affinity > Twitter
|
||||
|
||||
|
||||
# Return list of matches
|
||||
async def reverse(urls):
|
||||
return [await _saucenao(url) or await _kheina(url) for url in urls]
|
||||
|
||||
|
|
Loading…
Reference in a new issue