Repository navigation
Expand file tree
/
Copy pathmain.py
More file actions
47 lines (34 loc) · 1.67 KB
/
Copy pathmain.py
File metadata and controls
47 lines (34 loc) · 1.67 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
from urllib.parse import urlparse, parse_qs
import discord
import chat_exporter
from discord.ext import commands
intents = discord.Intents.default()
intents.members = True
intents.message_content = True
bot = commands.Bot(command_prefix="!", intents=intents)
token = "" # Update your discord bot token here
domain_url = "http://localhost:20910" # Update the domain URL to match your server's address and port. If you're running the server locally, you can use "http://localhost:20910". If you're hosting it on a remote server, replace "localhost" with your server's IP address or domain name.
def convert_url(cdn_url):
parsed_url = urlparse(cdn_url)
path_parts = parsed_url.path.strip('/').split('/')
query_params = parse_qs(parsed_url.query)
ex_value = query_params.get('ex', [])[0] if 'ex' in query_params else ''
is_value = query_params.get('is', [])[0] if 'is' in query_params else ''
hm_value = query_params.get('hm', [])[0] if 'hm' in query_params else ''
filename = path_parts[-1] if path_parts else ''
new_url = f"{domain_url}/view/{path_parts[1]}/{path_parts[2]}/{filename}/{ex_value}/{is_value}/{hm_value}"
return new_url
@bot.command()
async def transcript(ctx: commands.Context):
await ctx.message.delete()
process_msg = await ctx.send("Generating transcript...")
transcript_file = await chat_exporter.quick_export(ctx.channel)
await process_msg.delete()
attachment_url = transcript_file.attachments[0].url
converted_url = convert_url(attachment_url)
link = converted_url
await transcript_file.edit(content=link)
@bot.event
async def on_ready():
print(bot.user.name + " is running!")
bot.run(token)