|
@ -27,6 +27,7 @@ guild_id = int(os.getenv('guild_id')) |
|
|
verification_channel = int(os.getenv('verification_channel')) |
|
|
verification_channel = int(os.getenv('verification_channel')) |
|
|
verification_message = int(os.getenv('verification_message')) |
|
|
verification_message = int(os.getenv('verification_message')) |
|
|
application_api_key = os.getenv('application_api_key') |
|
|
application_api_key = os.getenv('application_api_key') |
|
|
|
|
|
running_on_panel = bool(os.getenv('running_on_panel')) |
|
|
|
|
|
|
|
|
logging.basicConfig(filename='console.log', |
|
|
logging.basicConfig(filename='console.log', |
|
|
level=logging.INFO, |
|
|
level=logging.INFO, |
|
@ -44,12 +45,13 @@ async def on_ready(): |
|
|
|
|
|
|
|
|
@bot.event |
|
|
@bot.event |
|
|
async def on_message(message): |
|
|
async def on_message(message): |
|
|
|
|
|
if running_on_panel == False: |
|
|
# Account link |
|
|
# Account link |
|
|
|
|
|
|
|
|
# Binflop |
|
|
# Binflop |
|
|
if len(message.attachments) > 0: |
|
|
if len(message.attachments) > 0: |
|
|
if not message.attachments[0].url.endswith( |
|
|
|
|
|
('.png', '.jpg', '.jpeg', '.mp4', '.mov', '.avi', '.gif', '.image')): |
|
|
|
|
|
|
|
|
if message.attachments[0].url.endswith( |
|
|
|
|
|
('.png', '.jpg', '.jpeg', '.mp4', '.mov', '.avi', '.gif', '.image')) == False: |
|
|
download = message.attachments[0].url |
|
|
download = message.attachments[0].url |
|
|
async with aiohttp.ClientSession() as session: |
|
|
async with aiohttp.ClientSession() as session: |
|
|
async with session.get(download, allow_redirects=True) as r: |
|
|
async with session.get(download, allow_redirects=True) as r: |
|
@ -78,6 +80,7 @@ async def on_message(message): |
|
|
|
|
|
|
|
|
@bot.event |
|
|
@bot.event |
|
|
async def on_raw_reaction_add(payload): |
|
|
async def on_raw_reaction_add(payload): |
|
|
|
|
|
if running_on_panel == True: |
|
|
global verification_message |
|
|
global verification_message |
|
|
global verification_channel |
|
|
global verification_channel |
|
|
if payload.message_id != verification_message: |
|
|
if payload.message_id != verification_message: |
|
@ -119,12 +122,16 @@ async def on_raw_reaction_add(payload): |
|
|
|
|
|
|
|
|
@bot.command() |
|
|
@bot.command() |
|
|
async def ping(ctx): |
|
|
async def ping(ctx): |
|
|
await ctx.send(f'Bot ping is {round(bot.latency * 1000)}ms') |
|
|
|
|
|
|
|
|
if running_on_panel == True: |
|
|
|
|
|
await ctx.send(f'Private bot ping is {round(bot.latency * 1000)}ms') |
|
|
|
|
|
if running_on_panel == False: |
|
|
|
|
|
await ctx.send(f'Public bot ping is {round(bot.latency * 1000)}ms') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@bot.command(name="react", pass_context=True) |
|
|
@bot.command(name="react", pass_context=True) |
|
|
@has_permissions(administrator=True) |
|
|
@has_permissions(administrator=True) |
|
|
async def react(ctx, url, reaction): |
|
|
async def react(ctx, url, reaction): |
|
|
|
|
|
if running_on_panel == False: |
|
|
channel = await bot.fetch_channel(int(url.split("/")[5])) |
|
|
channel = await bot.fetch_channel(int(url.split("/")[5])) |
|
|
message = await channel.fetch_message(int(url.split("/")[6])) |
|
|
message = await channel.fetch_message(int(url.split("/")[6])) |
|
|
await message.add_reaction(reaction) |
|
|
await message.add_reaction(reaction) |
|
@ -157,10 +164,10 @@ async def updater(): |
|
|
i += 1 |
|
|
i += 1 |
|
|
already_exists = False |
|
|
already_exists = False |
|
|
for server2 in modified_servers['servers']: |
|
|
for server2 in modified_servers['servers']: |
|
|
if not already_exists: |
|
|
|
|
|
|
|
|
if already_exists == False: |
|
|
if server['attributes']['uuid'] == server2['uuid']: |
|
|
if server['attributes']['uuid'] == server2['uuid']: |
|
|
already_exists = True |
|
|
already_exists = True |
|
|
if not already_exists: |
|
|
|
|
|
|
|
|
if already_exists == False: |
|
|
headers = { |
|
|
headers = { |
|
|
'Accept': 'application/json', |
|
|
'Accept': 'application/json', |
|
|
'Content-Type': 'application/json', |
|
|
'Content-Type': 'application/json', |
|
@ -175,6 +182,7 @@ async def updater(): |
|
|
server['attributes']['feature_limits']['databases']) + ', "allocations": ' + str( |
|
|
server['attributes']['feature_limits']['databases']) + ', "allocations": ' + str( |
|
|
server['attributes']['feature_limits']['allocations']) + ', "backups": 3 } }' |
|
|
server['attributes']['feature_limits']['allocations']) + ', "backups": 3 } }' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async with aiohttp.ClientSession() as session: |
|
|
async with aiohttp.ClientSession() as session: |
|
|
async with session.patch('https://panel.birdflop.com/api/application/servers/' + str(server['attributes']['id']) + '/build', headers=headers, data=data) as response: |
|
|
async with session.patch('https://panel.birdflop.com/api/application/servers/' + str(server['attributes']['id']) + '/build', headers=headers, data=data) as response: |
|
|
if response.status == 200: |
|
|
if response.status == 200: |
|
@ -257,13 +265,20 @@ async def before_updater(): |
|
|
await bot.wait_until_ready() |
|
|
await bot.wait_until_ready() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if running_on_panel == True: |
|
|
for file_name in os.listdir('./cogs'): |
|
|
for file_name in os.listdir('./cogs'): |
|
|
if file_name.endswith('.py'): |
|
|
|
|
|
|
|
|
if file_name.endswith('_panel.py'): |
|
|
|
|
|
bot.load_extension(f'cogs.{file_name[:-3]}') |
|
|
|
|
|
else: |
|
|
|
|
|
for file_name in os.listdir('./cogs'): |
|
|
|
|
|
if file_name.endswith('_public.py'): |
|
|
bot.load_extension(f'cogs.{file_name[:-3]}') |
|
|
bot.load_extension(f'cogs.{file_name[:-3]}') |
|
|
|
|
|
|
|
|
|
|
|
if running_on_panel == True: |
|
|
updater.start() |
|
|
updater.start() |
|
|
linking_updater = bot.get_cog('Linking_updater') |
|
|
linking_updater = bot.get_cog('Linking_updater') |
|
|
linking_updater.linking_updater.start() |
|
|
linking_updater.linking_updater.start() |
|
|
|
|
|
|
|
|
bot.run(token) |
|
|
bot.run(token) |
|
|
|
|
|
|
|
|
# full name: message.author.name + "#" + str(message.author.discriminator) + " (" + str(message.author.id) + ")" |
|
|
# full name: message.author.name + "#" + str(message.author.discriminator) + " (" + str(message.author.id) + ")" |
|
|