Some logging and comments
This commit is contained in:
@ -70,6 +70,9 @@ async def on_message(message):
|
|||||||
logging.info("\n"+localtime+"\n"+message.author.name+" ran !monster")
|
logging.info("\n"+localtime+"\n"+message.author.name+" ran !monster")
|
||||||
title, text1, text2, text3, text4, text5 = funcs.monsterFunc(message.content)
|
title, text1, text2, text3, text4, text5 = funcs.monsterFunc(message.content)
|
||||||
em1 = discord.Embed(title = title, description = text1, colour=0xDEADBF)
|
em1 = discord.Embed(title = title, description = text1, colour=0xDEADBF)
|
||||||
|
|
||||||
|
# Sends the received information. Seperates into seperate messages if
|
||||||
|
# there is too much text
|
||||||
await message.channel.send(embed = em1)
|
await message.channel.send(embed = em1)
|
||||||
if text2 != "":
|
if text2 != "":
|
||||||
if len(text2) < 2048:
|
if len(text2) < 2048:
|
||||||
|
@ -30,6 +30,10 @@ def monsterFunc(content):
|
|||||||
if str(command) == monster["name"]:
|
if str(command) == monster["name"]:
|
||||||
print("Found it!")
|
print("Found it!")
|
||||||
logging.info("Found it!")
|
logging.info("Found it!")
|
||||||
|
|
||||||
|
# Looks at the information about the monster and returns that information
|
||||||
|
# in seperate variables, allowing Gwendolyn to know where to seperate
|
||||||
|
# the messages
|
||||||
if monster["subtype"] != "":
|
if monster["subtype"] != "":
|
||||||
typs = (monster["type"]+" ("+monster["subtype"]+")")
|
typs = (monster["type"]+" ("+monster["subtype"]+")")
|
||||||
else:
|
else:
|
||||||
@ -99,18 +103,25 @@ def monsterFunc(content):
|
|||||||
hit_dice += (" - "+str(con_mod * int(monster["hit_dice"].replace("d"," ").split()[0])*(-1)))
|
hit_dice += (" - "+str(con_mod * int(monster["hit_dice"].replace("d"," ").split()[0])*(-1)))
|
||||||
if con_mod > 0:
|
if con_mod > 0:
|
||||||
hit_dice += (" + "+str(con_mod * int(monster["hit_dice"].replace("d"," ").split()[0])))
|
hit_dice += (" + "+str(con_mod * int(monster["hit_dice"].replace("d"," ").split()[0])))
|
||||||
|
|
||||||
new_part = "\n--------------------"
|
new_part = "\n--------------------"
|
||||||
|
|
||||||
monster_type = monster["size"]+" "+typs+", "+monster["alignment"]+"*"
|
monster_type = monster["size"]+" "+typs+", "+monster["alignment"]+"*"
|
||||||
|
|
||||||
basic_info = "\n**Armor Class** "+str(monster["armor_class"])+"\n**Hit Points** "+str(monster["hit_points"])+" ("+hit_dice+")\n**Speed **"+monster["speed"]+new_part+"\n"
|
basic_info = "\n**Armor Class** "+str(monster["armor_class"])+"\n**Hit Points** "+str(monster["hit_points"])+" ("+hit_dice+")\n**Speed **"+monster["speed"]+new_part+"\n"
|
||||||
|
|
||||||
text1 = (monster_type+new_part+basic_info+stats+new_part+saving_throws+skills+vulnerabilities+resistances+immunities+c_immunities+"\n**Senses** "+monster["senses"]+"\n**Languages** "+monster["languages"]+"\n**Challenge** "+monster["challenge_rating"])
|
text1 = (monster_type+new_part+basic_info+stats+new_part+saving_throws+skills+vulnerabilities+resistances+immunities+c_immunities+"\n**Senses** "+monster["senses"]+"\n**Languages** "+monster["languages"]+"\n**Challenge** "+monster["challenge_rating"])
|
||||||
|
|
||||||
text2 = (spec_ab)
|
text2 = (spec_ab)
|
||||||
text3 = (act)
|
text3 = (act)
|
||||||
text4 = (react)
|
text4 = (react)
|
||||||
text5 = (leg_act)
|
text5 = (leg_act)
|
||||||
print("Returning monster information\n")
|
|
||||||
logging.info("Returning monster information\n")
|
print("Returning monster information")
|
||||||
|
logging.info("Returning monster information")
|
||||||
return(str(command),text1,text2,text3,text4,text5)
|
return(str(command),text1,text2,text3,text4,text5)
|
||||||
print("")
|
print("Couldn't find monster")
|
||||||
|
logging.info("Couldn't find monster")
|
||||||
return("I don't know that monster...","","","","","")
|
return("I don't know that monster...","","","","","")
|
||||||
|
|
||||||
def spellFunc(content):
|
def spellFunc(content):
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
import random
|
import random
|
||||||
|
import logging
|
||||||
|
|
||||||
|
logging.basicConfig(filename="gwendolyn.log", level=logging.INFO)
|
||||||
|
|
||||||
def make_pairs(corpus):
|
def make_pairs(corpus):
|
||||||
for i in range(len(corpus)-1):
|
for i in range(len(corpus)-1):
|
||||||
@ -37,6 +38,7 @@ def nameGen():
|
|||||||
done = True
|
done = True
|
||||||
genName = "".join(chain)
|
genName = "".join(chain)
|
||||||
print("Generated "+genName)
|
print("Generated "+genName)
|
||||||
|
logging.info("Generated "+genName)
|
||||||
return(genName)
|
return(genName)
|
||||||
|
|
||||||
def tavernGen():
|
def tavernGen():
|
||||||
@ -44,5 +46,6 @@ def tavernGen():
|
|||||||
sp = ["Eel","Dolphin","Dwarf","Pegasus","Pony","Rose","Stag","Wolf","Lamb","Demon","Goat","Spirit","Horde","Jester","Mountain","Eagle","Satyr","Dog","Spider","Star","Dad","Rat","Jeremy","Mouse","Unicorn","Pearl","Ant","Crab","Penguin","Octopus","Lawyer","Ghost","Toad","Handjob","Immigrant","SJW","Dragon","Bard","Sphinx","Soldier","Salmon","Owlbear","Kite","Frost Giant","'̶̧̗̣̰̞̜̤̦̖͗̈́̏͊͒͜+̴͎̰͓̱̻̝̬̼͕̥͍̪͕̮͙͂͝*̶̲̓̊̏'̷̥̺͈̞͒̆̏͋̀̐̇͆̓͊͠'̷͖̱̟̟͉̝̪̮͕̃͑́̍͆̓̌͒̄͛̇͘̚ͅ!̷̡̻̈́#̸̳̰̿̿̏͐̏̓̌̚̚͠¨̷̟͙̱͎̟̱̅̀͋̇͗͂͋͋̕͘´̴̡̡͎͔̦̜̟̼̠̰̤͋́̀̓́̄́̏͂̀͜.̸̛̭͍̮̜͑̋̀̋̈́̇̆̆̌_̸̡̥̜̞̝̮̑͑̓̓̇͜͜^̴̡̢͕̠̖̤̺̭̮̙͕̼̳̺̼͋̿̏̎̑͑̊̀̅͐̚͝͝","Arsonist"]
|
sp = ["Eel","Dolphin","Dwarf","Pegasus","Pony","Rose","Stag","Wolf","Lamb","Demon","Goat","Spirit","Horde","Jester","Mountain","Eagle","Satyr","Dog","Spider","Star","Dad","Rat","Jeremy","Mouse","Unicorn","Pearl","Ant","Crab","Penguin","Octopus","Lawyer","Ghost","Toad","Handjob","Immigrant","SJW","Dragon","Bard","Sphinx","Soldier","Salmon","Owlbear","Kite","Frost Giant","'̶̧̗̣̰̞̜̤̦̖͗̈́̏͊͒͜+̴͎̰͓̱̻̝̬̼͕̥͍̪͕̮͙͂͝*̶̲̓̊̏'̷̥̺͈̞͒̆̏͋̀̐̇͆̓͊͠'̷͖̱̟̟͉̝̪̮͕̃͑́̍͆̓̌͒̄͛̇͘̚ͅ!̷̡̻̈́#̸̳̰̿̿̏͐̏̓̌̚̚͠¨̷̟͙̱͎̟̱̅̀͋̇͗͂͋͋̕͘´̴̡̡͎͔̦̜̟̼̠̰̤͋́̀̓́̄́̏͂̀͜.̸̛̭͍̮̜͑̋̀̋̈́̇̆̆̌_̸̡̥̜̞̝̮̑͑̓̓̇͜͜^̴̡̢͕̠̖̤̺̭̮̙͕̼̳̺̼͋̿̏̎̑͑̊̀̅͐̚͝͝","Arsonist"]
|
||||||
tp = [" Tavern"," Inn","","","","","","","","",""]
|
tp = [" Tavern"," Inn","","","","","","","","",""]
|
||||||
genTav = random.choice(fp)+" "+random.choice(sp)+random.choice(tp)
|
genTav = random.choice(fp)+" "+random.choice(sp)+random.choice(tp)
|
||||||
print("Generated "+genTav+"\n")
|
print("Generated "+genTav)
|
||||||
|
print("Generated "+genTav)
|
||||||
return(genTav)
|
return(genTav)
|
||||||
|
@ -1,21 +1,28 @@
|
|||||||
import imdb
|
import imdb
|
||||||
import random
|
import random
|
||||||
|
import logging
|
||||||
|
|
||||||
|
logging.basicConfig(filename="gwendolyn.log", level=logging.INFO)
|
||||||
|
|
||||||
def movieFunc():
|
def movieFunc():
|
||||||
try:
|
try:
|
||||||
print("Creating IMDb object")
|
print("Creating IMDb object")
|
||||||
|
logging.info("Creating IMDb object")
|
||||||
ia = imdb.IMDb()
|
ia = imdb.IMDb()
|
||||||
|
|
||||||
print("Picking a movie")
|
print("Picking a movie")
|
||||||
|
logging.info("Picking a movie")
|
||||||
movs = open("resources/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()
|
||||||
|
|
||||||
print("Searching for "+mov)
|
print("Searching for "+mov)
|
||||||
|
logging.info("Searching for "+mov)
|
||||||
s_result = ia.search_movie(mov)
|
s_result = ia.search_movie(mov)
|
||||||
|
|
||||||
print("Getting the data")
|
print("Getting the data")
|
||||||
|
logging.info("Getting the data")
|
||||||
movie = s_result[0]
|
movie = s_result[0]
|
||||||
ia.update(movie)
|
ia.update(movie)
|
||||||
cast = movie['cast']
|
cast = movie['cast']
|
||||||
@ -24,8 +31,9 @@ def movieFunc():
|
|||||||
if cast[x]:
|
if cast[x]:
|
||||||
pcast += cast[x]['name']+", "
|
pcast += cast[x]['name']+", "
|
||||||
print("Successfully ran !movie")
|
print("Successfully ran !movie")
|
||||||
print("")
|
logging.info("Successfully ran !movie")
|
||||||
return(movie['title'], movie['plot'][0].split("::")[0], movie['cover url'].replace("150","600").replace("101","404"), pcast[:-2])
|
return(movie['title'], movie['plot'][0].split("::")[0], movie['cover url'].replace("150","600").replace("101","404"), pcast[:-2])
|
||||||
except:
|
except:
|
||||||
print("Something bad happened...")
|
print("Something bad happened...")
|
||||||
|
logging.info("Something bad happened...")
|
||||||
return("error","","","")
|
return("error","","","")
|
||||||
|
@ -10,7 +10,7 @@ import numexpr
|
|||||||
|
|
||||||
from . import errors
|
from . import errors
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
logging.basicConfig(filename="gwendolyn.log", level=logging.INFO)
|
||||||
|
|
||||||
VALID_OPERATORS = 'k|rr|ro|mi|ma|ra|e|p'
|
VALID_OPERATORS = 'k|rr|ro|mi|ma|ra|e|p'
|
||||||
VALID_OPERATORS_ARRAY = VALID_OPERATORS.split('|')
|
VALID_OPERATORS_ARRAY = VALID_OPERATORS.split('|')
|
||||||
@ -41,10 +41,10 @@ def get_roll_comment(rollStr):
|
|||||||
no_comment = ''
|
no_comment = ''
|
||||||
dice_set = re.split('([-+*/().=])', rollStr)
|
dice_set = re.split('([-+*/().=])', rollStr)
|
||||||
dice_set = [d for d in dice_set if not d in (None, '')]
|
dice_set = [d for d in dice_set if not d in (None, '')]
|
||||||
log.debug("Found dice set: " + str(dice_set))
|
logging.debug("Found dice set: " + str(dice_set))
|
||||||
for index, dice in enumerate(dice_set):
|
for index, dice in enumerate(dice_set):
|
||||||
match = DICE_PATTERN.match(dice)
|
match = DICE_PATTERN.match(dice)
|
||||||
log.debug("Found dice group: " + str(match.groups()))
|
logging.debug("Found dice group: " + str(match.groups()))
|
||||||
no_comment += dice.replace(match.group(5), '')
|
no_comment += dice.replace(match.group(5), '')
|
||||||
if match.group(5):
|
if match.group(5):
|
||||||
comment = match.group(5) + ''.join(dice_set[index + 1:])
|
comment = match.group(5) + ''.join(dice_set[index + 1:])
|
||||||
@ -85,10 +85,10 @@ class Roll(object):
|
|||||||
# parse each, returning a SingleDiceResult
|
# parse each, returning a SingleDiceResult
|
||||||
dice_set = re.split('([-+*/().=])', rollStr)
|
dice_set = re.split('([-+*/().=])', rollStr)
|
||||||
dice_set = [d for d in dice_set if not d in (None, '')]
|
dice_set = [d for d in dice_set if not d in (None, '')]
|
||||||
log.debug("Found dice set: " + str(dice_set))
|
logging.debug("Found dice set: " + str(dice_set))
|
||||||
for index, dice in enumerate(dice_set):
|
for index, dice in enumerate(dice_set):
|
||||||
match = DICE_PATTERN.match(dice)
|
match = DICE_PATTERN.match(dice)
|
||||||
log.debug("Found dice group: " + str(match.groups()))
|
logging.debug("Found dice group: " + str(match.groups()))
|
||||||
# check if it's dice
|
# check if it's dice
|
||||||
if match.group(1):
|
if match.group(1):
|
||||||
roll = self.roll_one(dice.replace(match.group(5), ''), adv)
|
roll = self.roll_one(dice.replace(match.group(5), ''), adv)
|
||||||
@ -157,7 +157,7 @@ class Roll(object):
|
|||||||
skeleton=skeletonReply, raw_dice=self)
|
skeleton=skeletonReply, raw_dice=self)
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
if not isinstance(ex, (SyntaxError, KeyError, errors.AvraeException)):
|
if not isinstance(ex, (SyntaxError, KeyError, errors.AvraeException)):
|
||||||
log.error('Error in roll() caused by roll {}:'.format(rollStr))
|
logging.error('Error in roll() caused by roll {}:'.format(rollStr))
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
return DiceResult(verbose_result="Invalid input: {}".format(ex))
|
return DiceResult(verbose_result="Invalid input: {}".format(ex))
|
||||||
|
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
import json
|
import json
|
||||||
import string
|
import string
|
||||||
|
import logging
|
||||||
|
|
||||||
|
logging.basicConfig(filename="gwendolyn.log", level=logging.INFO)
|
||||||
|
|
||||||
def getName(user : str):
|
def getName(user : str):
|
||||||
with open("resources/swcharacters.json", "r") as f:
|
with open("resources/swcharacters.json", "r") as f:
|
||||||
|
Reference in New Issue
Block a user