tmi2_fluffos_v2/
tmi2_fluffos_v2/bin/
tmi2_fluffos_v2/etc/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/ChangeLog.old/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/Win32/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/compat/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/compat/simuls/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/include/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/clone/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/command/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/data/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/etc/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/include/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/inherit/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/inherit/master/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/log/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/single/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/single/tests/compiler/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/single/tests/efuns/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/single/tests/operators/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/testsuite/u/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/tmp/
tmi2_fluffos_v2/fluffos-2.7-ds2.018/windows/
tmi2_fluffos_v2/lib/
tmi2_fluffos_v2/lib/adm/
tmi2_fluffos_v2/lib/adm/daemons/languages/
tmi2_fluffos_v2/lib/adm/daemons/network/I3/
tmi2_fluffos_v2/lib/adm/daemons/virtual/
tmi2_fluffos_v2/lib/adm/daemons/virtual/template/
tmi2_fluffos_v2/lib/adm/news/
tmi2_fluffos_v2/lib/adm/obj/
tmi2_fluffos_v2/lib/adm/obj/master/
tmi2_fluffos_v2/lib/adm/priv/
tmi2_fluffos_v2/lib/adm/shell/
tmi2_fluffos_v2/lib/adm/tmp/
tmi2_fluffos_v2/lib/cmds/
tmi2_fluffos_v2/lib/d/
tmi2_fluffos_v2/lib/d/Conf/
tmi2_fluffos_v2/lib/d/Conf/adm/
tmi2_fluffos_v2/lib/d/Conf/boards/
tmi2_fluffos_v2/lib/d/Conf/cmds/
tmi2_fluffos_v2/lib/d/Conf/data/
tmi2_fluffos_v2/lib/d/Conf/logs/
tmi2_fluffos_v2/lib/d/Conf/obj/
tmi2_fluffos_v2/lib/d/Conf/text/help/
tmi2_fluffos_v2/lib/d/Fooland/adm/
tmi2_fluffos_v2/lib/d/Fooland/data/
tmi2_fluffos_v2/lib/d/Fooland/data/attic/
tmi2_fluffos_v2/lib/d/Fooland/items/
tmi2_fluffos_v2/lib/d/TMI/
tmi2_fluffos_v2/lib/d/TMI/adm/
tmi2_fluffos_v2/lib/d/TMI/boards/
tmi2_fluffos_v2/lib/d/TMI/data/
tmi2_fluffos_v2/lib/d/TMI/rooms/
tmi2_fluffos_v2/lib/d/grid/
tmi2_fluffos_v2/lib/d/grid/adm/
tmi2_fluffos_v2/lib/d/grid/data/
tmi2_fluffos_v2/lib/d/std/
tmi2_fluffos_v2/lib/d/std/adm/
tmi2_fluffos_v2/lib/data/adm/
tmi2_fluffos_v2/lib/data/adm/daemons/
tmi2_fluffos_v2/lib/data/adm/daemons/doc_d/
tmi2_fluffos_v2/lib/data/adm/daemons/emoted/
tmi2_fluffos_v2/lib/data/adm/daemons/network/http/
tmi2_fluffos_v2/lib/data/adm/daemons/network/services/mail_q/
tmi2_fluffos_v2/lib/data/adm/daemons/network/smtp/
tmi2_fluffos_v2/lib/data/adm/daemons/news/archives/
tmi2_fluffos_v2/lib/data/attic/connection/
tmi2_fluffos_v2/lib/data/attic/user/
tmi2_fluffos_v2/lib/data/std/connection/b/
tmi2_fluffos_v2/lib/data/std/connection/l/
tmi2_fluffos_v2/lib/data/std/user/a/
tmi2_fluffos_v2/lib/data/std/user/b/
tmi2_fluffos_v2/lib/data/std/user/d/
tmi2_fluffos_v2/lib/data/std/user/f/
tmi2_fluffos_v2/lib/data/std/user/l/
tmi2_fluffos_v2/lib/data/std/user/x/
tmi2_fluffos_v2/lib/data/u/d/dm/working/doc_d/
tmi2_fluffos_v2/lib/data/u/l/leto/doc_d/
tmi2_fluffos_v2/lib/data/u/l/leto/smtp/
tmi2_fluffos_v2/lib/doc/
tmi2_fluffos_v2/lib/doc/driverdoc/applies/
tmi2_fluffos_v2/lib/doc/driverdoc/applies/interactive/
tmi2_fluffos_v2/lib/doc/driverdoc/concepts/
tmi2_fluffos_v2/lib/doc/driverdoc/driver/
tmi2_fluffos_v2/lib/doc/driverdoc/efuns/arrays/
tmi2_fluffos_v2/lib/doc/driverdoc/efuns/buffers/
tmi2_fluffos_v2/lib/doc/driverdoc/efuns/compile/
tmi2_fluffos_v2/lib/doc/driverdoc/efuns/ed/
tmi2_fluffos_v2/lib/doc/driverdoc/efuns/filesystem/
tmi2_fluffos_v2/lib/doc/driverdoc/efuns/floats/
tmi2_fluffos_v2/lib/doc/driverdoc/efuns/functions/
tmi2_fluffos_v2/lib/doc/driverdoc/efuns/general/
tmi2_fluffos_v2/lib/doc/driverdoc/efuns/mappings/
tmi2_fluffos_v2/lib/doc/driverdoc/efuns/numbers/
tmi2_fluffos_v2/lib/doc/driverdoc/efuns/parsing/
tmi2_fluffos_v2/lib/doc/driverdoc/lpc/constructs/
tmi2_fluffos_v2/lib/doc/driverdoc/lpc/preprocessor/
tmi2_fluffos_v2/lib/doc/driverdoc/lpc/types/
tmi2_fluffos_v2/lib/doc/driverdoc/platforms/
tmi2_fluffos_v2/lib/doc/mudlib/
tmi2_fluffos_v2/lib/ftp/
tmi2_fluffos_v2/lib/include/driver/
tmi2_fluffos_v2/lib/log/
tmi2_fluffos_v2/lib/log/driver/
tmi2_fluffos_v2/lib/obj/net/
tmi2_fluffos_v2/lib/obj/shells/
tmi2_fluffos_v2/lib/obj/tools/
tmi2_fluffos_v2/lib/std/adt/
tmi2_fluffos_v2/lib/std/board/
tmi2_fluffos_v2/lib/std/body/
tmi2_fluffos_v2/lib/std/fun/
tmi2_fluffos_v2/lib/std/living/
tmi2_fluffos_v2/lib/std/object/
tmi2_fluffos_v2/lib/std/shop/
tmi2_fluffos_v2/lib/std/socket/
tmi2_fluffos_v2/lib/std/user/
tmi2_fluffos_v2/lib/std/virtual/
tmi2_fluffos_v2/lib/student/
tmi2_fluffos_v2/lib/student/kalypso/
tmi2_fluffos_v2/lib/student/kalypso/armor/
tmi2_fluffos_v2/lib/student/kalypso/rooms/
tmi2_fluffos_v2/lib/student/kalypso/weapons/
tmi2_fluffos_v2/lib/u/l/leto/
tmi2_fluffos_v2/lib/u/l/leto/cmds/
tmi2_fluffos_v2/lib/www/errors/
tmi2_fluffos_v2/lib/www/gateways/
tmi2_fluffos_v2/lib/www/images/
tmi2_fluffos_v2/old/
tmi2_fluffos_v2/win32/
/*
// File     :  _channels.c
// Purpose  :  show (and alter) which channels exist
// 93-08-28 :  Written by Pallando
*/
#include <channels.h>
#include <daemons.h>
#include <net/daemons.h>
#include <mudlib.h>
#include <messages.h>

inherit DAEMON;

#ifdef NO_NEW_CHANNELS
#define SYNTAX "Syntax: channels [-l [regexp]| who <channel> <mudname> ]\n"
#else
#define SYNTAX "Syntax: channels [ { create | delete | admin | who } <channel> [modifiers] } ]\n"

#endif /* NO_NEW_CHANNELS */

int cmd_channels( string arg )
{
    string *chan_names, *current, *lines, line, flag, channel;
    string group, mode;
    mapping chans;
    int i, stat, type;

    chans = (mapping)CHANNELS_D-> q();
    if( !mapp( chans ) ) chans = ([]);
    chan_names = keys( chans );

    chan_names = filter_array( chan_names, "may_use", this_object(), chans );

    if( !arg )
    {
    for( i=0; i<sizeof(chan_names); i++ )
        if( chans[chan_names[i]]["object"] )
          chan_names[i] += "*";

        if( !sizeof( chan_names ) )
            write( "There are no active channels.\n" );
        else
            write( "The channels are:\n"+wrap( implode( chan_names, ", " ) ) );
        return 1;
    }
    channel="";
    if( arg == "-l" || sscanf( arg, "-l %s", channel) == 1 ) {
	lines = ({ });
        for( i=0; i<sizeof(chan_names); i++ ) {
	  line = sprintf( "%-18s %-13s", chan_names[i], 
		  chans[chan_names[i]]["priv"] ? chans[chan_names[i]]["priv"] : "player" );
	  if( chans[chan_names[i]]["object"] ) {
		line += " I3: "+chans[chan_names[i]]["creator"]+", ";
		switch( chans[chan_names[i]]["mode"] ) {
		 case 0: line += "selective ban";
			 break;
		 case 1: line += "selcectve allow";
			 break;
		 case 2: line += "filtered list";
			 break;
		}
	   }
	  lines += ({ line });
	}
	  if( channel ) lines = regexp( lines, channel );
	  this_player()->more( lines );
	  return 1;
   }
    notify_fail( SYNTAX );
    if( sscanf( arg, "%s %s", flag, channel ) != 2 )
        return 0;

    if( flag == "who" && adminp( this_player()) ) {
        string mud;
        if( sscanf( channel, "%s %s", channel, mud ) != 2 )
                return 0;
        message( MSG_COMMAND, "Send channel who request to "+mud+"\n",
                this_player() );
        CHANNELS_D->display_i3channel( channel, mud, this_player() );
        return 1;
    } 
 
	

#ifdef NO_NEW_CHANNELS
    return 0;
#else

    if( flag == "create" && adminp(this_player()) )
    {   sscanf( channel, "%s %s", channel, group);
	if(group) sscanf( group, "%s %s", group, mode );
	write( channel+" "+group+" "+mode+"\n" );
        if( mode )
	    switch( mode ) {
	      case "ban": type = 0; break;
	      case "admit": type = 1; break;
	      case "filter": type = 2; break;
	      default: notify_fail( "Unkown channel mode: "+mode+"\n" );
		       return 0; 
          }
	if( group == "player" || group == "all" ) group = 0;
	if( group && !member_group( geteuid( this_player()), group ) ) {
		notify_fail("You dont even belong to the group "+group+".\n" );
		return 0;
	}
	if( mode )
          stat=(int)CHANNELS_D-> register_channel( channel,
		this_player(), CRE, ({ group, type, (object)I3_DAEMON}) );
	else
	  stat=(int)CHANNELS_D-> register_channel( channel,
                this_player(), CRE, ({ group }) );
        if( stat ) 
            write( "Channel " + channel + " created.\n" );
        else
            write( "You may not do that.\n" );
        return 1;
    } else
    if( flag == "admin" && adminp(this_player()) ) {
	// This looks ugly ? ;)
	string *add_list=({ }), *rem_list=({ }), remove, add;
	if( sscanf( channel, "%s /add %s", channel, add ) == 2 )
		add_list=explode( add, " " );
	else if( sscanf( channel, "%s /remove %s", channel, remove ) == 2)
		rem_list=explode( remove, " " );
	else {
		notify_fail( "You must specifiy either /add or /remove.\n" );
		return 0;
	}
	if( !chans[channel] ) {
                notify_fail("Channel '"+channel+"' doesnt exist.\n" );
                return 0;
        }      
	stat=(int)CHANNELS_D-> register_channel( channel, this_player(), ADM,
				({ add_list, rem_list }) );
	if( stat ) write("Channel admin request send.\n" );
	else {
	 	notify_fail( "Failed to send channel admin request.\n" );
		return 0;
	}
	return 1;
	
    } 
    if( flag == "delete" && adminp(this_player()) )
    {   if( !chans[channel] ) {
		notify_fail("Channel '"+channel+"' doesnt exist.\n" );
		return 0;
	}
        if( CHANNELS_D-> register_channel( channel, this_player(), DEL, 0 ) )
            write( "Channel " + channel + " deleted.\n" );
        else
            write( "You may not do that.\n" );
        return 1;
    }
    return 0;
#endif /* NO_NEW_CHANNELS */
}

int may_use( string chan, mapping chans )
{
    return( !stringp( chans[chan]["priv"] ) || chans[chan]["priv"]=="all" || ( 0 !=
      member_group( geteuid( this_player() ), chans[chan]["priv"] ) ) );
}

int help()
{
#ifndef NO_NEW_CHANNELS
  write( @EndText
Syntax: channels create <channel> [group] [mode]
Syntax: channels delete <channel>
Syntax: channels admin  <channel> </add list|/remove list>
Syntax: channels who    <channel> <MUDName>
Effect: Creates a channel named <channel>
	- group: users must be in that group to be able to use the channel
	- mode: I3 channel mode: ban, admit or filter

Syntax: channels delete <channel>
Effect: Deletes channel <channel> (uncreates it)

EndText
  );
#endif /* NO_NEW_CHANNELS */
  write( @EndText
Syntax: channels [-l [regexp]] 
Effect: Shows the currently existing channels you can use.
Channels appened with an asterix '*' are remote channels.
If you specifiy the '-l' flag, you will get a verbose
listening of all the channels includeing group access and
for I3 channels the creator MUD and their mode.

To use a channel, eg "gossip", you must first tune into it.
  "tune gossip"    (see "help tune" for more details)
then to broadcast <message> to everyone else on the channel, just type
  "gossip<message>"
To see who is on a channel type
  "show gossip"    (see "help show" for more details)

There are a couple of special channels "gwiz" and "code".
These broadcast to users not just on this mud but about 160 other muds.
(See "help mudlist").
EndText
  );
  return 1;
}