Rapid Prototyping of MUD Servers

1 view
Skip to first unread message

Chris Norman

unread,
May 5, 2017, 4:21:35 AM5/5/17
to MOO-...@googlegroups.com

Hi all,

I found myself creating lots of text-based servers recently, so I decided to make it into a package.


It's called gsb, and is available from here, and enables you to create MUD-type servers quickly.


There's more extensive examples in the examples directory of the source repo, as well as full documentation, but here's a basic outline:


from gsb import Server


s = Server()  # Port defaults to 4000



@s.command('^shout ([^$]+)$')

def shout(caller):

    s.broadcast('Someone shouts: %s', caller.match.groups()[0])



s.run()


As you can see it's API is similar to that of Flask or Klein.


There are also a bunch of events which can be intercepted by subclassing gsb.Server:


class MyServer(Server):

    def on_connect(self, caller):

        with open('connections.txt', 'a') as f:

            f.write('New connection from %s:%d.' % (caller.connection.host, caller.connection.port))


I hope it's of use to somebody.


If anyone has any suggestions or anything please let me know.


Take care,


Chris

Reply all
Reply to author
Forward
0 new messages