Skip to content
This repository was archived by the owner on Nov 12, 2018. It is now read-only.

Commit

Permalink
Renamed options to config
Browse files Browse the repository at this point in the history
The options.ini file is now called config.ini
  • Loading branch information
TBK committed Apr 28, 2017
1 parent bfff115 commit f8bc065
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 22 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ Commands are listed [here](https://github.com/DiscordMusicBot/MusicBot/wiki/Comm


### Configuration
The main configuration file is called `config/options.ini` and the permissions file is called `config/permissions.ini` by default they do not exist.
The main configuration file is called `config/config.ini` and the permissions file is called `config/permissions.ini` by default they do not exist.

Read the following Wiki pages to on how to create them:
- [Options](https://github.com/DiscordMusicBot/MusicBot/wiki/Configuration)
- [Configurations](https://github.com/DiscordMusicBot/MusicBot/wiki/Configuration)
- [Permissions](https://github.com/DiscordMusicBot/MusicBot/wiki/Permissions)


Expand Down
2 changes: 1 addition & 1 deletion config/example_options.ini → config/example_config.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
; DO NOT OPEN THIS FILE WITH NOTEPAD. If you don't have a preferred text
; editor, use Atom or notepad++ or any other modern text editor.
;
; If you edit example_options.ini, Save-As options.ini
; If you edit example_config.ini, Save-As config.ini
;
; This is the main configuration file for MusicBot. You will need to edit
; this file when you setup the bot. The bot must be restarted for edits to
Expand Down
4 changes: 2 additions & 2 deletions config/example_permissions.ini
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
; Allows the user to skip a song without having to vote, like the owner.
;
; AllowHigherVolume = no
; Allows the user to go past 100% volume up to the MaxVolume set in options.
; Allows the user to go past 100% volume up to the MaxVolume set in config.
; Enabling this will allow users to distort the volume if the MaxVolume is set higher than 100.
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Expand All @@ -77,7 +77,7 @@
;;;;;;;;;;;;;;;;;;;

; This is the fallback group for any users that don't get assigned to another group. Don't remove/rename this group.
; You cannot assign users or roles to this group. Those options are ignored.
; You cannot assign users or roles to this group. Those options are ignored.
[Default]
CommandWhitelist = play perms queue np skip search id help clean
; CommandBlacklist =
Expand Down
4 changes: 2 additions & 2 deletions musicbot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class MusicBot(discord.Client):
""" TODO """
def __init__(self, config_file=None, perms_file=None):
if config_file is None:
config_file = ConfigDefaults.options_file
config_file = ConfigDefaults.config_file

if perms_file is None:
perms_file = PermissionsDefaults.perms_file
Expand Down Expand Up @@ -1208,7 +1208,7 @@ def run(self):
# Add if token, else
raise exceptions.HelpfulError(
"Bot cannot login, bad credentials.",
"Fix your %s in the options file. "
"Fix your %s in the config.ini file. "
"Remember that each field should be on their own line."
% ['shit', 'Token', 'Email/Password',
'Credentials'][len(self.config.auth)]
Expand Down
25 changes: 12 additions & 13 deletions musicbot/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,7 @@ def run_checks(self):
"The ID should be just a number, approximately "
"18 characters long. "
"If you don't know what your ID is, read the "
"instructions in the options or ask in the "
"help server.",
"instructions in the config.ini file.",
preface=self._confpreface
)

Expand Down Expand Up @@ -231,12 +230,12 @@ def run_checks(self):

self.debug_mode = self.debug_level <= logging.DEBUG

# TODO: Add save function for future editing of options with commands
# TODO: Add save function for future editing of config with commands
# Maybe add warnings about fields missing from the config file

async def async_validate(self, bot):
""" TODO """
LOG.debug("Validating options...")
LOG.debug("Validating config...")

if self.owner_id == 'auto':
if not bot.user.bot:
Expand Down Expand Up @@ -278,15 +277,15 @@ def find_config(self):
you should probably turn file extensions on."
.format(self.config_file + '.ini', self.config_file))

elif os.path.isfile('config/example_options.ini'):
shutil.copy('config/example_options.ini', self.config_file)
elif os.path.isfile('config/example_config.ini'):
shutil.copy('config/example_config.ini', self.config_file)
LOG.warning(
'Options file not found, copying example_options.ini')
'Config file not found, copying example_config.ini')

else:
raise HelpfulError(
"Your config files are missing. Neither options.ini nor "
"example_options.ini were found.",
"Your config files are missing. Neither config.ini nor "
"example_config.ini were found.",
"Grab the files back from the archive or remake them "
"yourself and copy paste the content "
"from the repo. Stop removing important files!"
Expand All @@ -303,22 +302,22 @@ def find_config(self):
if not int(config.get('Permissions', 'OwnerID', fallback=0)):
print(flush=True)
LOG.critical(
"""Please configure config/options.ini
"""Please configure config/config.ini
and re-run the bot.""")
sys.exit(1)

except ValueError: # Config id value was changed but its not valid
raise HelpfulError(
'Invalid value "{}" for OwnerID, config cannot be loaded.'
.format(config.get('Permissions', 'OwnerID', fallback=None)),
"""The OwnerID option takes a user id,
"""The OwnerID option takes a user id,
fuck it i'll finish this message later."""
)

except Exception as error:
print(flush=True)
LOG.critical(
"Unable to copy config/example_options.ini to %s",
"Unable to copy config/example_config.ini to %s",
self.config_file, exc_info=error)
sys.exit(2)

Expand Down Expand Up @@ -368,7 +367,7 @@ class ConfigDefaults:
# TODO this will change when I add playlists
autoplaylist_file = 'config/autoplaylist.txt'
banned_file = 'config/banned.txt'
options_file = 'config/options.ini'
config_file = 'config/config.ini'


setattr(ConfigDefaults, codecs.decode(
Expand Down
4 changes: 2 additions & 2 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,9 +343,9 @@ def opt_check_disk_space(warnlimit_mb=200):

def ensure_files():
""" TODO """
if os.path.isfile('config/options.ini') is False and \
if os.path.isfile('config/config.ini') is False and \
os.path.isfile('config/permissions.ini') is False:
LOG.critical("""MISSING config/options.ini and config/permissions.ini!\n
LOG.critical("""MISSING config/config.ini and config/permissions.ini!\n
Either cp the config folder into the container or mount is as a volume!""")
return True

Expand Down

0 comments on commit f8bc065

Please sign in to comment.