Skip to content

Commit

Permalink
new command_buffer_time variable
Browse files Browse the repository at this point in the history
server_command() will now wait specified time between sending command to server and reading log for output/response. 

E.g. PaperMC is lightweight and fast, so 1s should be enough, vanilla should be about the same, also keep in mind your PC specs and how that effects performance. A Forge heavily modded server will take longer, for me (currently using Valhesia Volatile (~161 mods) 3s is needed (possibly more).
  • Loading branch information
0n1udra committed Apr 9, 2022
1 parent f17350a commit 310c3b0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 37 deletions.
3 changes: 1 addition & 2 deletions source/backend_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ async def inactive_msg():
elif slime_vars.use_tmux is True:
# Checks if server is active in the first place by sending random number to be matched in server log.
os.system(f'tmux send-keys -t {slime_vars.tmux_session_name}:0.0 "{status_checker}" ENTER')
await asyncio.sleep(2)
await asyncio.sleep(slime_vars.command_buffer_time)
if not server_log(random_number):
await inactive_msg()
return False
Expand All @@ -155,7 +155,6 @@ async def inactive_msg():
await inactive_msg()
return False

await asyncio.sleep(1)
# Checks server log if command went through.
return_data = [server_log(command), None]
if stop_at_checker is True:
Expand Down
2 changes: 1 addition & 1 deletion source/slime_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1955,7 +1955,7 @@ async def secretpanel(self, ctx):

lprint(ctx, 'Opened secret panel')

@commands.command(aliases=['player', 'ppanel'])
@commands.command(aliases=['player', 'ppanel', 'pc'])
async def playerpanel(self, ctx, player=''):
"""Select player from list (or all, random) and use quick action buttons."""

Expand Down
44 changes: 10 additions & 34 deletions source/slime_vars.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os


# Set this variable if you're also using Debian based system. if not ignore this and manually set your file/folder paths.
user = '0n1udra'

Expand Down Expand Up @@ -57,14 +56,18 @@
'ulibrary': ['ulibrary', 'The Uncensored Library.', f'java -Xmx3G -Xms1G -jar server.jar nogui'],
}

server_selected = server_list['papermc']
server_selected = server_list['vvolatile']
server_path = f"{mc_path}/{server_selected[0]}"
# Where to save world and server backups.
world_backups_path = f"{mc_path}/world_backups/{server_selected[0]}"
server_backups_path = f"{mc_path}/server_backups/{server_selected[0]}"

# ========== Bot Config
log_lines_limit = 100 # Max number of log lines to read.
log_lines_limit = 100 # Max number of log lines to read. Increase if server is really busy (has a lot ouf console logging)

# Wait time (in seconds) between sending command to MC server and reading server logs for output.
# Time between receiving command and logging output varies depending on PC specs, MC server type (papermc, vanilla, forge, etc), and how many mods.
command_buffer_time = 3

# Autosave functionality. interval is in minutes.
autosave_status = False
Expand All @@ -74,9 +77,10 @@
mc_subprocess = None # If using subprocess, this is will be the Minecraft server.

# For '?links' command. Shows helpful websites.
useful_websites = {'Forge Downnload (Download 35.1.13 Installer)': 'https://files.minecraftforge.net/',
useful_websites = {'Valhesia Volatile': 'https://www.curseforge.com/minecraft/modpacks/valhelsia-volatile',
'Valhesia Volatile Guide': 'https://drive.google.com/drive/folders/1WpuMlZ30bloWE4GckDYWyBaNeO_8gLOK?usp=sharing',
'Forge Installer': 'https://files.minecraftforge.net/',
'CurseForge Download': 'https://curseforge.overwolf.com/',
'Valhesia 3.1': 'https://www.curseforge.com/minecraft/modpacks/valhelsia-3',
'Modern HD Resource Pack': 'https://minecraftred.com/modern-hd-resource-pack/',
'Minecraft Server Commands': 'https://minecraft.gamepedia.com/Commands#List_and_summary_of_commands',
'Minecraft /gamerule Commands': 'https://minecraft.gamepedia.com/Game_rule',
Expand All @@ -91,32 +95,4 @@
server_ip = '' # Will be updated by get_ip function in backend_functions.py on bot startup.

if use_rcon is True: import mctools, re
if server_files_access is True: import shutil, fileinput, json

# All variables which will be saved in slime_vars_json.
all_variables = {'user': user,
'bot_token_file': bot_token_file,
'pyenv_activate_command': pyenv_activate_command,
'slime_vars_json': slime_vars_json,
'channel_id': channel_id,
'server_url': server_url,
'server_files_access': server_files_access,
'use_subprocess': use_subprocess,
'use_tmux': use_tmux,
'use_rcon': use_rcon,
'rcon_pass': rcon_pass,
'rcon_port': rcon_port,
'mc_path': mc_path,
'java_params': java_params,
'server_list': server_list,
'server_selected': server_selected,
'world_backups_path': world_backups_path,
'server_backup_path': server_backups_path,
'log_lines_limit': log_lines_limit,
'autosave_status': autosave_status,
'autosave_interval': autosave_interval,
'mc_active_status': mc_active_status,
'mc_subprocess': mc_subprocess,
'useful_websites': useful_websites,
}

if server_files_access is True: import shutil, fileinput, json

0 comments on commit 310c3b0

Please sign in to comment.