import random import discord import asyncio import traceback import random import datetime import os import importlib.util import ast import websockets import json import difflib import io import gzip import re from dotenv import load_dotenv # Load environment variables from .env file load_dotenv() time_regex = re.compile(r'(\d+)([smhd])') # Matches 4m2s, 1h30m, etc. def parse_time(time_str): units = {'s': 1, 'm': 60, 'h': 3600, 'd': 86400} total_seconds = sum(int(amount) * units[unit] for amount, unit in time_regex.findall(time_str)) return total_seconds if total_seconds > 0 else None COMMANDS_DIR = "commands" os.makedirs(COMMANDS_DIR, exist_ok=True) def load_commands(): commands = {} for filename in os.listdir(COMMANDS_DIR): if filename.endswith(".py"): cmd_name = filename[:-3] cmd_path = os.path.join(COMMANDS_DIR, filename) spec = importlib.util.spec_from_file_location(cmd_name, cmd_path) module = importlib.util.module_from_spec(spec) spec.loader.exec_module(module) if hasattr(module, "run") and callable(module.run): commands[cmd_name] = module.run return commands # Add a tracking file to save channel IDs TRACKED_CHANNELS_FILE = "tracked_channels.json" def load_tracked_channels(): if os.path.exists(TRACKED_CHANNELS_FILE): with open(TRACKED_CHANNELS_FILE, 'r') as f: return json.load(f) return [] def save_tracked_channels(tracked_channels): with open(TRACKED_CHANNELS_FILE, 'w') as f: json.dump(tracked_channels, f) async def handle_blacklist(message): if message.author in [696800726084747314]: await message.reply("no") class Selfbot(discord.Client): def __init__(self): super().__init__() self.default_status = None self.loaded_commands = load_commands() self.tracked_channels = load_tracked_channels() self.last_status = {} self.AFK_STATUS = False # Static variable to track AFK status self.AFK_NOTIFIED_USERS = [] # Static list to store users notified of AFK status self.horsin = [] async def on_ready(self): print(f"Logged in as {self.user}") async def handle_afk_dm(self,message): if self.AFK_STATUS and message.author.id not in self.AFK_NOTIFIED_USERS: await message.reply( "Heya, I'm not at my computer right now, if you're requesting something please follow . I'll let you know when I'm back :) \n\n-# This action was automated." ) self.AFK_NOTIFIED_USERS.append(message.author.id) async def on_message(self, message): if message.author.id == 1169111190824308768 and "<@1236667927944761396>" in message.content: await message.reply("shut the fuck up") if message.content.startswith(".remindme "): await handle_blacklist(message) parts = message.content.split(" ", 2) if len(parts) < 3: await message.reply("Usage: `.remindme