You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.6 KiB
66 lines
1.6 KiB
######################################### |
|
# CaNerDUH BBS Presents: # |
|
# This Day In History # |
|
# A Mystic BBS Mod written in Python # |
|
# Written by: Travis Mehrer # |
|
# AKA blade # |
|
######################################### |
|
|
|
import mystic_bbs as bbs |
|
import random |
|
import json |
|
import textwrap |
|
from unidecode import unidecode |
|
|
|
# Change this path to reflect the root folder of your BBS |
|
tdihJSON = '/mystic/tdih.json' |
|
|
|
############################ |
|
# Custom function to pause # |
|
############################ |
|
|
|
def pause(): |
|
bbs.writeln("|PA") |
|
|
|
################################## |
|
# Custom fuction to clear screen # |
|
################################## |
|
|
|
def clear(): |
|
bbs.write('|CL') |
|
|
|
############# |
|
# Line Feed # |
|
############# |
|
|
|
def linefeed(): |
|
bbs.write('|CR') |
|
|
|
################### |
|
# Show Title ANSI # |
|
################### |
|
|
|
def showTitle(): |
|
bbs.showfile("tdih.ans", 57600, 0, 0, 0) |
|
|
|
# Import the JSON File with today's history |
|
with open("tdih.json", "r", encoding='utf8') as f: |
|
tdih = json.load(f) |
|
|
|
# Count the events and generate 5 random numbers within that range |
|
rEventNums = random.sample(range(0,len(tdih["data"]["Events"])-1), 5) |
|
|
|
wrapper = textwrap.TextWrapper(width=60,subsequent_indent=' ') |
|
|
|
clear() |
|
showTitle() |
|
linefeed() |
|
|
|
# Sort the random event numbers in numerical order and print each one. |
|
for rEventNum in sorted(rEventNums): |
|
event = tdih["data"]["Events"][rEventNum] |
|
bbs.writeln('|15' + event["year"] + ' |08- |07' + unidecode(wrapper.fill(text=event["text"]))) |
|
|
|
linefeed() |
|
pause() |
|
|
|
|