Adding minecraft map functionality back to the bot

This commit is contained in:
Luke Robles 2020-05-05 17:47:35 -07:00
parent 7748a54d3c
commit e770ed86a6

View File

@ -412,104 +412,97 @@ async def on_message(message):
# if message.content.startswith('!minecraft'): if message.content.startswith('!minecraft'):
# # Check permissions # Figure out what action they want to take
# if not role_check.docker_permissions(message.author.roles): action = message.content.split()[1]
# await client.send_message( if action == 'map':
# message.channel, await client.send_message(
# "You dont have permission to run docker commands" message.channel,
# ) "https://luker.gq/minecraft"
# return )
# if len(message.content.split()) == 1: # if len(message.content.split()) == 1:
# actions = ['restart', 'status', 'logs', 'map'] # actions = ['restart', 'status', 'logs']
# await client.send_message( # await client.send_message(
# message.channel, # message.channel,
# "\nSupported actions:```\n{}```".format(", ".join(actions)) # "\nSupported actions:```\n{}```".format(", ".join(actions))
# ) # )
# else: # else:
# docker_client = docker.from_env() # docker_client = docker.from_env()
# try: # try:
# minecraft_container = docker_client.containers.get('beyondreality') # minecraft_container = docker_client.containers.get('minecraft_eternal')
# except: # except:
# await client.send_message( # await client.send_message(
# message.channel, # message.channel,
# "The minecraft server is not running" # "The minecraft server is not running"
# ) # )
# return # return
# # Figure out what action they want to take # if action == 'restart':
# action = message.content.split()[1] # await client.send_message(
# if action == 'restart': # message.channel,
# await client.send_message( # "{}, restart the server? [!yes/!no]".format(
# message.channel, # message.author.mention)
# "{}, restart the server? [!yes/!no]".format( # )
# message.author.mention)
# )
# confirm_restart = await client.wait_for_message( # confirm_restart = await client.wait_for_message(
# author=message.author, # author=message.author,
# channel=message.channel, # channel=message.channel,
# content='!yes' # content='!yes'
# ) # )
# if confirm_restart: # if confirm_restart:
# await client.send_message( # await client.send_message(
# message.channel, # message.channel,
# "Sending restart action to {} server".format( # "Sending restart action to {} server".format(
# minecraft_container.name # minecraft_container.name
# ) # )
# ) # )
# minecraft_container.restart() # minecraft_container.restart()
# if action == 'status': # if action == 'status':
# await client.send_message( # await client.send_message(
# message.channel, # message.channel,
# "{} server is {}".format( # "{} server is {}".format(
# minecraft_container.name, # minecraft_container.name,
# minecraft_container.status # minecraft_container.status
# ) # )
# ) # )
# if action == 'logs': # if action == 'logs':
# if len(message.content.split()) == 3: # if len(message.content.split()) == 3:
# num_lines = int(message.content.split()[2]) # num_lines = int(message.content.split()[2])
# else: # else:
# num_lines = 10 # num_lines = 10
# log_stream = minecraft_container.logs( # log_stream = minecraft_container.logs(
# tail=num_lines # tail=num_lines
# ).decode('utf-8') # ).decode('utf-8')
# if len(log_stream) >= num_lines: # if len(log_stream) >= num_lines:
# await client.send_message( # await client.send_message(
# message.channel, # message.channel,
# "Pulling last {} lines from the {} server ".format( # "Pulling last {} lines from the {} server ".format(
# num_lines, # num_lines,
# minecraft_container.name # minecraft_container.name
# ) # )
# ) # )
# await client.send_message( # await client.send_message(
# message.channel, # message.channel,
# "```{}```".format( # "```{}```".format(
# minecraft_container.logs( # minecraft_container.logs(
# tail=num_lines # tail=num_lines
# ).decode('utf-8') # ).decode('utf-8')
# ) # )
# ) # )
# else: # else:
# await client.send_message( # await client.send_message(
# message.channel, # message.channel,
# "There arent {} lines of output yet".format(num_lines) # "There arent {} lines of output yet".format(num_lines)
# ) # )
# if action == 'map':
# await client.send_message(
# message.channel,
# "https://luker.gq/minecraft"
# )
client.run(os.getenv('token')) client.run(os.getenv('token'))