Create main.py
Browse files1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253import discordfrom discord.ext import commandsfrom PIL import Image, ImageChopsimport ioimport os
intents = discord.Intents.default()intents.message_content = Truebot = commands.Bot(command_prefix='!', intents=intents)
def remove_watermark(image_bytes, watermark_path): try: original = Image.open(io.BytesIO(image_bytes)).convert("RGBA") watermark = Image.open(watermark_path).convert("RGBA") watermark = watermark.resize(original.size) result = ImageChops.difference(original, watermark) output = io.BytesIO() result.save(output, format="PNG") output.seek(0) return output except Exception as e: print(f"Error processing image: {e}") return None
@bot.eventasync def on_ready(): print(f'البوت جاهز وشغال باسم {bot.user}')
@bot.eventasync def on_message(message): if message.author == bot.user: return
if message.attachments: for attachment in message.attachments: if attachment.filename.lower().endswith(('.png', '.jpg', '.jpeg')): await message.channel.send('جاري معالجة الصورة وإزالة العلامة المائية لحظة واحدة') image_bytes = await attachment.read() processed_image = remove_watermark(image_bytes, 'watermark_sample.png') if processed_image: await message.channel.send(file=discord.File(fp=processed_image, filename='unwatermarked.png')) else: await message.channel.send('حصلت مشكلة في معالجة الصورة تأكد من ملف العلامة المائية')
await bot.process_commands(message)
bot.run('حط_التوكن_الجديد_بتاعك_هنا')main.pyAdded+53