Comments
This commit is contained in:
@ -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)
|
||||
|
Reference in New Issue
Block a user