Instantly share code, notes, and snippets.
Last active
July 5, 2022 23:34
-
Star
(1)
1
You must be signed in to star a gist -
Fork
(0)
0
You must be signed in to fork a gist
-
Save nolageek/f314741c614b9234b2ae to your computer and use it in GitHub Desktop.
bbslink client menu for daydream
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
## Original code by Sampsa Laine, B4BBS (2:250/7), http://sampsa.com/b4bbs | |
## | |
## Will create a menu of doors. | |
## | |
## DOOR_COMMAND.. BBSLINK | |
## DOOR_TYPE..... 6 | |
## DOOR_SECURITY. 200 | |
## DOOR_EXECUTE.. /home/bbs/python/dd-bbslink-menu.py %N LORD | |
## DOOR_CONFS1... XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX | |
## DOOR_CONFS2... XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX | |
## DOOR_PASSWD... - | |
## | |
## User configurable bits start here / FIXME config file? | |
host = "games.bbslink.net" # Server address, usually 'games.bbslink.net' | |
## request access from bbslink.net | |
syscode = "xxxxxxxxx" # Your system code | |
authcode = "xxxxxxxxxx"; # Your system's authorisation code | |
schemecode = "xxxxxxxxxxxxxxx"; # Scheme code | |
menufile = "test" # NOT NOT INCLUDE EXTENTION | |
# if blank will generate menu from following key:value pairs | |
# file must be placed in /display/iso/ | |
## DOOR LIST - COMMENT OUT WHAT YOU DO NOT WANT. NO COMMA AFTER LAST. | |
doors = { | |
#"Door Name": "Door code" | |
#"All Games Menu": "menu", | |
#"Sysop Test": "test", | |
"Legend of the Red Dragon": "lord", | |
"Legend of the Red Dragon II: New World": "lord2", | |
"MZK LORD": "mzkl", | |
"Operation: Overkill II": "ooii", | |
"Trade Wars 2002": "tw", | |
"Planets: The Exploration of Space": "teos", | |
"Global War": "gwar", | |
"Global Backgammon": "ggam", | |
"Usurper": "usrp", | |
"Barren Realms Elite": "bre", | |
"Falcon's Eye": "falc", | |
"Falcon's Honor": "fhon", | |
"The Arcadian Legends": "arcl", | |
"DoorMUD": "dmud", | |
"Pimp Wars": "pimp", | |
"Lunatix": "luna", | |
"Netrunner": "netr", | |
"Assassin": "assn", | |
"BBS Crash": "bbsc", | |
"Virtual Sysop": "vsys", | |
"The Pit": "tpit", | |
"Bordello": "bord", | |
"Junkyard": "junk", | |
"Murder Motel": "mmot", | |
"Darklands": "dark", | |
"Hackin' Crackin'": "hack", | |
"Mega Slots": "mega", | |
"Fresh Water Fishing Sim": "fish", | |
"Lemondade": "lmon", | |
"Dungeon Master": "dmas", | |
"BCR Games Server": "bcr" | |
} | |
## User configurable bits end here | |
## DO NOT EDIT BELOW THIS LINE | |
version = "0.02" | |
import md5 | |
import random | |
import string | |
import httplib | |
import os | |
import sys | |
import dd | |
if (dd.initdoor(sys.argv[1])==0): | |
print "Ugh. Run me from DD\n" | |
sys.exit(-1) | |
else: | |
## Calculates a hex MD5 digest of given string s | |
def main(): | |
menu() | |
dd.sendstring("Please select a game. 'Q' to quit: ") | |
code = dd.prompt("",5,dd.PROMPT_NOCRLF) | |
if code.upper() == 'Q' or code == "": | |
sys.exit("\nReturning to the BBS...") | |
else: | |
connectDoor(code) | |
def menu(): | |
if menufile is not "": | |
dd.typefile(menufile,dd.TYPE_MAKE) | |
else: | |
dd.sendstring("\nGames Brought To you by BBSLink.net\n\n") | |
for name,code in doors.items(): | |
dd.sendstring(code + ": " + name + "\n") | |
## Calculates a hex MD5 digest of given string s | |
def getMD5Hash(s): | |
m = md5.new() | |
m.update(s) | |
rv = m.hexdigest() | |
return rv | |
def connectDoor(code): | |
dd.sendstring("\nConnecting to " + code) | |
## getting our variables and the door name. | |
doorcode = code | |
usernumber = dd.getvar(dd.USER_ACCOUNT_ID) | |
screenrows = dd.getvar(dd.USER_SCREENLENGTH) | |
## generate xkey | |
xkey = ''.join(random.SystemRandom().choice(string.ascii_uppercase + string.digits) for _ in range(6)).lower() | |
## get token | |
h1 = httplib.HTTPConnection(host) | |
h1.request("GET", "/token.php?key=" + xkey) | |
r1 = h1.getresponse() | |
token = r1.read() | |
token = str(token).strip() | |
## authorize | |
# "Accept": "text/plain"} | |
headers = { | |
"X-User": usernumber, | |
"X-System": syscode, | |
"X-Auth": getMD5Hash(authcode + token), | |
"X-Code": getMD5Hash(schemecode + token), | |
"X-Rows": screenrows, | |
"X-Key": xkey, | |
"X-Door": doorcode, | |
"X-Token": token | |
} | |
h2 = httplib.HTTPConnection(host) | |
h2.request("GET","/auth.php?key=" + xkey,"",headers) | |
r2 = h2.getresponse() | |
status = r2.read() | |
status = str(status).strip() | |
if status == "complete": | |
os.system("telnet -K -8 " + host) | |
else: | |
dd.sendstring("An error occurred when contacting the door server:") | |
dd.sendstring("[" + status + "]") | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Updated with all doors as of 4/9/2018