Esempio n. 1
0
def main():
    wapi, user, citystr, newslink = h.kernfig()
    h.welcome(user)

    while True:
        wapi, user, citystr, newslink = h.kernfig()
        print(h.ask())
        uin = str.lower(input(">"))
        if "fetch" in uin:
            fetch.main(uin)

        elif "visit" in uin:
            for itemToVisit in h.giveComputerIndex(uin):
                newsfeed = h.grab(newslink)
                webbrowser.open(newsfeed.entries[itemToVisit - 1].link)

        elif "set" in uin:
            if "name" in uin:
                name = input("What would you like me to call you? ")
                h.cfgwriter("settings.cfg", 0, name)
            if "city" in uin:
                city = input("""
Changing weather location? Where to?
Must be in Wunderground form. """)
                h.cfgwriter("settings.cfg", 1, city)

        elif "name" and "pronounce" in uin:
            print(h.pipya() +
                  "My name is pronounced Pip-pah. The y is silent :).")

        elif "name" and ("how" or "where") and "get" in uin:
            print(h.pipya() + """\
My name started as pypa, for "python personal assistant". It morphed to pipya
for pronounceability. Thanks for asking!""")

        elif "what" and "can" and "do" in uin:
            h.capabilities()

        elif "who" and "are" and ("you" or "pipya") in uin:
            print(h.pipya() + """
I am Pipya, a personal assistant written in python3. My creator is brupoon.
He intended for me to be a jack-of-all-trades personal assistant operated by
a cli. I am a sexless, genderless entity, though my name is similar to the
human feminine "Pippa".
                """)

        elif uin in ["quit", "goodbye", "exit"]:
            print("Goodbye, {0}! 'Till next time.".format(user))
            sys.exit()

        elif uin in ["jellyfish"]:
            h.jellyfish()

        else:
            print("Pipya: Sorry, {0}, I didn't quite catch that.".format(user))
Esempio n. 2
0
def main():
    wapi, user, citystr,newslink = h.kernfig()
    h.welcome(user)

    while True:
        wapi, user, citystr,newslink = h.kernfig()
        print(h.ask())
        uin = str.lower(input(">"))
        if "fetch" in uin:
            fetch.main(uin)
            
        elif "visit" in uin:
            for itemToVisit in h.giveComputerIndex(uin):
                newsfeed = h.grab(newslink)
                webbrowser.open(newsfeed.entries[itemToVisit-1].link)

        elif "set" in uin:
            if "name" in uin:
                name = input("What would you like me to call you? ")
                h.cfgwriter("settings.cfg",0,name)
            if "city" in uin:
                city = input("""
Changing weather location? Where to?
Must be in Wunderground form. """)
                h.cfgwriter("settings.cfg",1,city)

        elif "name" and "pronounce" in uin:
            print(h.pipya()+"My name is pronounced Pip-pah. The y is silent :).")

        elif "name" and ("how" or "where") and "get" in uin:
            print(h.pipya()+"""\
My name started as pypa, for "python personal assistant". It morphed to pipya
for pronounceability. Thanks for asking!""")

        elif "what" and "can" and "do" in uin:
            h.capabilities()

        elif "who" and "are" and ("you" or "pipya") in uin:
            print(h.pipya()+"""
I am Pipya, a personal assistant written in python3. My creator is brupoon.
He intended for me to be a jack-of-all-trades personal assistant operated by
a cli. I am a sexless, genderless entity, though my name is similar to the
human feminine "Pippa".
                """)

        elif uin in ["quit", "goodbye", "exit"]:
            print("Goodbye, {0}! 'Till next time.".format(user))
            sys.exit()

        elif uin in ["jellyfish"]:
            h.jellyfish()

        else:
            print("Pipya: Sorry, {0}, I didn't quite catch that.".format(user))
Esempio n. 3
0
def main(uin):
    wapi, user, citystr = h.kernfig()[0:3]
    if "headlines" in uin:
        if "npr" in uin:
            h.rt(uin)
            link = "http://www.npr.org/rss/rss.php?id=1001"
            newsfeed = h.grab(link)
            for i in range(10):
                print("Item {0}: ".format(i+1) + h.bcolors.BOLD +\
                  newsfeed.entries[i].title +\
                  h.bcolors.ENDC)
                print("Time Published ",newsfeed.entries[i].published)
        elif "atlantic" in uin:
            h.rt(uin)
            link = "http://feeds.feedburner.com/TheAtlantic?format=xml"
            newsfeed = h.grab(link)
            for i in range(10):
                print("Item {0}: ".format(i+1) + h.bcolors.BOLD +\
                  newsfeed.entries[i].title +\
                  h.bcolors.ENDC)
                print("Time Published: ",newsfeed.entries[i].published)
        else:
            print(h.pipya() + "Defaulting to NPR!")
            link = "http://www.npr.org/rss/rss.php?id=1001"
            newsfeed = h.grab(link)
            for i in range(10):
                print("Item {0}: ".format(i+1) + h.bcolors.BOLD +\
                  newsfeed.entries[i].title +\
                  h.bcolors.ENDC)
                print("Time Published ",newsfeed.entries[i].published)
        h.cfgwriter("settings.cfg",2,link)

    elif "weather" in uin:
        currentcond = str('http://api.wunderground.com/api/'+wapi+\
                    '/geolookup/conditions/q/'+citystr+'.json')
        parsed_json = h.wloader(currentcond)
        h.wcurre(parsed_json)

        currentforec = str('http://api.wunderground.com/api/'+wapi+\
                    '/geolookup/forecast/q/'+citystr+'.json')
        parsed_json = h.wloader(currentforec)
        h.wforec(parsed_json)
    return None