diff --git a/cogs/emoji.py b/cogs/emoji.py index 69b9236..6b030ad 100644 --- a/cogs/emoji.py +++ b/cogs/emoji.py @@ -3,7 +3,6 @@ import cairosvg import cv2 as cv import numpy as np -import os import pathlib import urllib diff --git a/cogs/hug.py b/cogs/hug.py index d33bf78..ab5c643 100644 --- a/cogs/hug.py +++ b/cogs/hug.py @@ -5,7 +5,7 @@ import pathlib import urllib -from util import aliases, config, flagset +from util import aliases, config, flagset, rotate class Hug(commands.Cog): def __init__(self, bot): @@ -49,14 +49,6 @@ async def hug(self, ctx, left: MemberProfilePicture, right: MemberProfilePicture mask1 = cv.inRange(img, self.darkblue, self.darkblue) mask2 = cv.inRange(img, self.lightblue, self.lightblue) - # define a rotate function to rotate the flag for person 2 - def rotate(img, angle, scale=1.0): - (height,width) = img.shape[:2] - point = (width // 2, height // 2) - matrix = cv.getRotationMatrix2D(point, angle, scale) - dimensions = (width, height) - return cv.warpAffine(img, matrix, dimensions) - pflags = [] for p in left[0], right[0]: if p[6:-4] in flagset: # image is a locally stored flag diff --git a/cogs/meta.py b/cogs/meta.py index 26e034e..bd78582 100644 --- a/cogs/meta.py +++ b/cogs/meta.py @@ -57,7 +57,7 @@ async def flags(self, ctx): await ctx.send(embed=em) @commands.command() - async def flag(self, ctx, flag): + async def flag(self, ctx, flag=''): full = flag if flag not in aliases else aliases[flag] if full in flagset: aliases_for_full = [alias for alias in aliases if aliases[alias] == full] @@ -65,6 +65,8 @@ async def flag(self, ctx, flag): em.set_thumbnail(url=f'https://raw.githubusercontent.com/amazansky/hugmaker/main/flags/{full}.png') em.add_field(name='Short name(s)', value=', '.join(aliases_for_full) or '(None)') await ctx.send(embed=em) + elif full == '': + await ctx.send(f'Error: You must use this command with the name of a pride flag. Run **{self.prefix}help flag** for more info.') else: await ctx.send('Error: The flag you entered was not recognized.') @@ -72,9 +74,9 @@ async def flag(self, ctx, flag): async def about(self, ctx): em = discord.Embed(title=f'About hugmaker ({config["BOT_VERSION"]})', description='Hi, I\'m hugmaker! I am a \ Discord bot which creates custom emotes.') - em.add_field(name='Source code', value='Hugmaker is open source! You can find the code at . \ - The code is available under the MIT license. In addition, any images generated by hugmaker are available under \ - CC BY 4.0. Have any issues or run into problems using the bot? Report them at the issue tracker: \ + em.add_field(name='Source code', value='Hugmaker is open source under the MIT license! You can find the code \ + at . In addition, any images generated by hugmaker are available \ + under CC BY 4.0. Have any issues or run into problems using the bot? Report them at the issue tracker: \ ', inline=False) opstring = ", ".join(["**" + str(await self.bot.fetch_user(uid)) + "**" for uid in self.ops]) em.add_field(name='Operators', value=f'On this server, the operators of hugmaker are: {opstring}. You can ask them \ diff --git a/example.config.yml b/example.config.yml index 381fde5..d7480d9 100644 --- a/example.config.yml +++ b/example.config.yml @@ -1,6 +1,6 @@ # This is probably a bad way of doing this, but it's easy and is used within the bot. Maybe # I'll change it later. -BOT_VERSION: v1.0.0 +BOT_VERSION: v1.1.0 BOT_TOKEN: YOUR_TOKEN_HERE diff --git a/main.py b/main.py index d7efefd..0f5c6a9 100644 --- a/main.py +++ b/main.py @@ -31,9 +31,15 @@ async def load(ctx, ext): @bot.command() @commands.is_owner() -async def reload(ctx, ext): - bot.reload_extension(f'cogs.{ext}') - await ctx.message.add_reaction('\U00002705') +async def reload(ctx, ext=''): + if ext != '': # reload specific cog + bot.reload_extension(f'cogs.{ext}') + await ctx.message.add_reaction('\U00002705') + else: # reload all cogs + for filename in os.listdir('cogs'): + if filename.endswith('.py'): + bot.reload_extension(f'cogs.{filename[:-3]}') + await ctx.message.add_reaction('\U00002611') # different check mark emoji @bot.command() @commands.is_owner() diff --git a/util.py b/util.py index e68b5e2..2ffb60d 100644 --- a/util.py +++ b/util.py @@ -1,5 +1,6 @@ import os import yaml +import cv2 as cv # generate set of flags from png files in flags folder flagset = {f[:-4] for f in os.listdir('flags') if f.endswith('.png')} @@ -28,3 +29,11 @@ # access config file with open('config.yml', 'r') as f: config = yaml.safe_load(f) + +# define a rotate function to rotate the flag for person 2 +def rotate(img, angle, scale=1.0): + (height,width) = img.shape[:2] + point = (width // 2, height // 2) + matrix = cv.getRotationMatrix2D(point, angle, scale) + dimensions = (width, height) + return cv.warpAffine(img, matrix, dimensions)