ttbp/bin/ttbp.py

66 lines
1.3 KiB
Python
Raw Normal View History

2016-04-30 03:17:06 +00:00
#!/usr/bin/python
2016-04-30 03:48:01 +00:00
#import core
2016-04-30 03:17:06 +00:00
import os
2016-05-01 00:19:00 +00:00
import core
import chatter
2016-04-30 03:17:06 +00:00
2016-05-01 00:19:00 +00:00
SOURCE = os.path.join("/home", "endorphant", "projects", "ttbp", "bin")
USER = os.path.basename(os.path.expanduser("~"))
PATH = os.path.join("/home", USER, ".ttbp")
LIVE = "http://tilde.town/~"
WWW = os.path.join(PATH, "www")
2016-04-30 03:48:01 +00:00
CONFIG = os.path.join(PATH, "config")
2016-05-01 00:19:00 +00:00
DATA = os.path.join(PATH, "entries")
2016-04-30 03:17:06 +00:00
BANNER = open(os.path.join(CONFIG, "banner.txt")).read()
2016-05-01 00:19:00 +00:00
#CLOSER = "\n\tsee you later, space cowboy..."
2016-04-30 03:34:43 +00:00
SPACER = "\n\n\n\n"
2016-04-30 03:17:06 +00:00
def start():
print(BANNER)
2016-05-01 00:19:00 +00:00
print(chatter.say("greet")+", "+chatter.say("friend"))
2016-04-30 03:34:43 +00:00
print(SPACER)
print(check_init())
2016-04-30 03:17:06 +00:00
try:
print(main_menu())
except ValueError or SyntaxError:
2016-04-30 03:34:43 +00:00
print("\n\noh no i didn't understand that")
2016-04-30 03:17:06 +00:00
print(main_menu())
except KeyboardInterrupt:
2016-04-30 03:34:43 +00:00
print("\n\neject button fired")
2016-04-30 03:17:06 +00:00
print(main_menu())
2016-04-30 03:34:43 +00:00
def stop():
2016-05-01 00:19:00 +00:00
return "\n\t"+chatter.say("bye")
2016-04-30 03:34:43 +00:00
def check_init():
if os.path.exists(os.path.join(os.path.expanduser("~"),".ttbp")):
2016-05-01 00:19:00 +00:00
return "welcome back, "+USER
2016-04-30 03:34:43 +00:00
else:
return init()
def init():
print(SPACER)
2016-05-01 00:19:00 +00:00
return "i don't recognize you, stranger. let's make friends. you're "+USER+", right?"
2016-04-30 03:34:43 +00:00
2016-04-30 03:17:06 +00:00
def main_menu():
2016-04-30 03:34:43 +00:00
print(SPACER)
2016-04-30 03:17:06 +00:00
print("how are you feeling today? ")
2016-04-30 03:48:01 +00:00
ans = raw_input("your feels (enter 'none' to quit): ")
2016-04-30 03:17:06 +00:00
2016-04-30 03:34:43 +00:00
if ans == "none":
return stop()
else:
return main_menu()
2016-04-30 03:48:01 +00:00
#####
start()