Comments
This commit is contained in:
@ -202,4 +202,3 @@ async def on_message(message):
|
||||
|
||||
# Runs the whole shabang
|
||||
client.run(token)
|
||||
|
||||
|
@ -8,6 +8,7 @@ import imdb #used by movieFunc
|
||||
|
||||
from .roll import dice
|
||||
|
||||
# I stole this. It rolls dice. I am not qualified to comment it
|
||||
def roll_dice(author : str, rollStr : str = "1d20"):
|
||||
print("Rolling "+str(rollStr))
|
||||
if rollStr == '0/0': # easter eggs
|
||||
@ -28,8 +29,8 @@ def roll_dice(author : str, rollStr : str = "1d20"):
|
||||
print("")
|
||||
return(outputs)
|
||||
|
||||
# Capitalizes all words except some of them
|
||||
no_caps_list = ["of","the"]
|
||||
|
||||
def cap(s):
|
||||
word_number = 0
|
||||
lst = s.split()
|
||||
@ -49,6 +50,7 @@ def time_in_range(start, end, x):
|
||||
else:
|
||||
return start <= x or x <= end
|
||||
|
||||
# Responds with a greeting of a time-aprpriate maner
|
||||
def helloFunc(author):
|
||||
print("")
|
||||
now = datetime.datetime.now()
|
||||
@ -65,7 +67,9 @@ def helloFunc(author):
|
||||
else:
|
||||
return("Why hello, "+str(author))
|
||||
|
||||
# Finds a random picture online
|
||||
def imageFunc():
|
||||
# Picks a type of camera, which decides the naming scheme
|
||||
cams = ("one","two","three","four")
|
||||
cam = random.choice(cams)
|
||||
if cam == "one":
|
||||
@ -88,12 +92,17 @@ def imageFunc():
|
||||
c = str(random.randint(0,9))
|
||||
d = str(random.randint(0,9))
|
||||
search = ("DSC_"+a+b+c+d)
|
||||
|
||||
# Searches for the image and reads the resulting web page
|
||||
page = urllib.request.urlopen("https://www.bing.com/images/search?q="+search+"&safesearch=off")
|
||||
read = page.read()
|
||||
tree = lxml.etree.HTML(read)
|
||||
images = tree.xpath('//a[@class = "thumb"]/@href')
|
||||
|
||||
# Picks an image
|
||||
number = random.randint(1,len(images))-1
|
||||
image = images[number]
|
||||
print("Successfully returned an image")
|
||||
print("")
|
||||
|
||||
# Returns the image
|
||||
print("Successfully returned an image\n")
|
||||
return(image)
|
||||
|
@ -7,6 +7,7 @@ from funcs import gwendolynFuncs as gf
|
||||
|
||||
logging.basicConfig(filename="gwendolyn.log", level=logging.INFO)
|
||||
|
||||
# Calculates D&D stat modifier
|
||||
def modifier(statistic):
|
||||
mods = math.floor((statistic-10)/2)
|
||||
if mods >= 0:
|
||||
@ -16,15 +17,19 @@ def modifier(statistic):
|
||||
saves = ["strength_save","dexterity_save","constitution_save","intelligence_save","wisdom_save","charisma_save"]
|
||||
abilities = ["acrobatics","animal_handling","arcana","athletics","deception","history","insight","intimidation","investigation","medicine","nature","perception","performance","persuasion","religion","sleight_of_hand","stealth","survival"]
|
||||
|
||||
# Looks up a monster
|
||||
def monsterFunc(content):
|
||||
command = gf.cap(content.lower().replace("!monster ",""))
|
||||
print("Looking up "+command)
|
||||
logging.info("Looking up "+command)
|
||||
|
||||
# 1-letter monsters don't exist
|
||||
if len(content.lower().split()) < 2:
|
||||
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:
|
||||
# Opens "mensters.json"
|
||||
data = json.load(open('resources/monsters.json', encoding = "utf8"))
|
||||
for monster in data:
|
||||
if str(command) == monster["name"]:
|
||||
@ -124,10 +129,13 @@ def monsterFunc(content):
|
||||
logging.info("Couldn't find monster")
|
||||
return("I don't know that monster...","","","","","")
|
||||
|
||||
# Looks up a spell
|
||||
def spellFunc(content):
|
||||
command = gf.cap(content.lower().replace("!spell ",""))
|
||||
print("Looking up "+command)
|
||||
logging.info("Looking up "+command)
|
||||
|
||||
# Opens "spells.json"
|
||||
data = json.load(open('resources/spells.json', encoding = "utf8"))
|
||||
if str(command) in data:
|
||||
print("Returning spell information")
|
||||
|
@ -4,48 +4,65 @@ import logging
|
||||
|
||||
logging.basicConfig(filename="gwendolyn.log", level=logging.INFO)
|
||||
|
||||
# Returns a list of all letter pairs in the text
|
||||
def make_pairs(corpus):
|
||||
for i in range(len(corpus)-1):
|
||||
yield (corpus[i], corpus[i+1])
|
||||
|
||||
# Generates a random name
|
||||
def nameGen():
|
||||
# Makes a list of all names from "names.txt"
|
||||
names = open('resources/names.txt', encoding='utf8').read()
|
||||
corpus = list(names)
|
||||
|
||||
# Makes a list of pairs
|
||||
pairs = make_pairs(corpus)
|
||||
|
||||
word_dict = {}
|
||||
letter_dict = {}
|
||||
|
||||
for word_1, word_2 in pairs:
|
||||
if word_1 in word_dict.keys():
|
||||
word_dict[word_1].append(word_2)
|
||||
# Makes a dictionary of all letters that come after all other letters
|
||||
for letter_1, letter_2 in pairs:
|
||||
if letter_1 in letter_dict.keys():
|
||||
letter_dict[letter_1].append(letter_2)
|
||||
else:
|
||||
word_dict[word_1] = [word_2]
|
||||
letter_dict[letter_1] = [letter_2]
|
||||
|
||||
first_word = random.choice(corpus)
|
||||
# Choses a random first letter
|
||||
first_letter = random.choice(corpus)
|
||||
|
||||
while first_word.islower() or first_word == " " or first_word == "-" or first_word == "\n":
|
||||
first_word = random.choice(corpus)
|
||||
# Makes sure the first letter is not something a name can't start with.
|
||||
while first_letter.islower() or first_letter == " " or first_letter == "-" or first_letter == "\n":
|
||||
first_letter = random.choice(corpus)
|
||||
|
||||
chain = [first_word]
|
||||
# Starts the name
|
||||
chain = [first_letter]
|
||||
|
||||
done = False
|
||||
|
||||
# Creates the name one letter at a time
|
||||
while done == False:
|
||||
new_letter = random.choice(word_dict[chain[-1]])
|
||||
new_letter = random.choice(letter_dict[chain[-1]])
|
||||
chain.append(new_letter)
|
||||
# Ends name if the name ends
|
||||
if new_letter == "\n":
|
||||
done = True
|
||||
genName = "".join(chain)
|
||||
print("Generated "+genName)
|
||||
logging.info("Generated "+genName)
|
||||
# Returns the name
|
||||
return(genName)
|
||||
|
||||
# Generates a random tavern name
|
||||
def tavernGen():
|
||||
# Lists first parts, second parts and third parts of tavern names
|
||||
fp = ["The Silver","The Golden","The Staggering","The Laughing","The Prancing","The Gilded","The Running","The Howling","The Slaughtered","The Leering","The Drunken","The Leaping","The Roaring","The Frowning","The Lonely","The Wandering","The Mysterious","The Barking","The Black","The Gleaming","The Tap-Dancing","The Sad","The Sexy","The Artificial","The Groovy","The Merciful","The Confused","The Pouting","The Horny","The Okay","The Friendly","The Hungry","The Handicapped","The Fire-breathing","The One-Eyed","The Psychotic","The Mad","The Evil","The Idiotic","The Trusty","The Busty"]
|
||||
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","","","","","","","","",""]
|
||||
|
||||
# Picks one of each
|
||||
genTav = random.choice(fp)+" "+random.choice(sp)+random.choice(tp)
|
||||
print("Generated "+genTav)
|
||||
logging.info("Generated "+genTav)
|
||||
|
||||
# Return the name
|
||||
return(genTav)
|
||||
|
@ -4,6 +4,7 @@ import logging
|
||||
|
||||
logging.basicConfig(filename="gwendolyn.log", level=logging.INFO)
|
||||
|
||||
# Picks a random movie and returns information about it
|
||||
def movieFunc():
|
||||
try:
|
||||
print("Creating IMDb object")
|
||||
|
Reference in New Issue
Block a user