Last active
March 5, 2024 14:11
-
-
Save denzuko/4e8faa980c299d7be176d4d83836ed5c to your computer and use it in GitHub Desktop.
bbslink.mpy door menu - InterBBS Server
This file contains hidden or 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
# *********************************************************************** | |
# * BBS Link Script for Mystic BBS * | |
# *********************************************************************** | |
# * This script will allow you to run BBSlink from your system. * | |
# * Installation: * | |
# * (1) Go to http://www.bbslink.net and register! * | |
# * (2) Locate the line below that says "BBS Auth Information". * | |
# * Change the syscode, authcode, and schemecode to match what you * | |
# * receive when you signed up. * | |
# * (3) Install this script into your mystic /themes/default/scripts * | |
# * directory. * | |
# * NOTE: This is a Mystic Python script, so you will have to install * | |
# * python 2.7 to run this. Refer to this page for help: * | |
# * http://wiki.mysticbbs.com/doku.php?id=python_install * | |
# * (4) In Mystic -cfg, you will need to add a menu option in your * | |
# * menu editor: * | |
# * Menu Command: GY (Executable Python Script) * | |
# * Data: bbslink doorcode * | |
# * or just bbslink which will bring up a menu of doors * | |
# * * | |
# *********************************************************************** | |
import json | |
import httplib | |
import hashlib | |
import random | |
import string | |
import md5 | |
from mystic_bbs import * | |
def randomString(stringLength=10): | |
"""Generate a random string of fixed length """ | |
letters = string.ascii_lowercase | |
return ''.join(random.choice(letters) for i in range(stringLength)) | |
def getMD5Hash(s): | |
m = md5.new() | |
m.update(s) | |
rv = m.hexdigest() | |
return rv | |
#BBS Auth Information (stored in mysticbbs folder next to the mystic/mis binaries) | |
## Schema: | |
## { "syscode": ..., "authcode": ..., "schemecode": ... } | |
auth = dict( | |
syscode=str(), | |
authcode=str(), | |
schemecode=str()) | |
with open('bbslink.json') as file: | |
auth = json.load(file) | |
#Host Connection Info | |
host = "games.bbslink.net" | |
#Script Information | |
scripttype = "JS" | |
scriptver = "1.2.1" | |
#User Information | |
user = getuser(0) | |
usernumber = user["id"] | |
#Door to launch. Default is to bring up the menu | |
if param_str(1) is None: | |
doorcode="menu" | |
else: | |
doorcode = param_str(1) | |
config = getcfg() | |
bbsName = config["bbsname"] | |
screenrows = 24 | |
writeln("Please wait...") | |
#Open Connection | |
conn = httplib.HTTPConnection(host) | |
#Get Token from server | |
key = randomString(6) | |
endpoint = "/token.php?key=" + key; | |
conn.request('GET', endpoint) | |
response1 = conn.getresponse() | |
token = response1.read(); | |
#Authenticate with server | |
authurl = "/auth.php?key=" + key; | |
headers = { | |
"X-User": usernumber, | |
"X-System": auth['syscode'], | |
"X-Auth": getMD5Hash(auth['authcode'] + token), | |
"X-Code": getMD5Hash(auth['schemecode'] + token), | |
"X-Rows": screenrows, | |
"X-Key": key, | |
"X-Door": doorcode, | |
"X-Token": token, | |
"X-Type": scripttype, | |
"X-Version": scriptver | |
} | |
conn.request('GET', authurl, "", headers) | |
response2 = conn.getresponse() | |
status = response2.read() | |
status = str(status).strip() | |
if status == "complete": | |
writeln("Connecting to the interBBS server...") | |
menucmd("IT", "/addr={} /port=23".format(host)) | |
else: | |
writeln("Unable to connect") | |
writeln("Response: " + status) | |
writeln("Returning to " + bbsName + "...") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Didn't think we needed a "RTFM" and that the kind of people using this script was more perceptive but a recent email sent over shows how much people do not read.
NOTE: Follow the instructions in lines 6,7,10,15 to get things installed and your authkey for bbslink. You'll also need a very plain Json file with three keys inside a single object for the config as defined on lines 43-48.