Browse Source

Added setup.py for easy setup. Need to test it yet tho.

tags/v1.8.0
Roxie Gibson 6 years ago
parent
commit
a3b9a2b7c9
3 changed files with 91 additions and 9 deletions
  1. +2
    -6
      main.py
  2. +14
    -3
      roxbot/settings/preferences_example.ini
  3. +75
    -0
      setup.py

+ 2
- 6
main.py View File

@@ -38,6 +38,7 @@ from roxbot import guild_settings as gs


# REMEMBER TO UNCOMMENT THE GSS LINE, ROXIE
# DO NOT UNCOMMENT GSS IF YOU ARE NOT ROXIE

cogs = [
"roxbot.cogs.admin",
@@ -95,9 +96,6 @@ async def on_ready():
print(server)
print("")

# In the next two functions, I was gunna user bot.settings for something but I don't think it's possible.
# So while I don't use it, the function still will do their jobs of adding and removing the settings.


@bot.event
async def on_guild_join(guild):
@@ -113,8 +111,6 @@ async def on_guild_remove(guild):
async def on_message(message):
"""
Checks if the user is blacklisted, if not, process the message for commands as usual.
:param message:
:return:
"""
if roxbot.blacklisted(message.author):
return
@@ -124,7 +120,7 @@ async def on_message(message):
@bot.command()
async def about(ctx):
"""
Outputs info about RoxBot, showing uptime, how to report issues, what settings where set in prefs.ini and credits.
Outputs info about RoxBot, showing up time, how to report issues, what settings where set in prefs.ini and credits.
"""
owner = bot.get_user(roxbot.owner)
em = discord.Embed(title="About Roxbot", colour=roxbot.EmbedColours.pink, description=roxbot.__description__)

+ 14
- 3
roxbot/settings/preferences_example.ini View File

@@ -3,9 +3,20 @@ OwnerID=451192272349036545
Command_Prefix=r;

[Tokens]
; Discord: REQUIRED
; Imgur: Used in the reddit cog. This is your Client ID
; Explaination:
; Discord: This is the Token given when you register your bot account. (REQUIRED)
; Imgur: Used in the reddit cog. This is your Client ID, given when you register a client with Imgur.
; Tastsumaki: Only used by custom GSSP cog. Normal users can ignore.
Discord=TokenHere
Imgur=TokenHere
Tatsumaki=TokenHere
Tatsumaki=TokenHere

[Backups]
; Settings for the servers.json backups.
; This is the file that contains all settings for all servers the bot is in.

; Explaintion:
; enabled: Whether or not backups should be enabled. This is heavily recommened to be kept on.
; rate: The amount of time in seconds that the bot will check for changes in the settings file to backup. Default: 300 # 5 Minutes
enabled=True
rate=300

+ 75
- 0
setup.py View File

@@ -0,0 +1,75 @@
import os
import sys
import configparser

# Version Checking
# Basically reject anything not 3.5 or 3.6 as those are the only versions that work.

if not sys.version_info[:2] == (3, 5) or sys.version_info[:2] == (3, 6):
print("Roxbot does not support Python {}".format(".".join(sys.version_info[:2])))
exit(0)

# Install Requirements

code = os.system("python3 -m pip install -r requirements.txt")
if code != 0:
print("Error occurred while installing requirements. Exiting...")
exit(1)
else:
print("Requirements successfully installed.")

# Create preferences file.

with open("roxbot/settings/preferences_example.ini", "r") as orig:
fp = orig.read()
with open("roxbot/settings/preferences.ini", "w") as new:
new.write(fp)
print("Preferences file created")

# Ask to do preferences.ini setup

print("Most of the setup is complete. All there is to do is setup the preferences.ini file.")
print("You can do the quick setup in this script, or manually setup the file yourself.")
while True:
choice = input("Do you want to continue to the easy preferences setup? (y/n): ")
if choice.strip(" ").lower() == "y":
print("You can leave the field empty if you don't have the required thing.")
print("Note: Everything that is asked here is required and not having it can lead ot issues.")
break
elif choice.strip(" ").lower() == "n":
print("Exiting...")
exit(0)

# Preferences.ini setup

config = configparser.ConfigParser()
config.read("roxbot/settings/preferences.ini")
print("Setting up preferences file...")

owner_id = str(input("Bot Owner ID: ")).strip(" ")
if not owner_id or not owner_id.isdigit():
print("Invalid owner ID given. Skipping...")
else:
config["Roxbot"]["OwnerID"] = owner_id

prefix = str(input("Command Prefix: ")).strip(" ")
if not prefix:
print("Invalid Owner ID given. Skipping...")
else:
config["Roxbot"]["Command_Prefix"] = prefix

token = str(input("Discord Bot Token: ")).strip(" ")
if not token:
print("Invalid token given. Skipping...")
else:
config["Tokens"]["Discord"] = token

token = str(input("Imgur Client ID: ")).strip(" ")
if not token:
print("Invalid client ID given. Skipping...")
else:
config["Tokens"]["Imgur"] = token

print("Finished preferences.ini setup.")
print("There are more options avaliable in the file (found at ./roxbot/settings/preferences.ini) if you want to make optional tweaks to Roxbot.")
print("Exiting...")

Loading…
Cancel
Save