Giter VIP home page Giter VIP logo

sblendorio / petscii-bbs Goto Github PK

View Code? Open in Web Editor NEW
116.0 11.0 16.0 6.19 MB

A Java framework for building highly customizable PETSCII-enabled BBS, accessible from Commodore 64/128

License: Mozilla Public License 2.0

Java 72.28% Shell 0.05% RobotFramework 0.09% Roff 0.03% Dockerfile 0.01% Python 0.02% JavaScript 14.16% BASIC 12.30% Visual Basic 6.0 0.48% FreeBasic 0.08% HTML 0.37% CSS 0.13%
bbs petscii commodore commodore-64 c64 java server terminal telnet

petscii-bbs's Introduction

PETSCII BBS Builder

A Java framework for building highly customizable PETSCII (and ASCII) enabled BBSes, accessible from 8-bit Commodore computers

Patreon support page

https://www.patreon.com/FrancescoSblendorio

Purpose

This framework provides base classes for build your own BBS in PETSCII mode, accessibile through:

The project has been extended to support also generic-ASCII client and also Videotex (Minitel/Teletel and Prestel standards).

System requirements

  • Java Development Kit (JDK) and JRE version 21+
  • A machine that will act as server

Required skills

  • Knowledge of Java language (compiler version 21+)
  • BASIC TCP/IP concepts
  • Knowledge of PETSCII encoding

Getting started

Let's suppose to build a very simple BBS that asks your name and welcomes you. The basic operation is to extend PetsciiThread class (or AsciiThread for ASCII BBS) implementing doLoop() method, such as:

public class WelcomeBBS extends PetsciiThread {
    
    // NEVER forget default (empty) constructor
    public WelcomeBBS() {
        super(); // Recommended
    }
    
    @Override
    public void doLoop() throws Exception {
    
        // clear screen
        cls();
        
        println("This is your brand-new BBS");
        println();
        print("Enter your name: ");

        // flush output 
        flush();
        
        // clear input buffer
        resetInput();
        
        String name = readLine();
        println();
        println("Welcome, " + name + "!");
        println("Press a key to exit");
        flush();
        readKey();

    }
}

this piece of code is enough to create a fully-functional but pretty simple BBS. The result will look like this:

BBS sample screenshot

All you have to do now is to build and run the BBS on your server, ready to be called by a PETSCII-enabled terminal client. Let's see how to do it in the following sections.

Building the server

Once you have written your own BBS as an extension of PetsciiThread class, simply build the fat jar with this command:

mvn clean package

The build process will result in the file petscii-bbs.jar, it will be found in the target directory. So you can run it with:

java -jar target/petscii-bbs.jar

Running the BBS Server

Running the server with no parameters, a help screen will be displayed:

usage: target/petscii-bbs.jar
    --bbs <bbsName:port>   Run specific BBSes (mandatory - see list below)
                           in the form <name1>:<port1> <name2>:<port2> ...
 -h,--help                 Displays help
 -s,--serviceport <arg>    TCP port used by service process, 0 for
                           no-service (default 0)
 -t,--timeout <arg>        Socket timeout in millis (default 60 minutes)
List of available BBS:
 * ...
 * WelcomeBBS

So we can rename the -jar file in bbs.jar, and the basic syntax for running our sample BBS is:

java -jar bbs.jar --bbs WelcomeBBS:6510

the port where the service will run is 6510 and the timeout is 3600000 milliseconds by default (1 hour). We can change the timeout parameter with -t switch:

java -jar bbs.jar --bbs WelcomeBBS:8088 -t 7200000

It's possible to run multiple BBSes, each one on a different port:

java -jar bbs.jar --bbs WelcomeBBS:6510 NewsBBS:8400 SportsBBS:9100 -t 7200000

(so the port will be 8088 with a timeout of 2 hours)

It's possibile to specify a "Service Port", which makes accessible (via web browser) the inspection of JVM running BBSes:

java -jar bbs.jar --bbs WelcomeBBS:6510 NewsBBS:8400 SportsBBS:9100 -s 8080

Keep it running

This .jar is intended to be a server process: it has to run all time. So, it's a good thing to run it in background if you use a UNIX shell using nohup command with bash "&" operator:

nohup java -jar bbs.jar --bbs WelcomeBBS:6510 &

It's VERY important not to forget the final & symbol to keep it running. After launching that, you can logoff from your server.

Stopping it

It's a plain process, so use plain ps and kill commands. If this jar is the only one running on your server, this command will do the work:

killall java

Sample BBSes in the package

You can study the sample BBSes (all classes that extend PetsciiThread) in the package eu.sblendorio.bbs.tenants as example of complete task. The package includes some proxies for accessing WordPress sites through Commodore 64 and a two classic strategy games (tic-tac-toe and connect-4)

Sample online BBSes

  • bbs.sblendorio.eu - port 6510
  • bbs.retrocampus.com - port 6510 (included in C64 Forever version of CCGMS)

Credits

Thanks to:

Sample screenshot of the demo pack

bbs1

bbs2

bbs3

bbs4

petscii-bbs's People

Contributors

ch0mik avatar dependabot[bot] avatar felicepagano avatar matteobaccan avatar rmanicardi avatar rmanicardisfdc avatar sblendorio avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

petscii-bbs's Issues

When to use flush() and resetInput()

I've been trying to understand when these need to be used and what they do but I don't follow it.

Could you give me some guidance on when to use either of these and why. Thanks!

Wordpress Proxy - Not valid certification path

I get this error when trying to use any wordpress proxy examples:

2020-01-04 13:35:37.798 The BBS Sys64738 is running: port = 6464, timeout = 3600000 millis
2020-01-04 13:35:54.683 Client #1. New connection at Socket[addr=/192.168.1.51,port=58583,localport=6464]
2020-01-04 13:35:54.886 Client #1. Wordpress entering (https://sys64738.org)
2020-01-04 13:35:57.621 Client #1. ERROR handling: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

PETSCII Charset

Consider to implement a PETSCII Charset and reconsider the CbmInputOuput class (warning: missing "t").

Provide credentials.example.json

Could you please provide an example credentials file and perhaps instructions on how to generate the credentials (api token, user pass?)

Nullability

Consider annotate code with JSR 305 nullability annotations (package already included).

This will become part of documentation and it is well integrated with IDEs or Kotlin language.

Wordpress proxy wall of text

Is there a way to get the Wordpress proxy to listen to paragraph breaks or
commands when displaying texts so that paragraphs with breaks show up without the entire text becoming a wall of text?

I've tried pulling BR| from this line without success:
.replaceAll("(?is)^[\s\n\r]+|^\s*(</?(br|div|figure|iframe|img|p|h[0-9])[^>]>\s)+", EMPTY)

Question: Ability to return ANSI instead of PETSCII

I would like to open up the BBS I built upon your framework to the PC world, which means it needs to support ANSI instead of PETSCII (or that is my understanding).

Can you help me with this? Could you tell me what needs to be done to support this?

Is it just a matter of swapping a character map and color palette?

bbs.retrocampus.com >> CHATGPT >> accents not displayed properly > a way to simplify it ?

Hi,

What an amazing project that you've made, thank you ! I'm using this card : https://www.tindie.com/products/iodeo/minitel-esp32-dev-board/

On a Minitel and also on http://bbs.retrocampus.com/, the accents (in french like "é", "è", "à", "ù" for example, are not displayed well on chatGPT as you can see on screenshots.

Capture d’écran 2023-08-21 à 17 39 17 Capture d’écran 2023-08-21 à 19 10 24

I'm not sure that the Minitel as ever been compatible with accents by the way. So I suggest to fix it, to replace each output with an accent by his equivalent without accent :
à > a
â > a
é > e
è > e
ê > e
î > i
ï > i
ô > o
ù > u
û > u
ü > u
ç > c
œ > oe

Would you like to fix this or it's not your priority at all ? 😅

I cant download file via

Im using the CCGM'S Terminal v6 (2017)

``
2020-11-11 15:38:51.608 The BBS CsdbReleases is running: port = 6510, timeout = 3600000 millis
2020-11-11 15:39:36.968 Client #1. New connection at Socket[addr=/192.168.55.103,port=60047,localport=6510], server=172.17.0.2
2020-11-11 15:39:45.193 Client #1. CSDb waiting for input
2020-11-11 15:39:58.924 Client #1. Downloading Test Memory - https://csdb.dk/release/?id=84523
Transmission beginning
too many errors... aborting
Error code 1
2020-11-11 15:40:32.653 Client #1. EOF java.io.UncheckedIOException: eu.sblendorio.bbs.core.CbmIOException: Too many errors during XModem transfer: 1
2020-11-11 15:40:32.654 Client #1. STOP. Connection CLOSED.

``

Regards
Pawel

Here is a method to write a PETmate json file, maybe you can add it to the repo

Below you will find the function for reading in a PETmate (https://nurpax.github.io/petmate/) json file and write it out. It takes into account arbitrary width and height, and can be written to x,y on the screen. Hope this helps some people, please add it in to the repo if you can.

I attached an example json file that was created from PETmate, which you can also include in the repo if you'd like.
art.zip

Cheers! Deadline of CityXen ( https://github.com/cityxen )

import java.util.HashMap;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import java.io.FileReader;

/****************************/

private void PETmateJSON(String File) throws Exception { PETmateJSON(File,0,0); };
private void PETmateJSON(String File, Integer XLoc, Integer YLoc) throws Exception {

        // By Deadline of CityXen (cityxen.net)

	gotoXY(XLoc,YLoc);

	HashMap<Integer,Integer> codehash =new HashMap<Integer,Integer>();

	for(int i = 0; i < 32; i++)    { codehash.put(i,i+64);  }
	for(int i = 64; i < 96; i++)   { codehash.put(i,i+128); }
	for(int i = 96; i < 128; i++)  { codehash.put(i,i+64);  }
	for(int i = 128; i < 160; i++) { codehash.put(i,i-64);  }
	for(int i = 160; i < 192; i++) { codehash.put(i,i-128); }
	for(int i = 224; i < 256; i++) { codehash.put(i,i-64);  }

	HashMap<Integer,Integer> colorhash=new HashMap<Integer,Integer>();

	colorhash.put(0,Colors.BLACK);
	colorhash.put(1,Colors.WHITE);
	colorhash.put(2,Colors.RED);
	colorhash.put(3,Colors.CYAN);
	colorhash.put(4,Colors.PURPLE);
	colorhash.put(5,Colors.GREEN);
	colorhash.put(6,Colors.BLUE);
	colorhash.put(7,Colors.YELLOW);
	colorhash.put(8,Colors.ORANGE);
	colorhash.put(9,Colors.BROWN);
	colorhash.put(10,Colors.LIGHT_RED);
	colorhash.put(11,Colors.GREY1);
	colorhash.put(12,Colors.GREY2);
	colorhash.put(13,Colors.LIGHT_GREEN);
	colorhash.put(14,Colors.LIGHT_BLUE);
	colorhash.put(15,Colors.GREY3);

	Object jpars = new JSONParser().parse(new FileReader(File));
	JSONObject json = (JSONObject) jpars;
	JSONArray framebufs = (JSONArray) json.get("framebufs");
	JSONArray screencodes = (JSONArray) ((JSONObject) framebufs.get(0)).get("screencodes");
	JSONArray colors = (JSONArray) ((JSONObject) framebufs.get(0)).get("colors");
	String charset = (String) ((JSONObject)framebufs.get(0)).get("charset");
	Long width  = (Long) ((JSONObject)framebufs.get(0)).get("width");
	Long height = (Long) ((JSONObject)framebufs.get(0)).get("height");
	// System.out.println("\nFile: "+File+" (CHARSET: ["+charset+"] WIDTH: ["+width+"] HEIGHT: ["+height+"])");
	if(charset.equals((String)"upper")) { write(Keys.UPPERCASE,Keys.CASE_LOCK); }
	else { write(Keys.LOWERCASE,Keys.CASE_LOCK); }
	Integer outcolor;
	Integer lastcolor=null;
	Integer outcode;
	Integer compcode;
	int linecounter=0;
	int linecounter2=0;
	int heightcounter=0;
	int DrawSize=screencodes.size();
	for (int i = 0; i < DrawSize; i++) {
		if(width<40) {
			if(linecounter==width) {
				write(Keys.DOWN);
				for(int zz=0;zz<width;zz++) {
					write(Keys.LEFT);
				}
				linecounter=0;
			}
		}
		outcolor = colorhash.get((int) (long) colors.get(i));
		if(lastcolor!=outcolor) {
			write(outcolor);
			lastcolor=outcolor;
		}
		outcode  = (int)(long)screencodes.get(i);
		if(outcode>127) write(Keys.REVON);
		else write(Keys.REVOFF);
		compcode = codehash.get(outcode);
		if(compcode!=null) {
			outcode=compcode;
		}
		write(outcode);
		linecounter++;
		linecounter2++;
		if(linecounter2 == width) {
			linecounter2=0;
			heightcounter++;
			if(heightcounter>height) {
				break;
			}
		}
	}
};

Understanding logo bitmap

A pretty noobish question but you have this logo here. Can you tell me how to construct my own logo. I'm not very familiar with java (not at all really).

This looks like an array of byte, you give it an int value and that is driving what, the pixels?

 public static byte[] LOGO = new byte[] {
        32,  32,  32,  32,  32,  28, -84,  32,  32,  32,  32,  32,  32,  32,  32,  32,
        32,  32,  32,  32,  32,-104, -69,  32,  32,  32,  32,  32,  32,  32,  32,  32,
        32,  32,  32,-101, -69, -84,  32, -84, -84,  13,  18,  28, -95, -65,-110, -84,
        18, -69,-110, -69,  18, -69,-110, -66,  18, -68,-110, -66,  18, -65,-110, -65,
        -104, -84,  18, -94,-110, -95,  18, -65,-110, -66,  18, -65, -69,-110, -84,  18,
        -94,-110, -95,  18, -65, -68, -95, -69,-110, -65,  18, -95,-110,  32, -95,  32,
        32,  32,-101, -68,  18, -65, -95,-110, -69, -84,  18, -95,-110, -66,  13,  18,
        28, -95,-110,  32, -68,  18, -68,-110,  32, -68, -69, -95,  32, -65,  18, -65,
        -110,-104, -68, -94, -95, -65, -69, -65,  18, -66,-110, -68, -94, -95,  18, -69,
        -110, -69,  18, -95, -95, -95,-110, -68, -94, -95,  30, -94, -94,  32,-101, -68,
        18, -65, -95, -65, -95,-110, -68, -69,  13,  32,  32,  32,  32,  32,  32,  32,
        32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,  32,
        32,  32,  32,  32,-104, -94, -66,  13,  18,-102, -95, -84, -69,-110, -69,  13,
        18, -95, -68, -66,-110, -66,  13,  18, -95,-110, -95,  18, -95,-110, -95,  13,
        -68,  18, -94, -94,-110,  13,  18,-103, -95, -84, -69,-110, -69,  13,  18, -95,
        -68, -66,-110, -66,  13,  18, -95,-110, -95,  18, -95,-110, -95,  13, -68,  18,
        -94, -94,-110,  13,-106, -84,  18, -84, -69,-110, -69,  13, -68,  18, -68,-110,
        -94,  13, -84, -69,  18, -95,-110, -95,  13,  32,  18, -94, -94,-110,  13
    };

Reading the next message with a carriage return

I've been slowly adapting a copy "UserLogon.Java" (originally used for the private Electronic Mail option) as a General Message area (new called "GeneralMessages.Java" for my own board. Most of my changes are formatting, and by creating the user "All" I've been able to make all messages visible to all users of the board.

I've been trying to add a feature which is eluding me for the last few weeks. When I user selects a message number to read, (example: 8) it displays the message as requested, then provides the option to [R]eply or any key to go back to the menu.

I'm hunting for a way for the user to hit [return] at the list of messages to display the next newest message (so if they read message 8, then it would now display message 7)

It appears that what I'm trying to add should go into:

    public void listMessages(boolean onlyUnread) throws Exception {
        List<Message> messages = getMessages("All", onlyUnread); 

perhaps after the section:


            } else if (isNumeric(cmd.replace("#", EMPTY)) && index>0 && index<=size) {
                displayMessage(messages.get(index - 1));

Not sure what I need to do to create this...

Passing petscii values into print()

Is there anyway to pass in petscii values via the print command?

I wish to do conditional colour coding using your existing rows behavior.

I would do an http get to fetch a document. Then I would like to insert ORANGE for example every time I find an image tag.

Or better yet, respect the color="<color"> html attribute on the original document.

It looks like write() is used for this currently but that would require a lot of mangling to get that to work I think. Any advice?

80 column petscii bbs

Thank you for creating this code!

I want to build a bbs with 80 columns petscii chars.

I believe I have to edit CLIScreenModel.java and modify the numbers:
static int BUFFER_LENGTH = 880; // = 40 columns x 22 rows (+1 for title + 2 for input)

for example for the screen size 80 columns x 50 rows, I have to edit to:
static int BUFFER_LENGTH = 3760; // = 80 columns x 47 rows (+1 for title + 2 for input)

and also this lines (changing 40 to 80):
int rowCount = row.length() / 40;
newContent = row.substring(maxRows * 40) + "\n" + newContent;
int spaces = 40 - adventureName.length() - 1 - rightStatus.length();

and it should work?

no list of available BBSes

$ java -jar petscii-bbs-1.0-SNAPSHOT.jar
usage: petscii-bbs-1.0-SNAPSHOT.jar
-b,--bbs Run specific BBS (mandatory - see list below)
-h,--help Displays help
-p,--port TCP port used by server process (default 6510)
-t,--timeout Socket timeout in millis (default 60 minutes)
List of available BBS:

no list of available BBSes - what is wrong ?

PS. I build it via docker
docker run -it --rm -v "$(pwd)":/tmp/bbsjava/petscii-bbs -w /tmp/bbsjava/petscii-bbs maven mvn clean install package

and then run it via
java -jar target/petscii-bbs-1.0-SNAPSHOT.jar

log : https://pastebin.pl/view/4bcb467f

Colors as enum

Consider to replace Colors class with a proper enum

public enum Color {
    BLACK(144),
    WHITE(5),
    RED(28),
    CYAN(159),
    PURPLE(156),
    GREEN(30),
    BLUE(31),
    YELLOW(158),
    ORANGE(129),
    BROWN(149),
    LIGHT_RED(150),
    GREY1(151),
    GREY2(152),
    LIGHT_GREEN(153),
    LIGHT_BLUE(154),
    GREY3(155);

    public final int code;

    Color(final int code) {
        this.code = code;
    }

    public int getCode() {
        return code;
    }
}

Conversion of the Chatroom to allow Public chat

Is there a way to convert the existing chatroom to allow for public messages?

It would appear that

sendToAll(new ChatMessage(-1, getClientName() + text));

in the correct location would allow messages which did not conform to the other if statement to be posted publicly, but with java not being my primary programming language (python/perl programmer here) it is completely escaping me.

Thanks
Jeff

Correct new line for petscii

Please correct me if I shouldn't be asking questions like this on here.

I'm at my wits end trying to figure this out. I just want to do a regex replace and insert a new line.

.replaceAll("<img.[^>]*>", "\n\r[IMAGE] ")

But instead of a carriage return in the terminal I just get a couple spaces.

"something that should be on line above [IMAGE]"

turns into

"something that should be on line above (space)(space) [IMAGE]"

I'm starting to think I can't use a \n\r because there is nothing to convert it to a petscii carriage return.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.