diff --git a/DimBot.py b/DimBot.py index 3fdf64b..b42c2c3 100644 --- a/DimBot.py +++ b/DimBot.py @@ -26,7 +26,7 @@ intent.guilds = intent.members = intent.messages = intent.reactions = intent.voice_states = intent.typing = True intent.presences = True bot = missile.Bot(intents=intent) -nickname = f"DimBot {'S ' if dimsecret.debug else ''}| 0.10" +nickname = f"DimBot {'S ' if dimsecret.debug else ''}| 0.10.1" logger = missile.get_logger('DimBot') sponsor_txt = '世界の未来はあなたの手の中にあります ' reborn_channel = None @@ -145,7 +145,7 @@ async def botinfo(ctx): embed.add_field('Uptime', datetime.now() - bot.boot_time) embed.add_field('Python', python_version()) embed.add_field('Discord.py', discord.__version__) - embed.add_field('Codename', '뾆') + embed.add_field('Codename', 'みずはら') embed.add_field('Devblog', '[Instagram](https://www.instagram.com/techdim)') embed.add_field('Source code', '[GitHub](https://github.com/TCLRainbow/DimBot)') embed.add_field('Discord server', '[6PjhjCD](https://discord.gg/6PjhjCD)') @@ -449,18 +449,9 @@ async def modrole(ctx: commands.Context, role: discord.Role): async def changelog(ctx): """Shows the latest release notes of DimBot""" await ctx.reply(""" -**__0.10 (Jul 3, 2021 2:45PM GMT+8)__ The UI update** - -After 2 months of somewhat relaxing development, I am pleased to announce v0.10, with 29 modified files, 2236 new lines and 1068 deleted lines. - -The development began with a database interconnect rewrite, which not only supports concurrent access, -but also an easier way to code SQL. -Followed by the addition of `d.xp` commands, I've stored over 1000 entries of xp records, before the 128BB incident. -Next, the UI of the entire help & quote commands, as well as `xp lb` are redesigned to be menu-driven, allowing users to -access the commands in a much easier fashion. - -In the near future, I am focusing on resolving GitHub issues, which are basically features to be added. A major goal is -to make Aegis much more configurable. +**__0.10.1 (Jul 3, 2021 8:33PM GMT+8)__** +You can now mention others as well as having multiple lines in quote message. +You can now mention others as a Quoter (but not quoter group). """) diff --git a/README.md b/README.md index e936b60..9aef3b8 100644 --- a/README.md +++ b/README.md @@ -22,5 +22,9 @@ The following are the variables that should be in the file: `Barbados` is the codename given to the discord.py implementation of DimBot. |Name|Represents|English| |------|-----------|---------| +|みずはら|0.10|Mizuhara| |뾆|0.9|Bbwaelp| -|ζ|0.8|Zeta| \ No newline at end of file +|ζ|0.8|Zeta| + +# Icon links +Not sure why, but I'll still document this. https://imgur.com/a/9h6DyhE \ No newline at end of file diff --git a/echo.py b/echo.py index b9d2d45..00f94f3 100644 --- a/echo.py +++ b/echo.py @@ -13,9 +13,19 @@ def split_quoter(quoter: str): return quoter[0], quoter[1] if len(quoter) > 1 else None +async def verify_quoter(ctx, quoter, quoter_group): + if quoter_group: + if '<@' in quoter_group: + await ctx.reply('You can only mention a user as a quoter, but not a quoter group.') + raise commands.errors.CheckFailure + if '\n' in quoter or '\n' in quoter_group: + await ctx.reply('Quoter must be single line!') + raise commands.errors.CheckFailure + + class Bottas(commands.Cog): """Storing messages. - Version 3.2""" + Version 3.2.1""" def __init__(self, bot): self.bot = bot @@ -66,8 +76,6 @@ async def quote_add(self, ctx: commands.Context, *, quote): """d.quote a quote: The new quote to be added """ - # Quote message validation - await missile.check_arg(ctx, quote) # Check if a quote with the same content already exists in the database rowid = await self.bot.sql.quote_msg_exists(self.bot.db, msg=quote) if rowid: @@ -76,9 +84,8 @@ async def quote_add(self, ctx: commands.Context, *, quote): # Asks for the quoter who said the quote quoter = await self.bot.ask_msg(ctx, 'Quoter?') if quoter: - # Quote message validation - await missile.check_arg(ctx, quoter) quoter, quoter_group = split_quoter(quoter) + await verify_quoter(ctx, quoter, quoter_group) # Quoter validation # Determines the ROWID to be used for inserting the quote rowid = await self.bot.sql.get_next_row_id(self.bot.db) if rowid: # Use ROWID from QuoteRowID if available. These IDs exist when a quote was deleted @@ -136,14 +143,12 @@ async def edit(self, ctx: commands.Context, index: int): if quote and (quote[2] == ctx.author.id or ctx.author.id == self.bot.owner_id): quote = Quote(index, *quote) content = await self.bot.ask_msg(ctx, 'Enter the new quote: (wait 10 seconds if it is the same)') - if content: # Quote message validation - await missile.check_arg(ctx, content) - else: + if not content: content = quote.msg quoter = await self.bot.ask_msg(ctx, "Enter new quoter: (wait 10 seconds if it is the same)") - if quoter: # Quoter validation - await missile.check_arg(ctx, quoter) + if quoter: quoter, quoter_group = split_quoter(quoter) + await verify_quoter(ctx, quoter, quoter_group) # Quoter validation else: quoter = quote.quoter quoter_group = quote.quoter_group diff --git a/missile.py b/missile.py index 22ff6f5..172797f 100644 --- a/missile.py +++ b/missile.py @@ -42,6 +42,7 @@ def decode(text: str) -> str: decoded: bytes = base64.b64decode(b) return decoded.decode() + async def append_msg(msg: discord.Message, content: str, delimiter: str = '\n'): await msg.edit(content=f'{msg.content}{delimiter}{content}') @@ -152,15 +153,6 @@ async def no_guild(): return commands.check(check) -async def check_arg(ctx, arg: str, user_mention=True, newline=True): - if user_mention and '<@' in arg: - await ctx.reply("You can't mention others!") - raise commands.errors.CheckFailure - if newline and '\n' in arg: - await ctx.reply('It should only be a single line!') - raise commands.errors.CheckFailure - - class Bot(commands.Bot): def __init__(self, **options):