|
|
@ -27,6 +27,7 @@ guild_id = int(os.getenv('guild_id')) |
|
|
|
verification_channel = int(os.getenv('verification_channel')) |
|
|
|
verification_message = int(os.getenv('verification_message')) |
|
|
|
application_api_key = os.getenv('application_api_key') |
|
|
|
running_on_panel = bool(os.getenv('running_on_panel')) |
|
|
|
|
|
|
|
logging.basicConfig(filename='console.log', |
|
|
|
level=logging.INFO, |
|
|
@ -44,17 +45,18 @@ async def on_ready(): |
|
|
|
|
|
|
|
@bot.event |
|
|
|
async def on_message(message): |
|
|
|
if running_on_panel == False: |
|
|
|
# Account link |
|
|
|
|
|
|
|
# Binflop |
|
|
|
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 |
|
|
|
async with aiohttp.ClientSession() as session: |
|
|
|
async with session.get(download, allow_redirects=True) as r: |
|
|
|
|
|
|
|
# r = requests.get(download, allow_redirects=True) |
|
|
|
# r = requests.get(download, allow_redirects=True) |
|
|
|
text = await r.text() |
|
|
|
text = "\n".join(text.splitlines()) |
|
|
|
if '�' not in text: # If it's not an image/gif |
|
|
@ -78,6 +80,7 @@ async def on_message(message): |
|
|
|
|
|
|
|
@bot.event |
|
|
|
async def on_raw_reaction_add(payload): |
|
|
|
if running_on_panel == True: |
|
|
|
global verification_message |
|
|
|
global verification_channel |
|
|
|
if payload.message_id != verification_message: |
|
|
@ -119,12 +122,16 @@ async def on_raw_reaction_add(payload): |
|
|
|
|
|
|
|
@bot.command() |
|
|
|
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) |
|
|
|
@has_permissions(administrator=True) |
|
|
|
async def react(ctx, url, reaction): |
|
|
|
if running_on_panel == False: |
|
|
|
channel = await bot.fetch_channel(int(url.split("/")[5])) |
|
|
|
message = await channel.fetch_message(int(url.split("/")[6])) |
|
|
|
await message.add_reaction(reaction) |
|
|
@ -157,10 +164,10 @@ async def updater(): |
|
|
|
i += 1 |
|
|
|
already_exists = False |
|
|
|
for server2 in modified_servers['servers']: |
|
|
|
if not already_exists: |
|
|
|
if already_exists == False: |
|
|
|
if server['attributes']['uuid'] == server2['uuid']: |
|
|
|
already_exists = True |
|
|
|
if not already_exists: |
|
|
|
if already_exists == False: |
|
|
|
headers = { |
|
|
|
'Accept': 'application/json', |
|
|
|
'Content-Type': 'application/json', |
|
|
@ -175,6 +182,7 @@ async def updater(): |
|
|
|
server['attributes']['feature_limits']['databases']) + ', "allocations": ' + str( |
|
|
|
server['attributes']['feature_limits']['allocations']) + ', "backups": 3 } }' |
|
|
|
|
|
|
|
|
|
|
|
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: |
|
|
|
if response.status == 200: |
|
|
@ -257,13 +265,20 @@ async def before_updater(): |
|
|
|
await bot.wait_until_ready() |
|
|
|
|
|
|
|
|
|
|
|
for file_name in os.listdir('./cogs'): |
|
|
|
if file_name.endswith('.py'): |
|
|
|
if running_on_panel == True: |
|
|
|
for file_name in os.listdir('./cogs'): |
|
|
|
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]}') |
|
|
|
|
|
|
|
updater.start() |
|
|
|
linking_updater = bot.get_cog('Linking_updater') |
|
|
|
linking_updater.linking_updater.start() |
|
|
|
if running_on_panel == True: |
|
|
|
updater.start() |
|
|
|
linking_updater = bot.get_cog('Linking_updater') |
|
|
|
linking_updater.linking_updater.start() |
|
|
|
|
|
|
|
bot.run(token) |
|
|
|
|
|
|
|
# full name: message.author.name + "#" + str(message.author.discriminator) + " (" + str(message.author.id) + ")" |
|
|
|