Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/tako-discord/tako
Browse files Browse the repository at this point in the history
  • Loading branch information
Pukimaa committed Feb 28, 2023
2 parents 71eecfb + c08f605 commit 3e21b5a
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 19 deletions.
10 changes: 5 additions & 5 deletions cogs/language/autotranslate.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ async def on_message(self, message: discord.Message):
if (
not message.content
or not state
or message.author.id == self.bot.user.id # type: ignore
or message.author.id == self.bot.user.id # type: ignore
or message.webhook_id
):
return
Expand Down Expand Up @@ -159,7 +159,8 @@ async def on_message(self, message: discord.Message):
attachments = new_attachments

data = await detect(
message.content.replace("\n", " "), path=os.path.join(os.getcwd(), "assets/lid.176.bin")
message.content.replace("\n", " "),
path=os.path.join(os.getcwd(), "assets/lid.176.bin"),
)
data["score"] = data["score"] * 100
confidence = await self.bot.db_pool.fetchval(
Expand Down Expand Up @@ -255,7 +256,7 @@ async def on_message(self, message: discord.Message):
files=attachments, # type: ignore
thread=message.channel if isinstance(message.channel, discord.Thread) else discord.utils.MISSING, # type: ignore
content=translation[0],
allowed_mentions=discord.AllowedMentions.none()
allowed_mentions=discord.AllowedMentions.none(),
)
if delete_original:
await message.delete()
Expand Down Expand Up @@ -301,8 +302,7 @@ async def on_message(self, message: discord.Message):
await message.delete()
return
await message.reply(
"> "
+ (translation[0]).replace("\n", "\n> "),
"> " + (translation[0]).replace("\n", "\n> "),
allowed_mentions=discord.AllowedMentions.none(),
mention_author=False,
files=attachments,
Expand Down
3 changes: 1 addition & 2 deletions cogs/language/reaction_translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ async def on_raw_reaction_add(self, payload: discord.RawReactionActionEvent):

message: discord.Message = await self.bot.get_channel(
payload.channel_id
).fetch_message( # type: ignore

).fetch_message( # type: ignore
payload.message_id
)
try:
Expand Down
2 changes: 1 addition & 1 deletion cogs/language/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async def translate(
embed = discord.Embed(
title=i18n.t("misc.translation", locale=language),
description="\n".join(description),
color=await get_color(self.bot, interaction.guild_id), # type: ignore
color=await get_color(self.bot, interaction.guild_id), # type: ignore
)
embed.set_thumbnail(url="attachment://thumbnail.png")
await interaction.followup.send(embed=embed, file=file, ephemeral=ephemeral)
8 changes: 4 additions & 4 deletions cogs/misc/affirmations.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ def __init__(self, bot: TakoBot):
@app_commands.describe(
ephemeral="Whether the response should be ephemeral (default: false)",
)
async def affirmation(self, interaction: discord.Interaction, ephemeral: bool = False):
async def affirmation(
self, interaction: discord.Interaction, ephemeral: bool = False
):
await interaction.response.defer(ephemeral=ephemeral)
async with aiohttp.ClientSession() as session:
async with session.get("https://affirmations.dev/") as r:
data = await r.json()
await interaction.followup.send(
data["affirmation"]
)
await interaction.followup.send(data["affirmation"])
4 changes: 1 addition & 3 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
SURVEY_ROLES = [1026487071625457754, 1062067399395913808]
CURRENCY = " <:TK:1025679113777848320>"
TRANSLATE_API = "https://lingva.ml" # no / at the end is important
TRANSLATE_API_FALLBACK = (
"https://lingva.ml" # no / at the end is important
)
TRANSLATE_API_FALLBACK = "https://lingva.ml" # no / at the end is important
IMGEN = "https://imgen.tako-bot.com" # no / at the end is important
REPO = "tako-discord/tako"
RAW_GH = "https://raw.githubusercontent.com/"
Expand Down
10 changes: 6 additions & 4 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def format_bytes(size: int):
n = 0
power_labels = ["Bytes", "KB", "MB", "GB", "TB"]
while size > power and n != 4:
size /= power # type: ignore
size /= power # type: ignore
n += 1
return str(round(size)) + power_labels[n]

Expand Down Expand Up @@ -86,7 +86,7 @@ def color_check(color: str):
"""
value = True
rgb = ImageColor.getcolor(color, "RGB")
value = True if (rgb[0] * 0.299 + rgb[1] * 0.587 + rgb[2] * 0.114) < 143 else False # type: ignore
value = True if (rgb[0] * 0.299 + rgb[1] * 0.587 + rgb[2] * 0.114) < 143 else False # type: ignore
return value


Expand Down Expand Up @@ -321,7 +321,9 @@ async def get_latest_version():
return data["tool"]["commitizen"]["version"]


async def translate_logic(session: aiohttp.ClientSession, url: str, source: str = "auto") -> Type[json.JSONDecodeError] | list[str]:
async def translate_logic(
session: aiohttp.ClientSession, url: str, source: str = "auto"
) -> Type[json.JSONDecodeError] | list[str]:
async with session.get(url) as r:
data = await r.text()
try:
Expand Down Expand Up @@ -357,7 +359,7 @@ async def translate(text: str, target: str, source: str = "auto") -> list[str]:
f"{config.TRANSLATE_API_FALLBACK}/api/v1/{source}/{target}/{quote(text)}",
source,
)
return data if data is not json.JSONDecodeError else [text, source] # type: ignore
return data if data is not json.JSONDecodeError else [text, source] # type: ignore


async def new_meme(guild_id: int | None, user_id: int, bot, db_pool: asyncpg.Pool):
Expand Down

0 comments on commit 3e21b5a

Please sign in to comment.