Skip to content

Commit 4cd466d

Browse files
committed
Remove pypresence and spypet command from codebase
1 parent 2954f3d commit 4cd466d

File tree

5 files changed

+3
-174
lines changed

5 files changed

+3
-174
lines changed

bot/bot.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ async def on_ready(self):
119119

120120
self._setup_scripts()
121121
await self.controller.setup_webhooks()
122-
self.controller.spypet.set_bot(self)
123122

124123
except Exception as e:
125124
console.print_error(str(e))

bot/commands/util.py

Lines changed: 0 additions & 164 deletions
Original file line numberDiff line numberDiff line change
@@ -261,49 +261,6 @@ async def specs(self, ctx):
261261
"thumbnail": os_logos[os_name.lower()]
262262
})
263263

264-
@commands.command(name="sessionspoofer", description="Spoof your session", usage="[device]", aliases=["sessionspoof", "spoofsession"])
265-
async def sessionspoofer(self, ctx, device = None):
266-
cfg = self.cfg
267-
devices = ["mobile", "desktop", "web", "embedded"]
268-
spoofing, spoofing_device = cfg.get_session_spoofing()
269-
270-
if not spoofing:
271-
await cmdhelper.send_message(ctx, {
272-
"title": "Session Spoofing",
273-
"description": "Session spoofing is not enabled. Enable it in the config.",
274-
"colour": "#ff0000"
275-
})
276-
return
277-
278-
if device not in devices:
279-
await cmdhelper.send_message(ctx, {
280-
"title": "Session Spoofing",
281-
"description": f"Invalid device. Options: {', '.join(devices)}",
282-
"colour": "#ff0000"
283-
})
284-
return
285-
286-
if device is None:
287-
cfg.set_session_spoofing(not spoofing, spoofing_device)
288-
289-
await cmdhelper.send_message(ctx, {
290-
"title": "Session Spoofing",
291-
"description": f"Session spoofing is now {'enabled' if not spoofing else 'disabled'}\nRestarting to apply changes...",
292-
"colour": "#00ff00" if not spoofing else "#ff0000"
293-
})
294-
295-
else:
296-
cfg.set_session_spoofing(spoofing, device)
297-
298-
await cmdhelper.send_message(ctx, {
299-
"title": "Session Spoofing",
300-
"description": f"Session spoofing is now enabled as {device}\nRestarting to apply changes...",
301-
"colour": "#00ff00"
302-
})
303-
304-
cfg.save()
305-
await self.restart(ctx, no_response=True)
306-
307264
@commands.command(name="uptime", description="View the bot's uptime", usage="")
308265
async def uptime(self, ctx):
309266
uptime = time.time() - self.bot.start_time
@@ -345,126 +302,5 @@ async def commandhistory(self, ctx):
345302
description=description
346303
), delete_after=cfg.get("message_settings")["auto_delete_delay"])
347304

348-
@commands.command(name="spypet", description="Get a list of every message a member has sent in mutual servers.", usage="[member]")
349-
async def spypet(self, ctx, member_id: int):
350-
mutual_guilds = [guild for guild in self.bot.guilds if guild.get_member(member_id)]
351-
data = {}
352-
tasks = []
353-
sem = asyncio.Semaphore(15)
354-
stop_event = asyncio.Event()
355-
last_saved_count = 0
356-
357-
def _count_messages():
358-
return sum(len(channels) for guilds in data.values() for channels in guilds.values())
359-
360-
def _save_data():
361-
nonlocal last_saved_count
362-
current_count = _count_messages()
363-
if current_count == last_saved_count:
364-
return
365-
last_saved_count = current_count
366-
with open(files.get_application_support() + "/data/spypet.json", "w") as f:
367-
json.dump(data, f, indent=4)
368-
console.print_info(f"Auto-saved {current_count} messages.")
369-
370-
async def _autosave(interval=5):
371-
while not stop_event.is_set():
372-
await asyncio.sleep(interval)
373-
_save_data()
374-
375-
console.print_info("Auto-saving stopped. Spypet complete!")
376-
377-
def _add_message(guild, channel, message):
378-
if guild.name not in data: data[guild.name] = {}
379-
if channel.name not in data[guild.name]: data[guild.name][channel.name] = []
380-
381-
data[guild.name][channel.name].append(message)
382-
# _save_data()
383-
384-
def _get_permissions(channel):
385-
member = channel.guild.get_member(member_id)
386-
member_role = member.top_role
387-
bot_role = channel.guild.me.top_role
388-
389-
return (channel.permissions_for(member).read_messages and
390-
channel.permissions_for(channel.guild.me).read_messages or
391-
channel.overwrites_for(member_role).read_messages and
392-
channel.overwrites_for(bot_role).read_messages)
393-
394-
395-
async def _fetch_context_channel(channel):
396-
if channel.id == ctx.channel.id:
397-
return ctx.channel
398-
try:
399-
latest_msg = [msg async for msg in channel.history(limit=1)][0]
400-
context = await self.bot.get_context(latest_msg)
401-
402-
return context.channel
403-
except Exception as e:
404-
if "429" in str(e):
405-
await asyncio.sleep(5)
406-
return await _fetch_context_channel(channel)
407-
408-
return None
409-
410-
async def _get_messages(channel, delay=0.25):
411-
async with sem:
412-
try:
413-
await asyncio.sleep(delay)
414-
console.print_info(f"Finding messages in {channel.guild.name} - {channel.name}")
415-
416-
channel = await _fetch_context_channel(channel) or channel
417-
guild = channel.guild
418-
messages = []
419-
420-
try:
421-
async for msg in channel.history(limit=999999999, oldest_first=False):
422-
if msg.author.id == member_id:
423-
if len(msg.attachments) > 0:
424-
attachments = "\n".join([f"Attachment: {attachment.url}" for attachment in msg.attachments])
425-
msg_string = f"[{msg.created_at.strftime('%Y-%m-%d %H:%M:%S')}] {msg.content}\n{attachments}"
426-
else:
427-
msg_string = f"[{msg.created_at.strftime('%Y-%m-%d %H:%M:%S')}] {msg.content}"
428-
messages.append(msg_string)
429-
_add_message(guild, channel, msg_string)
430-
431-
if len(messages) > 0:
432-
console.print_success(f"Found messages in {channel.guild.name} - {channel.name}")
433-
else:
434-
console.print_error(f"Found no messages in {channel.guild.name} - {channel.name}")
435-
except:
436-
console.print_error(f"Failed to fetch messages in {channel.guild.name} - {channel.name}")
437-
438-
_save_data()
439-
except asyncio.CancelledError:
440-
console.print_warning("Process was cancelled! Saving progress...")
441-
stop_event.set()
442-
_save_data()
443-
raise
444-
except Exception as e:
445-
console.print_error(f"Error in {channel.guild.name} - {channel.name}: {e}")
446-
finally:
447-
_save_data()
448-
449-
delay = 0.5
450-
autosave_task = asyncio.create_task(_autosave(5))
451-
452-
for guild in mutual_guilds:
453-
for channel in guild.text_channels:
454-
if _get_permissions(channel):
455-
tasks.append(asyncio.create_task(_get_messages(channel, delay)))
456-
delay += 0.5
457-
458-
await asyncio.gather(*tasks)
459-
stop_event.set()
460-
await autosave_task
461-
_save_data()
462-
463-
console.print_success("Spypet complete! Data saved to data/spypet.json.")
464-
console.print_info(f"Total messages: {_count_messages()}")
465-
console.print_info(f"Total guilds: {len(data)}")
466-
console.print_info(f"Total channels: {sum(len(channels) for channels in data.values())}")
467-
await ctx.send(file=discord.File("data/spypet.json"), delete_after=self.cfg.get("message_settings")["auto_delete_delay"])
468-
469305
def setup(bot):
470306
bot.add_cog(Util(bot))

bot/controller.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,11 @@
1515
from bot.helpers import cmdhelper, imgembed
1616
import utils.webhook as webhook_client
1717
from gui.helpers.images import resize_and_sharpen
18-
from pypresence import Presence
19-
from bot.helpers.spypet import Spypet
2018

2119
if getattr(sys, 'frozen', False):
2220
os.chdir(os.path.dirname(sys.executable))
2321

2422
class BotController:
25-
spypet = None
26-
2723
def __init__(self):
2824
self.cfg = Config()
2925
self.bot = None
@@ -34,7 +30,6 @@ def __init__(self):
3430
self.bot_running = False
3531
self.startup_scripts = []
3632
self.presence = self.cfg.get_rich_presence()
37-
self.spypet = Spypet()
3833

3934
def add_startup_script(self, script):
4035
self.startup_scripts.append(script)

readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Ghost has 150+ commands and a completely custom built GUI for endless customisat
1717
> ```bash
1818
> git clone https://github.com/ghostselfbot/ghost
1919
> cd ghost
20-
> python3 -m venv .venv # create venv (requires Python 3.10+)
20+
> python3 -m venv .venv # create venv (requires Python 3.10+)
2121
> source .venv/bin/activate # or on Windows: .\.venv\Scripts\activate
2222
> pip install -r requirements.txt
2323
> python3 ghost.py
@@ -30,7 +30,7 @@ Ghost has 150+ commands and a completely custom built GUI for endless customisat
3030
<img src="https://github.com/user-attachments/assets/3ed477b8-55a4-49c5-87b2-0e8f98e3832a" width="100%">
3131
-->
3232
33-
> | ![CleanShot 2025-05-16 at 9 36 19@2x](https://github.com/user-attachments/assets/570fc27d-5a30-4dfa-8644-0aed5d2a818a) | ![CleanShot 2025-05-16 at 9 36 35@2x](https://github.com/user-attachments/assets/e0a3350d-a5d9-4521-a964-014000d4fd6b) |
33+
> | ![CleanShot 2025-05-16 at 9 36 19@2x](https://github.com/user-attachments/assets/570fc27d-5a30-4dfa-8644-0aed5d2a818a) | ![CleanShot 2025-05-16 at 9 36 35@2x](https://github.com/user-attachments/assets/e0a3350d-a5d9-4521-a964-014000d4fd6b) |
3434
> |---|---|
3535
3636
> [!NOTE]

requirements.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,4 @@ cupcake-editor
1414
filetype
1515
toml
1616
pygments
17-
certifi
18-
pypresence
17+
certifi

0 commit comments

Comments
 (0)