Cleanup in resources

This commit is contained in:
Nikolaj Danger committed 2020-03-24 16:25:24 +01:00
1 parent 780e32fcc6
commit b2a47ce11a
16 files changed
+23 -25

No files matched your search

+1 -1
View File
@@ -34,7 +34,7 @@ async def on_message(message):
localtime = time.asctime( time.localtime(time.time()) ) localtime = time.asctime( time.localtime(time.time()) )
print("\n"+localtime+"\n"+message.author.name+" ran !help") print("\n"+localtime+"\n"+message.author.name+" ran !help")
logging.info("\n"+localtime+"\n"+message.author.name+" ran !help") logging.info("\n"+localtime+"\n"+message.author.name+" ran !help")
with codecs.open("help.txt",encoding="utf-8") as f: with codecs.open("resources/help.txt",encoding="utf-8") as f:
text = f.read() text = f.read()
print(text) print(text)
em = discord.Embed(title = "Help", description = text,colour = 0x59f442) em = discord.Embed(title = "Help", description = text,colour = 0x59f442)
-3
View File
@@ -7,9 +7,6 @@ import urllib #used by imageFunc
import imdb #used by movieFunc import imdb #used by movieFunc
from .roll import dice from .roll import dice
from .lookup import lookupFuncs
from .other import movie, generators
from .swfuncs import swchar, swroll
def roll_dice(author : str, rollStr : str = "1d20"): def roll_dice(author : str, rollStr : str = "1d20"):
print("Rolling "+str(rollStr)) print("Rolling "+str(rollStr))
+2 -2
View File
@@ -25,7 +25,7 @@ def monsterFunc(content):
logging.info("Monster doesn't exist in database\n") logging.info("Monster doesn't exist in database\n")
return("I don't know that monster...","","","","","") return("I don't know that monster...","","","","","")
else: else:
data = json.load(open('funcs/lookup/monsters.json', encoding = "utf8")) data = json.load(open('resources/monsters.json', encoding = "utf8"))
for monster in data: for monster in data:
if str(command) == monster["name"]: if str(command) == monster["name"]:
print("Found it!") print("Found it!")
@@ -117,7 +117,7 @@ def spellFunc(content):
command = gf.cap(content.lower().replace("!spell ","")) command = gf.cap(content.lower().replace("!spell ",""))
print("Looking up "+command) print("Looking up "+command)
logging.info("Looking up "+command) logging.info("Looking up "+command)
data = json.load(open('funcs/lookup/spells.json', encoding = "utf8")) data = json.load(open('resources/spells.json', encoding = "utf8"))
if str(command) in data: if str(command) in data:
print("Returning spell information") print("Returning spell information")
logging.info("Returning spell information") logging.info("Returning spell information")
+1 -1
View File
@@ -8,7 +8,7 @@ def make_pairs(corpus):
yield (corpus[i], corpus[i+1]) yield (corpus[i], corpus[i+1])
def nameGen(): def nameGen():
names = open('funcs/other/names.txt', encoding='utf8').read() names = open('resources/names.txt', encoding='utf8').read()
corpus = list(names) corpus = list(names)
pairs = make_pairs(corpus) pairs = make_pairs(corpus)
+1 -1
View File
@@ -7,7 +7,7 @@ def movieFunc():
ia = imdb.IMDb() ia = imdb.IMDb()
print("Picking a movie") print("Picking a movie")
movs = open("funcs/other/movies.txt", "r") movs = open("resources/movies.txt", "r")
movlist = movs.read().split("\n") movlist = movs.read().split("\n")
mov = random.choice(movlist) mov = random.choice(movlist)
movs.close() movs.close()
+10 -10
View File
@@ -2,7 +2,7 @@ import json
import string import string
def getName(user : str): def getName(user : str):
with open("funcs/swfuncs/characters.json", "r") as f: with open("resources/swcharacters.json", "r") as f:
data = json.load(f) data = json.load(f)
if user in data: if user in data:
@@ -81,7 +81,7 @@ def characterSheet(character : dict):
return name, text1+"\n\n"+text2+divider+text3 return name, text1+"\n\n"+text2+divider+text3
def charData(user : str,cmd : str): def charData(user : str,cmd : str):
with open("funcs/swfuncs/characters.json", "r") as f: with open("resources/swcharacters.json", "r") as f:
data = json.load(f) data = json.load(f)
key = string.capwords(cmd.split(" ")[0]) key = string.capwords(cmd.split(" ")[0])
@@ -107,7 +107,7 @@ def charData(user : str,cmd : str):
if type(lookUpResult) is dict: if type(lookUpResult) is dict:
data[user][key] = lookUpResult data[user][key] = lookUpResult
with open("funcs/swfuncs/characters.json", "w") as f: with open("resources/swcharacters.json", "w") as f:
json.dump(data,f,indent = 4) json.dump(data,f,indent = 4)
return "Changed " + data[user]["Name"] + "'s " + key return "Changed " + data[user]["Name"] + "'s " + key
else: else:
@@ -133,7 +133,7 @@ def charData(user : str,cmd : str):
return "Can't add that" return "Can't add that"
else: else:
data[user][key] = cmd data[user][key] = cmd
with open("funcs/swfuncs/characters.json", "w") as f: with open("resources/swcharacters.json", "w") as f:
json.dump(data,f,indent = 4) json.dump(data,f,indent = 4)
return "Changed " + data[user]["Name"] + "'s " + key +" to " + cmd return "Changed " + data[user]["Name"] + "'s " + key +" to " + cmd
else: else:
@@ -142,7 +142,7 @@ def charData(user : str,cmd : str):
return "You don't have a character. You can make one with !swchar" return "You don't have a character. You can make one with !swchar"
def parseChar(user : str, cmd : str): def parseChar(user : str, cmd : str):
with open("funcs/swfuncs/characters.json", "r") as f: with open("resources/swcharacters.json", "r") as f:
data = json.load(f) data = json.load(f)
if cmd == " ": if cmd == " ":
@@ -157,30 +157,30 @@ def parseChar(user : str, cmd : str):
if user in data: if user in data:
return characterSheet(data[user]) return characterSheet(data[user])
else: else:
with open("funcs/swfuncs/templates.json", "r") as f: with open("resources/swtemplates.json", "r") as f:
templates = json.load(f) templates = json.load(f)
newChar = templates["Character"] newChar = templates["Character"]
data[user] = newChar data[user] = newChar
with open("funcs/swfuncs/characters.json", "w") as f: with open("resources/swcharacters.json", "w") as f:
json.dump(data,f,indent = 4) json.dump(data,f,indent = 4)
return "", "Character for " + user + " created" return "", "Character for " + user + " created"
else: else:
if cmd == "purge": if cmd == "purge":
del data[user] del data[user]
with open("funcs/swfuncs/characters.json", "w") as f: with open("resources/swcharacters.json", "w") as f:
json.dump(data,f,indent = 4) json.dump(data,f,indent = 4)
return "", "Character for " + user + " deleted" return "", "Character for " + user + " deleted"
return "", charData(user,cmd) return "", charData(user,cmd)
def lightsaberChar(user : str): def lightsaberChar(user : str):
with open("funcs/swfuncs/characters.json", "r") as f: with open("resources/swcharacters.json", "r") as f:
data = json.load(f) data = json.load(f)
if user in data: if user in data:
return data[user]["Lightsaber Characteristic"] return data[user]["Lightsaber Characteristic"]
def userHasChar(user : str): def userHasChar(user : str):
with open("funcs/swfuncs/characters.json", "r") as f: with open("resources/swcharacters.json", "r") as f:
data = json.load(f) data = json.load(f)
return user in data return user in data
+2 -1
View File
@@ -2,10 +2,11 @@ import random
import re import re
import string import string
import json import json
import os
from . import swchar from . import swchar
with open("funcs/swfuncs/skills.json", "r") as f: with open("resources/swskills.json", "r") as f:
skillData = json.load(f) skillData = json.load(f)
def roll(abi : int = 1, prof : int = 0, dif : int = 3, cha : int = 0, boo : int = 0, setb : int = 0, force : int = 0): def roll(abi : int = 1, prof : int = 0, dif : int = 3, cha : int = 0, boo : int = 0, setb : int = 0, force : int = 0):
View File
File renamed without changes.
File renamed without changes.
@@ -303,13 +303,13 @@ Fantastic Four
Fantastic Mr Fox Fantastic Mr Fox
Fargo Fargo
The Fast and the Furious The Fast and the Furious
The Fast and the Furious 2 (2 Fast 2 Furious) 2 Fast 2 Furious
The Fast and the Furious 3 (Tokyo Drift) The Fast and the Furious Tokyo Drift
The Fast and the Furious 4 (Fast & Furious) Fast & Furious
The Fast and the Furious 5 (Fast Five) Fast Five
The Fast and the Furious 6 The Fast and the Furious 6
The Fast and the Furious 7 (Furious 7) Furious 7
The Fast and the Furious 8 (The Fate of the Furious) The Fate of the Furious
Fast and Furious Presents: Hobbs and Shaw Fast and Furious Presents: Hobbs and Shaw
Fast Times of Ridgemont High Fast Times of Ridgemont High
The Fault in Our Stars The Fault in Our Stars
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.