NexusChat

Classes Tutorial Classes Tutorial

This is a quick tutorial for those who want to change NexusChat's class system, or write their own from scratch

Class Basics

The class file, nc_class by default, contains all the mappings of commands to user classes. Using the class file you can set up groups of users that will have specific rights and commands.

First, lets define a class. A class is nothing more than a collection of default data, a set of commands, and a priority.

What is priority?

A priority is an integer, usually from 1-10, but it can be any range you want. Using priorities we can set up a hierachy of control for our users.

There are certain option settings in NexusChat that let you specify a priority setting for users to be able to use that feature. When setting a priority option, anyone at or above that priority will be able to use the feature.

For example, if you set the option broadcast_priority to 5, anyone with a class priority of 5 or higher will get broadcasted log messages.

Priority is also useful for making certain classes more powerful than others. For example, the /k (CMD_KILL) command cannot be used on someone with a higher priority. So a priority 5 user with /k cannot kick off a priority 10 sysop.

For a full list of NexusChat's priority settings, please see the Admin Guide

Restrictions

There are a few restrictions on creating your own class structure. You must have both a GUEST and SYSOP class for NexusChat to function correctly. You should probably also make sure that SYSOP has the highest priority, as it is a special class that should have access to everything.
The classes are stored in an array, and the current max class count is 10, but you can increase it if you need. Also, each line in nc_class must be < 200 characters

You will also need a NEW class if you wanted newly registered uses to be able to log directly into their accounts after a sucessful registration.

Example Class File

Below is an example class file which we will disect


 1: [ GUEST ]
 2: handle=?
 3: time=15
 4: node_flags=()
 5: toggles=e
 6: priority=0
 7: CMD_HELP CMD_SUSERS CMD_HANDLE CMD_QUIT
 8: 
 9: [ SYSOP ]
10: time=-1
11: node_flags={}
12: toggles=e
13: priority=10
14: (GUEST)
15: CMD_KILL

The first line [ GUEST ] specifies that we will be defining a class called GUEST. Lines 2-6 specify default values for the GUEST class. You can specify as many default options you want, or none.

Line 7 specifies all the commands that this class can use. In this case, extended help, show who's online, change their handle, and logoff. You can can separate the commands on to multiple lines if it becomes too long.

A full list of command identifiers can be found in the Command List

The SYSOP class is the same basic idea except for line 14. The (GUEST) syntax means that we want to inherit all the commands from the GUEST class.

Putting parenthesis around a class name on a line by itself, such as (GUEST) in the example, tells nchat to make that class inherit the other class' commands. In the example the sysop class will inherit the GUEST class' commands (CMD_HELP CMD_SUSERS CMD_HANDLE CMD_QUIT) and also get CMD_KILL.

When using class inheritance, the inherited class must be defined before it is included. In the above example, the GUEST class must come before the sysop.

Default Values

Here are a list of the default values you can assign to a class

handleThis is the default handle for the user
timeThe default time limit for the class
node_flagsThese are parts of the handle that are often used to identify the authority of a user.
togglesThese are the default toggles, a current list of toggles is:
a ANSI color
e Echo
l Lurking enabled
z Input locked
priorityThis is usually a value from 0-MAX_CLASSES, but it can be as as big or small as an int.

These defaults can be changed in the user editor on a per user basis as desired. Also, you do not have to include entries for all, or any of the defaults.

The one exception to both of these rules is 'priority'
Priority may not be set on a per user level, and although nchat does not explicity require you to set the priority, it is defaulted to 0, which is probably NOT what you want (see above)