Fields & Set/Get

Fields are a method of placing information to a users record that can be displayed and propogated in many different ways. You can set it to display in a whois, or only to operators, or when a user joins a channel. There are two commands and an administrative command that are used to create this effect. The first is the field command that is used to create a field. As an example to create a field called age that is displayed to everyone in a 'whois' you would use the following commands:
/as field Age add
/as field Age set whois
/as field Age set remote

Now you want to set that information:

/set <nick> age <data>

/set John age 20

Now everyone will be able to see this when they do:

/whois john

Or they can do:

/get john age

For another example take a look at how we implemented avatars at the end of this technical note.

FIELD <name> [DEL|ADD|LIST|SET]
FIELD <name> DEL
Deletes an existing field.

FIELD <name> ADD
Adds a field with the specified name.

FIELD <name> LIST
Lists all the field settings of the specified name.

FIELD <name> SET <PRIVATE|ONJOIN|ONCHANGE|
WATCH|BUDDY|OPER|ONCE|WHOIS|REMOTE> <ON|OFF>

FIELD <name> SET PRIVATE
Nobody can retrieve the specified field except an IRC Operator or Server Administrator.

FIELD <name> SET ONJOIN
Sends the specified field data to all users when a client joins a channel.

FIELD <name> SET ONCHANGE
Sends the specified field data to all users when a client changes the field data.

FIELD <name> SET WATCH
If you're watching a user and his field changes then you will be notified. This is handy for updates of user status as an example.

FIELD <name> SET BUDDY
Only people on your 'buddy' list can see this field

FIELD <name> SET OPER
Only all opers to view or set this data.

FIELD <name> SET ONCE
Can only set it once.

FIELD <name> SET WHOIS
Show's the field data in the whois information.

FIELD <name> SET REMOTE
Send this inormation for the specified field to remote servers.

SET
SET <nick> <field> <data>

GET
GET <nick> <field>

As an example when we decided to implement avatars we used the Field system. First we created a new field called AVATAR. Then we set it so that when user joined a channel the field would send to all other clients in a channel. We set it to broadcast to all others in a channel when it was changed. With just these settings we were able to code the java client to support avatars.

Avatar Field Configuration:
field avatar add
field avatar set onjoin on
field avatar set onchange on
field avatar set remote on

The java client has several params for avatars that let admins define graphics that will be used when certain the field AVATAR is set.

prm file:
avatar0=avatar16/alien16.gif Alien

html param:
<param name="avatar" value="0=avatar16/alien16.gif Alien">

The first is the param name, Then the path and file followed by the field name.

When you select an avatar the java client will set the field avatar with the field name and display the graphic that was specified in the avatar param.