-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev.py
More file actions
212 lines (193 loc) · 10.9 KB
/
dev.py
File metadata and controls
212 lines (193 loc) · 10.9 KB
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
import discord
from discord import app_commands
from discord.ext import commands
import requests
import time
import random
import discord
from io import StringIO
from contextlib import redirect_stdout
import logging
import nacl
import asyncio
logger = logging.getLogger("tjbot.dev")
class EvalModal(discord.ui.Modal, title = 'Eval this shit'):
prompt = discord.ui.TextInput(
label = 'Eval this shit',
style = discord.TextStyle.long,
placeholder = 'TOKEN',
required = True,
max_length = 2000,
)
async def on_submit(self, interaction: discord.Interaction):
if interaction.user.name == "tjc472":
try:
output = str(eval(self.prompt.value))
except:
output = "what if you read https://www.w3schools.com/python/default.asp"
else:
output = "idk i dont want to rn"
await interaction.response.send_message(content=output)
class ExecModal(discord.ui.Modal, title = 'Exec this shit'):
prompt = discord.ui.TextInput(
label = 'Exec this shit',
style = discord.TextStyle.long,
placeholder = 'TOKEN(wont work here)',
required = True,
max_length = 4000,
)
async def on_submit(self, interaction: discord.Interaction):
if interaction.user.name == "tjc472":
try:
f = StringIO()
with redirect_stdout(f):
exec(self.prompt.value, globals())
output = f.getvalue()
except:
output = "what if you read https://www.w3schools.com/python/default.asp"
else:
output = "idk i dont want to rn"
await interaction.response.send_message(content = f"```ansi\n{output}```")
class Dev(commands.Cog):
def __init__(self, bot: commands.Bot) :
self.bot = bot
@app_commands.command(description="Developer utilities and debug :3")
@app_commands.describe(
prompt='dev prompt following the tjdev standard'
)
@app_commands.allowed_installs(guilds = True, users = True)
@app_commands.allowed_contexts(guilds = True, dms = True, private_channels = True)
async def dev(self, interaction: discord.Interaction, prompt: str):
await interaction.response.send_message(content = f"-# {interaction.user.name}({interaction.user.nick})\n-# Devutils\n<a:loading2:1296923111177850931>`Please wait... Running checks...`")
if interaction.user.name == "tjc472":
if prompt == "q":
await interaction.edit_original_response(content = f"-# {interaction.user.name}({interaction.user.nick})\n-# Devutils\n-# Message search\n-# Random quote:\n<a:loading2:1296923111177850931>`Please wait... Searching logs...`")
f = open("log.txt")
quotes = f.read()
f.close()
quotes = quotes.split("\n")
f = open("quoteblacklist.txt")
quoteblacklist = f.read()
f.close()
quoteblacklist = quoteblacklist.split("\n")
search = True
searchattempts = 0
while search:
try:
quote = random.choice(quotes)
quoteduser = quote.split(": ")[0]
quotedmessage = quote.split(": ")[1].replace("@everyone", "").replace("@here", "").replace("[lb]", "\n")
if quoteduser.split("(", 1)[0] in quoteblacklist:
search = True
else:
search = False
except:
pass
searchattempts = searchattempts + 1
if searchattempts > 50000000:
search = False
quotedmessage = "`No Quote found(Timed out)`"
quoteduser = "`Error`"
if searchattempts == 10000000:
await interaction.edit_original_response(content=f"-# {interaction.user.name}({interaction.user.nick})\n-# Devutils\n-# Message search\n-# Random quote:\n<a:loading2:1296923111177850931>`Please wait... Searching logs... 10000000 Messages Searched`")
if searchattempts == 20000000:
await interaction.edit_original_response(content=f"-# {interaction.user.name}({interaction.user.nick})\n-# Devutils\n-# Message search\n-# Random quote:\n<a:loading2:1296923111177850931>`Please wait... Searching logs... 20000000 Messages Searched`")
if searchattempts == 30000000:
await interaction.edit_original_response(content=f"-# {interaction.user.name}({interaction.user.nick})\n-# Devutils\n-# Message search\n-# Random quote:\n<a:loading2:1296923111177850931>`Please wait... Searching logs... 30000000 Messages Searched`")
if searchattempts == 40000000:
await interaction.edit_original_response(content=f"-# {interaction.user.name}({interaction.user.nick})\n-# Devutils\n-# Message search\n-# Random quote:\n<a:loading2:1296923111177850931>`Please wait... Searching logs... 40000000 Messages Searched Cancelling soon...`")
await interaction.edit_original_response(content = f"-# Devutils\n-# Message search\n-# Quote from {quoteduser}:\n{quotedmessage}")
elif prompt.startswith("s="):
searchterm = prompt.split("s=", 1)[1]
f = open("log.txt")
quotes = f.read()
f.close()
quotes = quotes.split("\n")
results = []
for message in quotes:
if searchterm in message:
results.append(message)
resultamount = len(results)
results = []
cancel = False
for message in quotes:
if searchterm in message:
results.append(message)
if len(results) > 9:
break
output = ""
for result in results:
output = output + "```" + result + "```"
if len(output) > 2000:
cancel = True
break
output = ""
for result in results:
output = output + "```" + result + "```"
if len(results) == 0:
output = "\nNothing found"
if not cancel:
await interaction.edit_original_response(content = f"-# {interaction.user.name}({interaction.user.nick})\n-# Devutils\n-# Message search\n`{resultamount} Results:`\n{output}")
else:
await interaction.edit_original_response(content = f"-# {interaction.user.name}({interaction.user.nick})\n-# Devutils\n-# Message search\n`{resultamount} Potential Results`\nOutput too long for message.")
else:
if prompt.startswith("m="):
requestlogchannel = self.bot.get_channel(1331091527308673056)
searchterm = prompt.split("m=", 1)[1]
await requestlogchannel.send(searchterm)
await interaction.edit_original_response(content = f"-# {interaction.user.name}({interaction.user.nick})\n-# Devutils\nSent Message successfully")
else:
if prompt == "penis":
await interaction.edit_original_response(content = f"-# {interaction.user.name}({interaction.user.nick})\n-# Devutils\nStop the penising")
else:
if prompt == "join":
vc = await interaction.channel.connect()
vc.play(discord.FFmpegPCMAudio("music.mp3"))
await interaction.edit_original_response(content = f"-# {interaction.user.name}({interaction.user.nick})\nmeow")
#await asyncio.sleep(31)
#await vc.disconnect()
else:
await interaction.edit_original_response(content = f"-# {interaction.user.name}({interaction.user.nick})\n-# Devutils\n`Invalid Prompt!`\nDid you misspell something?")
else:
await interaction.edit_original_response(content = f"-# {interaction.user.name}({interaction.user.nick})\n-# Devutils\n`No permission!`")
@app_commands.command(description = "Eval some code :3")
@app_commands.describe(
prompt='code to eval(maybe)'
)
@app_commands.allowed_installs(guilds = True, users = True)
@app_commands.allowed_contexts(guilds = True, dms = True, private_channels = True)
async def eval(self, interaction: discord.Interaction, prompt: str = ""):
if interaction.user.name == "tjc472":
await interaction.response.send_modal(EvalModal())
else:
if "please" in prompt:
await interaction.response.send_message(content = "ok you did say please but seriously? im not gonna run some code bruh shut up")
else:
await interaction.response.send_message(content = "if you say please maybe")
@app_commands.command(description = "Exec some code :3")
@app_commands.describe(
prompt='code to exec(maybe)'
)
@app_commands.allowed_installs(guilds = True, users = True)
@app_commands.allowed_contexts(guilds = True, dms = True, private_channels = True)
async def exec(self, interaction: discord.Interaction, prompt: str = ""):
if interaction.user.name == "tjc472":
await interaction.response.send_modal(ExecModal())
else:
if "please" in prompt:
await interaction.response.send_message(content = "ok you did say please but seriously? im not gonna run some code bruh shut up")
else:
await interaction.response.send_message(content = "if you say please maybe")
@app_commands.command(description = "funny :3")
@app_commands.allowed_installs(guilds = True, users = True)
@app_commands.allowed_contexts(guilds = True, dms = True, private_channels = True)
async def funny(self, interaction: discord.Interaction):
logger.info(interaction.user.id) # LEB bot reference
await interaction.response.send_message(content = "a")
@app_commands.command(description = "lebload a file :3")
@app_commands.allowed_installs(guilds = True, users = True)
@app_commands.allowed_contexts(guilds = True, dms = True, private_channels = True)
async def lebload(self, interaction: discord.Interaction):
await interaction.response.send_message(content = "your curl is incorrect, its either not a post or its not a multipart form data, please have your curl command like this: curl -X POST https://de-1.tjcsucht.net/lebload -F file=@{filename}")
async def setup(bot: commands.Bot):
await bot.add_cog(Dev(bot))