From de6ee115e7836f3799317842a6ed2008ecd1377f Mon Sep 17 00:00:00 2001 From: Nikolaj Danger Date: Tue, 24 Mar 2020 11:09:31 +0100 Subject: [PATCH] More logging --- .gitignore | 4 ++++ Gwendolyn.py | 7 +++++-- funcs/lookup/lookupFuncs.py | 19 +++++++++++++------ 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 28fa97c..832f63e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,10 @@ # Byte-compiled / optimized / DLL files __pycache__/ funcs/__pycache__/ +funcs/lookup/__pycache__/ +funcs/other/__pycache__/ +funcs/roll/__pycache__/ +funcs/swfuncs/__pycache__/ *.py[cod] *$py.class diff --git a/Gwendolyn.py b/Gwendolyn.py index 6a2172a..5615e22 100644 --- a/Gwendolyn.py +++ b/Gwendolyn.py @@ -9,7 +9,7 @@ import codecs import funcs -logging.basicConfig(filename="logfilename.log", level=logging.INFO) +logging.basicConfig(filename="gwendolyn.log", level=logging.INFO) with open("token.txt","r") as f: token =f.read() @@ -40,7 +40,10 @@ async def on_message(message): em = discord.Embed(title = "Help", description = text,colour = 0x59f442) await message.channel.send(embed = em) - if message.content.lower().startswith("!hello"): + elif message.content.lower().startswith("!stop"): + await client.logout() + + elif message.content.lower().startswith("!hello"): localtime = time.asctime( time.localtime(time.time()) ) print("\n"+localtime+"\n"+message.author.name+" ran !hello") logging.info("\n"+localtime+"\n"+message.author.name+" ran !hello") diff --git a/funcs/lookup/lookupFuncs.py b/funcs/lookup/lookupFuncs.py index bf050b9..05b6759 100644 --- a/funcs/lookup/lookupFuncs.py +++ b/funcs/lookup/lookupFuncs.py @@ -1,10 +1,11 @@ import math import discord import json +import logging from funcs import gwendolynFuncs as gf - +logging.basicConfig(filename="gwendolyn.log", level=logging.INFO) def modifier(statistic): mods = math.floor((statistic-10)/2) @@ -18,15 +19,17 @@ abilities = ["acrobatics","animal_handling","arcana","athletics","deception","hi def monsterFunc(content): command = gf.cap(content.lower().replace("!monster ","")) print("Looking up "+command) + logging.info("Looking up "+command) if len(content.lower().split()) < 2: - print("Monster doesn't exist in database") - print("") + print("Monster doesn't exist in database\n") + logging.info("Monster doesn't exist in database\n") return("I don't know that monster...","","","","","") else: data = json.load(open('funcs/lookup/monsters.json', encoding = "utf8")) for monster in data: - print("Found it!") if str(command) == monster["name"]: + print("Found it!") + logging.info("Found it!") if monster["subtype"] != "": typs = (monster["type"]+" ("+monster["subtype"]+")") else: @@ -104,8 +107,8 @@ def monsterFunc(content): text3 = (act) text4 = (react) text5 = (leg_act) - print("Returning monster information") - print("") + print("Returning monster information\n") + logging.info("Returning monster information\n") return(str(command),text1,text2,text3,text4,text5) print("") return("I don't know that monster...","","","","","") @@ -113,12 +116,16 @@ def monsterFunc(content): def spellFunc(content): command = gf.cap(content.lower().replace("!spell ","")) print("Looking up "+command) + logging.info("Looking up "+command) data = json.load(open('funcs/lookup/spells.json', encoding = "utf8")) if str(command) in data: print("Returning spell information") + logging.info("Returning spell information") spell_output = ("***"+str(command)+"***\n*"+str(data[str(command)]["level"])+" level "+str(data[str(command)]["school"])+"\nCasting Time: "+str(data[str(command)]["casting_time"])+"\nRange: "+str(data[str(command)]["range"])+"\nComponents: "+str(data[str(command)]["components"])+"\nDuration: "+str(data[str(command)]["duration"])+"*\n \n"+str(data[str(command)]["description"])) else: print("I don't know that spell") + logging.info("I don't know that spell") spell_output = "I don't think that's a spell" print("Successfully ran !spell") + logging.info("Successfully ran !spell") return(spell_output)