1 Python interface

DayDream BBS has a python module (dd.py, _dd.so) that allows easy door-writing and scripting using Python language.


2 Commands

initdoor(node)
Start the communication with DayDream. node is usually supplied by sys.argv[1].
sendstring(string)
Output string to the user.
hotkey(flags)
Wait for a keypress from the user. Returns the character received or 0 if carrier lost. Following flags are available:
  • HOTKEY_CURSOR - detect cursor keys. returns ascii code 250 if up, 251 if down, 252 if left, 253 if right.
  • HOTKEY_YESNO - Yes/no mode
  • HOTKEY_NOYES - yes/No mode (if HOTKEY_YESNO or HOTKEY_NOYES is specified, integer is returned. 0 = carrier lost, 1 = yes, 2 = no).
  • HOTKEY_QUICK - return instantly. (get a char from serial/console buffer)
  • typefile(file, flags)
    Shows file to the user. Following flags are supported:
  • TYPE_WARN - warn user if the file is not found
  • TYPE_MAKE - Format the filename (add .txt/.gfx extension and path)
  • TYPE_NOCODES - Disable control codes (~#)
  • TYPE_CONF - Look for the file from conference's display dir
  • TYPE_NOSTRIP - Don't strip ansi codes even if the user is in ascii mode
  • TYPE_SEC - Check if there's file for user's security.

    Returns 0 if file not found, 1 if success.

  • prompt(default,maxlen,flags)
    Prompts user for a string. default can be the default string or 0, maxlen is the maximum length (in bytes) of the string. Following flags are available:
  • PROMPT_SECRET - hide input
  • PROMPT_NOCRLF - don't write crlf when user presses enter
  • PROMPT_FILE - don't allow '/'.

    Returns 0 if carrier lost, otherwise 1.

  • closedoor(.)
    Close the doorport. After closing the doorport, you are not able to send commands to DD.
    getvar(var)
    Return a variable var. getvar may return you a string, integer, long integer or a char, depending on type.

    strings

  • BBS_NAME - BBS Name
  • BBS_SYSOP - SysOp's Name
  • USER_REALNAME - Real name of the user
  • USER_HANDLE - Handle of the user
  • USER_ORGANIZATION - Organization of the user
  • USER_ZIPCITY - Zip & City of the user
  • USER_VOICEPHONE - Voice phone number of the user
  • USER_COMPUTERMODEL - Computer model of the user
  • USER_SIGNATURE - Upload signature of the user
  • DOOR_PARAMS - Command line parameters from main prompt
  • DD_ORIGDIR - same as getenv("DAYDREAM"), the dir where DD stuff is.
  • USER_CONFERENCEACC1 - Conference access for confs 1-32, in format "X----X---", where X is yes and - is no.
  • USER_CONFERENCEACC2 - Conference access for confs 33-64, in format "X----X---", where X is yes and - is no.
  • USER_FIRSTCALL - Date of the first call by the user, in ctime()-format.
  • USER_LASTCALL - Date of the last call by the user, in ctime()-format.
  • CONF_NAME - Name of the current conference
  • CONF_PATH - Path to the current conference
  • CONF_ULPATH - Upload path of the current conference
  • CONF_NEWSCANAREAS - New file scan areas
  • CONF_PASSWD - Conference password
  • MSGBASE_NAME - Name of the current message base
  • MSGBASE_FN_TAG - Fidonet tag of the current message base
  • MSGBASE_FN_ORIGIN - Origin line
  • MSGBASE_FN_ADDRESS - Address

    integers

  • USER_SCREENLENGTH - Screen length of the user (lines)
  • USER_ULFILES - Number of files uploaded by the user
  • USER_DLFILES - Number of files downloaded by the user
  • USER_PUBMESSAGES - Number of public messages written by the user.
  • USER_PVTMESSAGES - Number of private messages written by the user.
  • USER_CONNECTIONS - Number of calls by the user.
  • USER_FILERATIO - File ratio of the user
  • USER_BYTERATIO - Byte ratio of the user
  • USER_FREEDLBYTES - Free download bytes of the user
  • USER_FREEDLFILES - Free download files of the user
  • USER_SECURITYLEVEL - Security level of the user
  • USER_JOINCONFERENCE - Auto-join conference
  • USER_DAILYTIMELIMIT - Daily time limit (minutes)
  • USER_ACCOUNT_ID - User account id
  • USER_TIMELEFT - Remaining time
  • SYS_CONF - Current conference number
  • USER_FAKEDFILES - Number of faked files
  • USER_FAKEDBYTES - Number of faked bytes
  • SYS_FLAGGEDFILES - Number of files flagged for downloading
  • SYS_FLAGGEDBYTES - Number of bytes flagged for downloading
  • SYS_FLAGERROR - Error code of the last file flagging attempt (See libdd.doc for more info)
  • SYS_MSGBASE - Number of the current message base
  • CONF_FILEAREAS - Number of fileareas in current conference
  • CONF_UPLOADAREA - Upload area number of the current conference
  • CONF_MSGBASES - Message base in the current conference
  • CONF_COMMENTAREA - Comment base number of the current conference
  • MSGBASE_MSGLIMIT - Message limit in the current message base

    long integers

  • USER_ULBYTES - Number of bytes uploaded by the user
  • USER_DLBYTES - Number of bytes downloaded by the user

    chars

  • USER_PROTOCOL - Protocol ID char of the user
  • setvar(var, newvalue)

    Set variable var. newvalue must be supplied as string. Possible var's are:

  • BBS_NAME - BBS Name
  • BBS_SYSOP - SysOp's Name
  • USER_REALNAME - Real name of the user
  • USER_HANDLE - Handle of the user
  • USER_ORGANIZATION - Organization of the user
  • USER_ZIPCITY - Zip & City of the user
  • USER_VOICEPHONE - Voice phone number of the user
  • USER_COMPUTERMODEL - Computer model of the user
  • USER_SIGNATURE - Upload signature of the user
  • USER_CONFERENCEACC1 - Conference access for confs 1-32, in format "X----X---", where X is yes and - is no.
  • USER_CONFERENCEACC2 - Conference access for confs 33-64, in format "X----X---", where X is yes and - is no.

    To change the value of an integer value, do it like this:

    spam=dd.getvar(dd.ULFILES)
    spam=spam+1;
    dd.setvar(dd.ULFILES,`spam`)
    
  • USER_SCREENLENGTH - Screen length of the user (lines)
  • USER_ULFILES - Number of files uploaded by the user
  • USER_DLFILES - Number of files downloaded by the user
  • USER_PUBMESSAGES - Number of public messages written by the user.
  • USER_PVTMESSAGES - Number of private messages written by the user.
  • USER_CONNECTIONS - Number of calls by the user.
  • USER_FILERATIO - File ratio of the user
  • USER_BYTERATIO - Byte ratio of the user
  • USER_FREEDLBYTES - Free download bytes of the user
  • USER_FREEDLFILES - Free download files of the user
  • USER_SECURITYLEVEL - Security level of the user
  • USER_JOINCONFERENCE - Auto-join conference
  • USER_DAILYTIMELIMIT - Daily time limit (minutes)
  • USER_TIMELEFT - Remaining time
  • USER_FAKEDFILES - Number of faked files
  • USER_FAKEDBYTES - Number of faked bytes

  • USER_ULBYTES - Number of bytes uploaded by the user
  • USER_DLBYTES - Number of bytes downloaded by the user

  • USER_PROTOCOL - Protocol ID char of the user
  • flagsingle(file, res)
    Flag a single file. file is the filename, and must be case sensitive. If res is 1, DD tells the user what happened. Returncodes are:

  • 0 = success
  • 1 = fileratio doesn't allow flagging
  • 2 = byteratio doesn't allow flagging
  • 3 = file already flagged
  • 4 = success (free download)
  • -1 = file not found
  • finduser(name)
    Find user looks for user called name, and returns the user if of the user or -1 if user not found.
    system(command,input)
    Run an executable and print the output to the user. If input is 1, reads the user input to stdin.
    cmd(command)
    Execute internal DD command or door cmd. Returns 0 if carrier lost, otherwise 1.
    writelog(string)
    Writes string to DD logfile.
    changestatus(new)
    Change node status (shown in WHO etc) to new.
    pause()
    Show default pause prompt and wait for any key.
    joinconf(conf,flags)
    Change the active conference to conf. Allowed values for flags are:

  • JC_LIST - if conf = 0, show list of conferences
  • JC_SHUTUP - don't tell user if anything goes wrong..
  • JC_QUICK - don't show conference information..

    Returns 1 if success, otherwise 0.

  • isfreedl(file)
    Returns 1 if file is free download in the current conference, 2 if all the files are free in the current conference or otherwise 0.
    flagfile(pattern, res)
    Flags files matching to pattern in the current conference. If res is 1, list the progress to the user. Returns number of files flagged.
    isconfaccess(conference)
    Return 1 if user has access to the conference.
    isanybasestagged(conf)
    Return 1 if user has any of the messagebases tagged in the conference.
    isconftagged(conference)
    Return 1 if user has the conference tagged for file scanning.
    isbasetagged(conference, msgbase)
    Return 1 if user has the msgbase tagged in the conference.
    changemsgbase(msgbase, flags)
    Change message base to msgbase in current conference. Following flags are available:

  • MC_QUICK - don't tell anything if failed to join
  • MC_NOSTAT - don't display msgbase stats
  • sendfiles(list)
    Send files to the user using the selected file transfer protocol. list is the name of file containing full paths to the files to be sent. One file per line.
    getfiles(directory)
    Receive files using selected file transfer protocol to the directory.
    unflagfiles(pattern)
    Unflags flagged files matching with the pattern. Returns number of files unflagged.
    findfilestolist(pattern, list)
    Find the files in current conference matching with pattern and put the to the list. One line per file. Returns number of matches.
    dumpfilestolist(list)
    Dump the names and paths of flagged files to list. One file per line.

    3 Usage

    To be able to access DD commands, you have to import 2 modules in the beginning of your script. These two modules are dd and sys. When importing module dd, c-routines are being loaded automatically. Connection with DD is established with dd.initdoor-routine, and if it fails, your script is NOT launced from DD. Here's an example of a simple script:

    import dd
    import sys
    
    if (dd.initdoor(sys.argv[1])==0):
        print "Ugh. Run me from DD\n"
        sys.exit(-1)
    else:
        dd.sendstring ("Hello, World and ")
        name=dd.getvar(dd.USER_HANDLE)
        dd.sendstring (name + "\n")
        calls=dd.getvar(dd.USER_CONNECTIONS)
        dd.sendstring ("You have called this system " + `calls` + " times.\n")
    
    Simple, huh? :)