Skip to content

Commit

Permalink
guilded bot now uses api.astroid.cc instead of astroid.deutscher775.de
Browse files Browse the repository at this point in the history
  • Loading branch information
Deutscher775 committed Nov 9, 2024
1 parent e2fd766 commit b6c5c9e
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions src/Bot/guilded_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ async def on_ready():
async def on_message_delete(message: guilded.Message):
try:
async with aiohttp.ClientSession() as session:
async with session.get(f"https://astroid.deutscher775.de/getendpoint/guilded?id={message.server_id}&token={config.MASTER_TOKEN}") as response:
async with session.get(f"https://api.astroid.cc/getendpoint/guilded?id={message.server_id}&token={config.MASTER_TOKEN}") as response:
data = await response.json()
endpoint = data["discord"]
except:
traceback.print_exc()
return
try:
async with aiohttp.ClientSession() as session:
async with session.get(f"https://astroid.deutscher775.de/{endpoint}?token={config.MASTER_TOKEN}") as response:
async with session.get(f"https://api.astroid.cc/{endpoint}?token={config.MASTER_TOKEN}") as response:
data = await response.json()
if data["config"]["isbeta"]:
return
Expand All @@ -84,7 +84,7 @@ async def on_message_delete(message: guilded.Message):
traceback.print_exc()

channels_url = (
f"https://astroid.deutscher775.de/{endpoint}?token={config.MASTER_TOKEN}"
f"https://api.astroid.cc/{endpoint}?token={config.MASTER_TOKEN}"
)
channels_data = await fetch_json(channels_url)

Expand All @@ -100,7 +100,7 @@ async def on_message_delete(message: guilded.Message):
)

logs_url = (
f"https://astroid.deutscher775.de/{endpoint}?token={config.MASTER_TOKEN}"
f"https://api.astroid.cc/{endpoint}?token={config.MASTER_TOKEN}"
)
logs_data = await fetch_json(logs_url)

Expand All @@ -112,15 +112,15 @@ async def on_message_delete(message: guilded.Message):
async def on_message_edit(before: guilded.Message, after: guilded.Message):
try:
async with aiohttp.ClientSession() as session:
async with session.get(f"https://astroid.deutscher775.de/getendpoint/guilded?id={before.server_id}&token={config.MASTER_TOKEN}") as response:
async with session.get(f"https://api.astroid.cc/getendpoint/guilded?id={before.server_id}&token={config.MASTER_TOKEN}") as response:
data = await response.json()
endpoint = data["discord"]
except:
traceback.print_exc()
return
try:
async with aiohttp.ClientSession() as session:
async with session.get(f"https://astroid.deutscher775.de/{endpoint}?token={config.MASTER_TOKEN}") as response:
async with session.get(f"https://api.astroid.cc/{endpoint}?token={config.MASTER_TOKEN}") as response:
data = await response.json()
if data["config"]["isbeta"]:
return
Expand All @@ -132,7 +132,7 @@ async def on_message_edit(before: guilded.Message, after: guilded.Message):
traceback.print_exc()

channels_url = (
f"https://astroid.deutscher775.de/{endpoint}?token={config.MASTER_TOKEN}"
f"https://api.astroid.cc/{endpoint}?token={config.MASTER_TOKEN}"
)
channels_data = await fetch_json(channels_url)

Expand All @@ -147,7 +147,7 @@ async def on_message_edit(before: guilded.Message, after: guilded.Message):
embed.add_field(name="After", value=after.content, inline=False)

logs_url = (
f"https://astroid.deutscher775.de/{endpoint}?token={config.MASTER_TOKEN}"
f"https://api.astroid.cc/{endpoint}?token={config.MASTER_TOKEN}"
)
logs_data = await fetch_json(logs_url)

Expand All @@ -161,7 +161,7 @@ async def register(ctx: commands.Context, endpoint):
await ctx.send("Invalid Format: `a!register DISCORD_SERVER_ID`")
else:
async with aiohttp.ClientSession() as session:
async with session.get(f"https://astroid.deutscher775.de/getendpoint/guilded?id={ctx.message.server_id}&token={config.MASTER_TOKEN}") as response:
async with session.get(f"https://api.astroid.cc/getendpoint/guilded?id={ctx.message.server_id}&token={config.MASTER_TOKEN}") as response:
data = await response.json()
try:
_endpoint = data["discord"]
Expand All @@ -172,23 +172,23 @@ async def register(ctx: commands.Context, endpoint):
await ctx.send("This server is registered with another endpoint. For further assistance, please contact the support server.")
except KeyError:
async with aiohttp.ClientSession() as session:
async with session.post(f"https://astroid.deutscher775.de/createendpoint/guilded?endpoint={endpoint}&id={ctx.message.server_id}&token={config.MASTER_TOKEN}") as response:
async with session.post(f"https://api.astroid.cc/createendpoint/guilded?endpoint={endpoint}&id={ctx.message.server_id}&token={config.MASTER_TOKEN}") as response:
if response.status == 200:
await ctx.send(f"Registered endpoint: https://astroid.deutscher775.de/{endpoint}")
await ctx.send(f"Registered endpoint: https://api.astroid.cc/{endpoint}")
else:
await ctx.send(f"Oops, something went wrong: `{data['message']}`")
except IndexError:
async with aiohttp.ClientSession() as session:
async with session.post(f"https://astroid.deutscher775.de/createendpoint/guilded?endpoint={endpoint}&id={ctx.message.server_id}&token={config.MASTER_TOKEN}") as response:
async with session.post(f"https://api.astroid.cc/createendpoint/guilded?endpoint={endpoint}&id={ctx.message.server_id}&token={config.MASTER_TOKEN}") as response:
if response.status == 200:
await ctx.send(f"Registered endpoint: https://astroid.deutscher775.de/{endpoint}")
await ctx.send(f"Registered endpoint: https://api.astroid.cc/{endpoint}")
else:
await ctx.send(f"Oops, something went wrong: `{data['message']}`")
except TypeError:
async with aiohttp.ClientSession() as session:
async with session.post(f"https://astroid.deutscher775.de/createendpoint/guilded?endpoint={endpoint}&id={ctx.message.server_id}&token={config.MASTER_TOKEN}") as response:
async with session.post(f"https://api.astroid.cc/createendpoint/guilded?endpoint={endpoint}&id={ctx.message.server_id}&token={config.MASTER_TOKEN}") as response:
if response.status == 200:
await ctx.send(f"Registered endpoint: https://astroid.deutscher775.de/{endpoint}")
await ctx.send(f"Registered endpoint: https://api.astroid.cc/{endpoint}")
else:
await ctx.send(f"Oops, something went wrong: `{data['message']}`")
except Exception as e:
Expand All @@ -199,10 +199,10 @@ async def register(ctx: commands.Context, endpoint):
channel_webhook = await ctx.channel.create_webhook(name="astroid")
channel_webhook_url = channel_webhook.url
async with aiohttp.ClientSession() as session:
async with session.post(f"https://astroid.deutscher775.de/update/{endpoint}?channel_guilded={channel_id}&webhook_guilded={channel_webhook_url}&token={config.MASTER_TOKEN}") as response:
async with session.post(f"https://api.astroid.cc/update/{endpoint}?channel_guilded={channel_id}&webhook_guilded={channel_webhook_url}&token={config.MASTER_TOKEN}") as response:
data = await response.json()
if response.ok:
await ctx.send(f"Updated endpoint: https://astroid.deutscher775.de/{endpoint}")
await ctx.send(f"Updated endpoint: https://api.astroid.cc/{endpoint}")
else:
await ctx.send(f"Oops, something went wrong: `{data['message']}`")
except Exception as e:
Expand All @@ -211,7 +211,7 @@ async def register(ctx: commands.Context, endpoint):
@client.command()
async def help(ctx):
embed = guilded.Embed(
title="astroid", description="API Docs: https://astroid.deutscher775.de/docs"
title="astroid", description="API Docs: https://api.astroid.cc/docs"
)
embed.add_field(
name="register",
Expand Down Expand Up @@ -244,12 +244,12 @@ async def set_log(ctx, endpoint, channelid):
)
else:
r = await post_json(
f"https://astroid.deutscher775.de/update/{endpoint}?channel_guilded={ctx.channel.id}&log_guilded={channelid}&token={config.MASTER_TOKEN}",
f"https://api.astroid.cc/update/{endpoint}?channel_guilded={ctx.channel.id}&log_guilded={channelid}&token={config.MASTER_TOKEN}",
{},
)
if r.ok:
await ctx.send(
f"Updated endpoint: https://astroid.deutscher775.de/{endpoint}"
f"Updated endpoint: https://api.astroid.cc/{endpoint}"
)
else:
await ctx.send(f"{r['message']}")
Expand All @@ -261,12 +261,12 @@ async def allow(ctx, endpoint, allowid):
await ctx.send("Invalid Format: `a!allow DISCORD_SERVER_ID GUILDED_USER_ID`")
else:
r = await post_json(
f"https://astroid.deutscher775.de/update/{endpoint}?allowed_ids={allowid}&token={config.MASTER_TOKEN}",
f"https://api.astroid.cc/update/{endpoint}?allowed_ids={allowid}&token={config.MASTER_TOKEN}",
{},
)
if r.ok:
await ctx.send(
f"Updated endpoint: https://astroid.deutscher775.de/{endpoint}"
f"Updated endpoint: https://api.astroid.cc/{endpoint}"
)
else:
await ctx.send(f"{r['message']}")
Expand All @@ -279,12 +279,12 @@ async def add_bridge(ctx, endpoint):
else:
webhook = await ctx.channel.create_webhook(name="astroid")
r = await post_json(
f"https://astroid.deutscher775.de/update/{endpoint}?channel_guilded={ctx.channel.id}&webhook_guilded={webhook.url}&token={config.MASTER_TOKEN}",
f"https://api.astroid.cc/update/{endpoint}?channel_guilded={ctx.channel.id}&webhook_guilded={webhook.url}&token={config.MASTER_TOKEN}",
{},
)
if r.ok:
await ctx.send(
f"Updated endpoint: https://astroid.deutscher775.de/{endpoint}"
f"Updated endpoint: https://api.astroid.cc/{endpoint}"
)
else:
await ctx.send(f"{r['message']}")
Expand All @@ -305,12 +305,12 @@ async def send_embed(ctx):
async def on_message(message: guilded.Message):
try:
async with aiohttp.ClientSession() as session:
async with session.get(f"https://astroid.deutscher775.de/getendpoint/guilded?id={message.server_id}&token={config.MASTER_TOKEN}") as response:
async with session.get(f"https://api.astroid.cc/getendpoint/guilded?id={message.server_id}&token={config.MASTER_TOKEN}") as response:
data = await response.json()
endpoint = data["discord"]
try:
async with aiohttp.ClientSession() as session:
async with session.get(f"https://astroid.deutscher775.de/{endpoint}?token={config.MASTER_TOKEN}") as response:
async with session.get(f"https://api.astroid.cc/{endpoint}?token={config.MASTER_TOKEN}") as response:
data = await response.json()
if data["config"]["isbeta"]:
return
Expand All @@ -325,7 +325,7 @@ async def on_message(message: guilded.Message):
await client.process_commands(message)
async with aiohttp.ClientSession() as session:
async with session.get(
f"https://astroid.deutscher775.de/{endpoint}?token={config.MASTER_TOKEN}"
f"https://api.astroid.cc/{endpoint}?token={config.MASTER_TOKEN}"
) as response:
data = await response.json()
if message.channel.id in data["config"]["channels"]["guilded"]:
Expand All @@ -345,7 +345,7 @@ async def on_message(message: guilded.Message):
if not message.author.bot or message.author.id in allowed_ids:
if not message.attachments and not message.embeds:
async with session.post(
f"https://astroid.deutscher775.de/update/{endpoint}?message_content={message.content}&message_author_name={message.author.name}&message_author_avatar={message.author.avatar.url if message.author.avatar.url else 'https://astroid.deutscher775.de/assets/Astroid PFP not found.png'}&message_author_id={message.author.id}&trigger=true&sender=guilded&token={config.MASTER_TOKEN}&sender_channel={message.channel.id}"
f"https://api.astroid.cc/update/{endpoint}?message_content={message.content}&message_author_name={message.author.name}&message_author_avatar={message.author.avatar.url if message.author.avatar.url else 'https://api.astroid.cc/assets/Astroid PFP not found.png'}&message_author_id={message.author.id}&trigger=true&sender=guilded&token={config.MASTER_TOKEN}&sender_channel={message.channel.id}"
) as response:
pass
elif message.embeds:
Expand All @@ -360,7 +360,7 @@ async def on_message(message: guilded.Message):
elif message.attachments:
if len(message.attachments) == 1:
async with session.post(
f"https://astroid.deutscher775.de/update/{endpoint}?message_content={message.content}&message_author_name={message.author.name}&message_author_avatar={message.author.avatar.url if message.author.avatar.url else 'https://astroid.deutscher775.de/assets/Astroid PFP not found.png'}&message_author_id={message.author.id}&trigger=true&sender=guilded&token={config.MASTER_TOKEN}&sender_channel={message.channel.id}&message_attachments={message.attachments[0].url.replace('![]', '').replace('(', '').replace(')', '')}"
f"https://api.astroid.cc/update/{endpoint}?message_content={message.content}&message_author_name={message.author.name}&message_author_avatar={message.author.avatar.url if message.author.avatar.url else 'https://api.astroid.cc/assets/Astroid PFP not found.png'}&message_author_id={message.author.id}&trigger=true&sender=guilded&token={config.MASTER_TOKEN}&sender_channel={message.channel.id}&message_attachments={message.attachments[0].url.replace('![]', '').replace('(', '').replace(')', '')}"
) as response:
pass
else:
Expand All @@ -372,7 +372,7 @@ async def on_message(message: guilded.Message):
.replace(")", "")
)
async with session.post(
f"https://astroid.deutscher775.de/update/{endpoint}?message_content={message.content}&message_author_name={message.author.name}&message_author_avatar={message.author.avatar.url if message.author.avatar.url else 'https://astroid.deutscher775.de/assets/Astroid PFP not found.png'}&message_author_id={message.author.id}&trigger=true&sender=guilded&token={config.MASTER_TOKEN}&sender_channel={message.channel.id}&message_attachments={attachments[:-1]}"
f"https://api.astroid.cc/update/{endpoint}?message_content={message.content}&message_author_name={message.author.name}&message_author_avatar={message.author.avatar.url if message.author.avatar.url else 'https://api.astroid.cc/assets/Astroid PFP not found.png'}&message_author_id={message.author.id}&trigger=true&sender=guilded&token={config.MASTER_TOKEN}&sender_channel={message.channel.id}&message_attachments={attachments[:-1]}"
) as response:
pass
except FileNotFoundError:
Expand Down

0 comments on commit b6c5c9e

Please sign in to comment.