-
Notifications
You must be signed in to change notification settings - Fork 7
/
ghost.py
executable file
·174 lines (142 loc) · 4.75 KB
/
ghost.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
import os
import sys
import requests
import time
import discord
import faker
import random
import asyncio
import colorama
import base64
import threading
import json
import string
import logging
headless = False
try:
import tkinter
except ModuleNotFoundError:
headless = True
from discord.errors import LoginFailure
from discord.ext import commands
from pypresence import Presence
from PIL import Image, ImageDraw, ImageFont, ImageFilter
from utils import console
from utils import config
from utils import notifier
from utils import scripts
from utils import files
from utils import codeblock
from utils import cmdhelper
from utils import imgembed
from utils import sessionspoof
if not headless: from utils import gui as ghost_gui
# import utils as ghost_utils
import commands as ghost_commands
import events as ghost_events
if discord.__version__ < "2.0.0":
for _ in range(100):
console.print_error("Ghost only supports discord.py-self 2.0.0, please upgrade!")
sys.exit()
cfg = config.Config()
cfg.check()
token = cfg.get("token")
files.create_defaults()
session_spoofing, session_spoofing_device = cfg.get_session_spoofing()
if session_spoofing:
sessionspoof.patch_identify(session_spoofing_device)
status_resp = requests.get("https://discord.com/api/users/@me/settings", headers={"Authorization": cfg.get("token")})
status = "online" if status_resp.status_code != 200 else status_resp.json()["status"]
ghost = commands.Bot(
command_prefix=cfg.get("prefix"),
self_bot=True,
help_command=None,
status=discord.Status.try_value(status)
)
if not headless: gui = ghost_gui.GhostGUI(ghost)
user = requests.get("https://discord.com/api/users/@me", headers={"Authorization": cfg.get("token")}).json()
rpc_log = ""
if cfg.get("rich_presence"):
try:
rpc = Presence(1018195507560063039)
rpc.connect()
rpc.update(
large_image="ghost",
start=time.time(),
state="ghost aint dead",
)
rpc_log = "Rich Presence connected succesfully!"
except Exception as e:
rpc_log = e
for script_file in os.listdir("scripts"):
if script_file.endswith(".py"):
scripts.add_script("scripts/" + script_file, globals(), locals())
@ghost.event
async def on_connect():
if not headless: gui.bot_started = True
await ghost.add_cog(ghost_commands.Account(ghost))
await ghost.add_cog(ghost_commands.Fun(ghost))
await ghost.add_cog(ghost_commands.General(ghost))
await ghost.add_cog(ghost_commands.Img(ghost))
await ghost.add_cog(ghost_commands.Info(ghost))
await ghost.add_cog(ghost_commands.Mod(ghost))
await ghost.add_cog(ghost_commands.NSFW(ghost))
await ghost.add_cog(ghost_commands.Text(ghost))
await ghost.add_cog(ghost_commands.Theming(ghost))
await ghost.add_cog(ghost_commands.Util(ghost))
await ghost.add_cog(ghost_commands.Abuse(ghost))
await ghost.add_cog(ghost_commands.Sniper(ghost))
await ghost.add_cog(ghost_events.NitroSniper(ghost))
await ghost.add_cog(ghost_events.PrivnoteSniper(ghost))
text = f"Logged in as {ghost.user.name}"
if str(ghost.user.discriminator) != "0":
text += f"#{ghost.user.discriminator}"
console.clear()
console.resize(columns=90, rows=25)
console.print_banner()
console.print_info(text)
console.print_info(f"You can now use commands with {cfg.get('prefix')}")
print()
if cfg.get("rich_presence"):
console.print_rpc(rpc_log)
if session_spoofing:
console.print_info(f"Spoofing session as {session_spoofing_device}")
if cfg.get("message_settings")["style"] == "embed" and cfg.get("rich_embed_webhook") == "":
console.print_error("Rich embed webhook not set! Using codeblock mode instead.")
notifier.Notifier.send("Ghost", text)
@ghost.event
async def on_command(ctx):
try:
await ctx.message.delete()
except Exception as e:
console.print_error(str(e))
command = ctx.message.content[len(ghost.command_prefix):]
console.print_cmd(command)
@ghost.event
async def on_command_error(ctx, error):
cfg = config.Config()
try:
await ctx.message.delete()
except Exception as e:
console.print_error(str(e))
try:
await cmdhelper.send_message(ctx, {
"title": "Error",
"description": str(error),
"colour": "#ff0000"
})
except Exception as e:
console.print_error(f"{e}")
console.print_error(str(error))
while token == "":
console.print_error("Invalid token, please set a new one below.")
new_token = input("> ")
cfg.set("token", new_token)
cfg.save()
try:
if not headless:
gui.run()
else:
ghost.run(token, log_handler=console.handler)
except Exception as e:
console.print_error(str(e))