async def on_message_without_command(self, message: discord.Message): if message.author.bot or isinstance(message.author, discord.User): return if not message.guild: return guild: discord.Guild = message.guild if guild.id not in self.enabled_guilds: return guild: discord.Guild = message.guild if "no quote" in message.content.lower(): return channel: discord.TextChannel = message.channel ctx = commands.Context( message=message, author=message.author, guild=guild, channel=channel, me=message.guild.me, bot=self.bot, prefix="auto_linkquote", command=self.bot.get_command("linkquote"), ) try: quoted_message = await LinkToMessage().convert( ctx, message.content) except BadArgument: return if not await self.bot.message_eligible_as_command(message): return cog = webhook_check(ctx) data = await self.config.guild(ctx.guild).all() tasks = [] if cog and data["webhooks"]: embed = await self.message_to_embed(quoted_message, invoke_guild=ctx.guild, author_field=False) tasks.append( cog.send_to_channel( ctx.channel, ctx.me, ctx.author, reason=f"For the {ctx.command.qualified_name} command", username=self.get_name(quoted_message.author), avatar_url=quoted_message.author.avatar_url, embed=embed, )) else: embed = await self.message_to_embed(quoted_message, invoke_guild=ctx.guild) tasks.append(ctx.send(embed=embed)) if data["delete"]: tasks.append(delete_quietly(ctx)) await asyncio.gather(*tasks)
async def on_message_without_command(self, message: discord.Message): if message.author.bot or not ( message.guild and await self.bot.message_eligible_as_command(message)): return if not await self.config.guild(message.guild).on(): return ctx = commands.Context( message=message, author=message.author, guild=message.guild, channel=message.channel, me=message.guild.me, bot=self.bot, prefix="auto_linkquote", command=self.bot.get_command("linkquote"), ) try: message = await LinkToMessage().convert(ctx, message.content) except BadArgument: return embeds = await self.create_embeds([message]) if not embeds: return cog = webhook_check(ctx) if (await self.config.guild(ctx.guild).webhooks()) and cog: await cog.send_to_channel( ctx.channel, ctx.me, ctx.author, reason=f"For the {ctx.command.qualified_name} command", username=ctx.author.display_name, avatar_url=ctx.author.avatar_url, embed=embeds[0][0], ) else: await ctx.send(embed=embeds[0][0])
async def on_message_without_command(self, message: discord.Message): if message.author.bot or isinstance(message.author, discord.User): return if not message.guild: return guild: discord.Guild = message.guild if guild.id not in self.enabled_guilds: return guild: discord.Guild = message.guild if "no quote" in message.content.lower(): return channel: discord.TextChannel = message.channel bucket = self.spam_control.get_bucket(message) current = message.created_at.timestamp() retry_after = bucket.get_retry_after(current) if retry_after: log.debug("%r ratelimits exhausted, retry after: %s" % (channel, retry_after)) return ctx = commands.Context( message=message, author=message.author, guild=guild, channel=channel, me=message.guild.me, bot=self.bot, prefix="auto_linkquote", command=self.bot.get_command("linkquote"), ) try: quoted_message = await LinkToMessage().convert(ctx, message.content) except commands.BadArgument: return if not await self.bot.message_eligible_as_command(message): return try: cog = webhook_check(ctx) except commands.CheckFailure: cog = False data = await self.config.guild(ctx.guild).all() tasks = [] if cog and data["webhooks"]: embed = await self.message_to_embed( quoted_message, invoke_guild=ctx.guild, author_field=False ) tasks.append( cog.send_to_channel( ctx.channel, ctx.me, ctx.author, reason=f"For the {ctx.command.qualified_name} command", username=self.get_name(quoted_message.author), avatar_url=quoted_message.author.avatar_url, embed=embed, ) ) else: embed = await self.message_to_embed(quoted_message, invoke_guild=ctx.guild) tasks.append(channel.send(embed=embed)) if data["delete"]: tasks.append(self.delete_quietly(ctx)) await asyncio.gather(*tasks) bucket.update_rate_limit(current)
async def on_message_without_command(self, message): if not message.author.id == 270904126974590976: return if "You gave" not in message.content: return if await self.config.channel(message.channel).ignored(): return last_message = await self.get_last_message(message) filtered_content = ( message.content.strip() .lstrip(f"<@{last_message.author.id}>") .lstrip(f"<@!{last_message.author.id}>") .replace("⏣ ", "") .strip() ) filtered_content = self.decode_cancer_name(filtered_content) match = re.match(gift_regex, filtered_content) if not match: return amount = int(match.group("amount").replace(",", "")) member = match.group("user") ctx = commands.Context( message=message, author=message.author, guild=message.guild, channel=message.channel, me=message.guild.me, bot=self.bot, prefix="dank_log_tracker", command=self.bot.get_command("dankinfo"), ) shared_user = await self.get_fuzzy_member(ctx, member) if not shared_user: return shared_user_data = await self.config.member(shared_user).all() user_data = await self.config.member(last_message.author).all() if last_message.content.lower().startswith( "pls share" ) or last_message.content.lower().startswith("pls give"): if str(shared_user.id) not in user_data["sharedusers"]: user_data["sharedusers"][str(shared_user.id)] = 0 user_data["sharedusers"][str(shared_user.id)] += 1 user_data["shared"] += amount shared_user_data["received"] += amount formatted_now = datetime.utcnow().strftime("%a, %d %b %Y %H:%M:%S") user_data["logs"].append( f"At {formatted_now}, {self.comma_format(amount)} was shared to {shared_user} (ID of {shared_user.id})" ) shared_user_data["logs"].append( f"At {formatted_now}, {self.comma_format(amount)} was received from {last_message.author} (ID of {last_message.author.id})" ) await self.config.member(shared_user).set(shared_user_data) await self.config.member(last_message.author).set(user_data) channel = await self.config.guild(message.guild).channel() channel = self.bot.get_channel(channel) if not channel: return e = discord.Embed( title="Dankmemer Logs", description=f"{last_message.author.mention} shared {self.comma_format(amount)} coins to {shared_user.mention} in {message.channel.mention}\n [JUMP]({message.jump_url})", ) await channel.send(embed=e) else: if str(shared_user.id) not in user_data["giftedusers"]: user_data["giftedusers"][str(shared_user.id)] = 0 user_data["giftedusers"][str(shared_user.id)] += 1 item = match.group("item") if item not in user_data["gifted"]: user_data["gifted"][item] = 0 user_data["gifted"][item] += amount if item not in shared_user_data["receiveditems"]: shared_user_data["receiveditems"][item] = 0 shared_user_data["receiveditems"][item] += amount formatted_now = datetime.utcnow().strftime("%a, %d %b %Y %H:%M:%S") shared_user_data["logs"].append( f"On {formatted_now}, {last_message.author} gave {self.comma_format(amount)} {item}" ) user_data["logs"].append( f"On {formatted_now}, {self.comma_format(amount)} {item} was sent to {shared_user}" ) channel = await self.config.guild(message.guild).channel() channel = self.bot.get_channel(channel) await self.config.member(shared_user).set(shared_user_data) await self.config.member(last_message.author).set(user_data) if not channel: return e = discord.Embed( title="Dankmemer Logs", description=f"{last_message.author.mention} gave {amount} {item} to {shared_user.mention} in {message.channel.mention}\n [JUMP]({message.jump_url})", ) await channel.send(embed=e)