This commit is contained in:
Xargana 2025-05-09 22:11:53 +03:00
parent c0d5dd5249
commit 40c9d3ffa0
3 changed files with 7 additions and 84 deletions

View file

@ -4,37 +4,6 @@ import asyncio
class UserManagementCommands:
def __init__(self, bot):
self.bot = bot
# Store lists of ignored/muted users and channels
self.ignored_channels = set()
self.muted_channels = set()
self.muted_users = set()
async def cmd_ignore(self, message):
"""
Ignore all users in the current channel except for self
Usage: .ignore
"""
try:
channel_id = message.channel.id
self.ignored_channels.add(channel_id)
await message.edit(content=f"✅ Ignoring users in this channel. Use `.unignore` to revert.")
except Exception as e:
await message.edit(content=f"❌ Error ignoring channel: {str(e)}")
async def cmd_unignore(self, message):
"""
Stop ignoring users in the current channel
Usage: .unignore
"""
try:
channel_id = message.channel.id
if channel_id in self.ignored_channels:
self.ignored_channels.remove(channel_id)
await message.edit(content=f"✅ No longer ignoring users in this channel.")
else:
await message.edit(content=f"❌ This channel is not being ignored.")
except Exception as e:
await message.edit(content=f"❌ Error: {str(e)}")
async def cmd_close(self, message):
"""
@ -52,36 +21,9 @@ class UserManagementCommands:
except Exception as e:
await message.edit(content=f"❌ Error closing DM: {str(e)}")
async def cmd_mute(self, message):
"""
Mute the current channel (no notifications)
Usage: .mute
"""
try:
channel_id = message.channel.id
self.muted_channels.add(channel_id)
await message.edit(content=f"✅ Channel muted. Use `.unmute` to revert.")
except Exception as e:
await message.edit(content=f"❌ Error muting channel: {str(e)}")
async def cmd_unmute(self, message):
"""
Unmute the current channel
Usage: .unmute
"""
try:
channel_id = message.channel.id
if channel_id in self.muted_channels:
self.muted_channels.remove(channel_id)
await message.edit(content=f"✅ Channel unmuted.")
else:
await message.edit(content=f"❌ This channel is not muted.")
except Exception as e:
await message.edit(content=f"❌ Error: {str(e)}")
async def cmd_block(self, message):
"""
Block a user
Block a user using Discord's native block function
Usage: .block @user or .block [in reply to a message]
"""
try:
@ -99,7 +41,7 @@ class UserManagementCommands:
return
await user.block()
await message.edit(content=f"✅ Blocked user {user.name}#{user.discriminator}.")
await message.edit(content=f"✅ Blocked {user.name}#{user.discriminator}")
except Exception as e:
await message.edit(content=f"❌ Error blocking user: {str(e)}")
@ -139,4 +81,4 @@ class UserManagementCommands:
# Method to check if a channel is muted
def is_channel_muted(self, channel_id):
return channel_id in self.muted_channels
return channel_id in self.muted_channels

View file

@ -80,12 +80,6 @@ class MessageHandler:
if message.author.bot:
return
# Check if the channel is in ignored channels list and message is not from bot user
if (message.author != self.bot.user and
hasattr(self, 'user_management_commands') and
self.user_management_commands.is_channel_ignored(message.channel.id)):
return
# Look for and replace time patterns (only for non-command messages)
if not message.content.startswith('.'):
original_content = message.content
@ -155,17 +149,9 @@ class MessageHandler:
await message.channel.send(f"Error executing command: {e}")
return
# User Management Commands
if content.startswith(".ignore"):
await self.user_management_commands.cmd_ignore(message)
elif content.startswith(".unignore"):
await self.user_management_commands.cmd_unignore(message)
elif content.startswith(".close"):
# User Management Commands - only keeping close and block
if content.startswith(".close"):
await self.user_management_commands.cmd_close(message)
elif content.startswith(".mute"):
await self.user_management_commands.cmd_mute(message)
elif content.startswith(".unmute"):
await self.user_management_commands.cmd_unmute(message)
elif content.startswith(".block"):
await self.user_management_commands.cmd_block(message)
elif content.startswith(".unblock"):

View file

@ -25,13 +25,8 @@ class Selfbot(discord.Client):
print(f"Logged in as {self.user}")
async def on_message(self, message):
# Skip notifications for muted channels
if (message.channel.id in self.user_management_commands.muted_channels and
message.author != self.user):
# Still process the message, but don't trigger notifications
pass
# Regular message handling
# Don't use muted_channels anymore since we're using Discord's native functionality
# Instead, just process all messages
await self.message_handler.handle_message(message)
async def on_message_delete(self, message):