lima-1.0b5/
lima-1.0b5/driver/
lima-1.0b5/driver/ChangeLog.old/
lima-1.0b5/driver/Win32/
lima-1.0b5/driver/compat/
lima-1.0b5/driver/include/
lima-1.0b5/driver/testsuite/
lima-1.0b5/driver/testsuite/clone/
lima-1.0b5/driver/testsuite/command/
lima-1.0b5/driver/testsuite/data/
lima-1.0b5/driver/testsuite/etc/
lima-1.0b5/driver/testsuite/include/
lima-1.0b5/driver/testsuite/inherit/
lima-1.0b5/driver/testsuite/inherit/master/
lima-1.0b5/driver/testsuite/log/
lima-1.0b5/driver/testsuite/single/
lima-1.0b5/driver/testsuite/single/tests/compiler/
lima-1.0b5/driver/testsuite/single/tests/efuns/
lima-1.0b5/driver/testsuite/single/tests/operators/
lima-1.0b5/driver/testsuite/u/
lima-1.0b5/driver/tmp/
lima-1.0b5/etc/
lima-1.0b5/lib/WWW/help/
lima-1.0b5/lib/cmds/
lima-1.0b5/lib/cmds/create/
lima-1.0b5/lib/cmds/player/attic/
lima-1.0b5/lib/contrib/bboard/
lima-1.0b5/lib/contrib/boards/
lima-1.0b5/lib/contrib/marriage/
lima-1.0b5/lib/contrib/roommaker/
lima-1.0b5/lib/contrib/transient_effect/
lima-1.0b5/lib/daemons/channel/
lima-1.0b5/lib/daemons/imud/
lima-1.0b5/lib/data/
lima-1.0b5/lib/data/config/
lima-1.0b5/lib/data/links/
lima-1.0b5/lib/data/news/
lima-1.0b5/lib/data/players/
lima-1.0b5/lib/data/secure/
lima-1.0b5/lib/domains/
lima-1.0b5/lib/domains/std/2.4.5/maze1/
lima-1.0b5/lib/domains/std/2.4.5/npc/
lima-1.0b5/lib/domains/std/2.4.5/post_dir/
lima-1.0b5/lib/domains/std/2.4.5/sub/
lima-1.0b5/lib/domains/std/camera/
lima-1.0b5/lib/domains/std/config/
lima-1.0b5/lib/domains/std/cult/
lima-1.0b5/lib/domains/std/effects/
lima-1.0b5/lib/domains/std/misc/
lima-1.0b5/lib/domains/std/monsters/
lima-1.0b5/lib/domains/std/recorder/
lima-1.0b5/lib/domains/std/rooms/
lima-1.0b5/lib/domains/std/rooms/beach/
lima-1.0b5/lib/domains/std/rooms/labyrinth/
lima-1.0b5/lib/domains/std/school/
lima-1.0b5/lib/domains/std/school/O/
lima-1.0b5/lib/domains/std/spells/
lima-1.0b5/lib/domains/std/spells/stock-mage/
lima-1.0b5/lib/domains/std/spells/stock-priest/
lima-1.0b5/lib/help/
lima-1.0b5/lib/help/admin/
lima-1.0b5/lib/help/hints/General_Questions/
lima-1.0b5/lib/help/hints/Pirate_Quest/
lima-1.0b5/lib/help/player/
lima-1.0b5/lib/help/player/bin/
lima-1.0b5/lib/help/player/quests/
lima-1.0b5/lib/help/wizard/
lima-1.0b5/lib/help/wizard/coding/guilds/
lima-1.0b5/lib/help/wizard/coding/rooms/
lima-1.0b5/lib/help/wizard/lib/daemons/
lima-1.0b5/lib/help/wizard/lib/lfun/
lima-1.0b5/lib/help/wizard/lib/std/
lima-1.0b5/lib/help/wizard/mudos_doc/
lima-1.0b5/lib/help/wizard/mudos_doc/applies/
lima-1.0b5/lib/help/wizard/mudos_doc/applies/interactive/
lima-1.0b5/lib/help/wizard/mudos_doc/applies/parsing/
lima-1.0b5/lib/help/wizard/mudos_doc/concepts/
lima-1.0b5/lib/help/wizard/mudos_doc/driver/
lima-1.0b5/lib/help/wizard/mudos_doc/efuns/
lima-1.0b5/lib/help/wizard/mudos_doc/efuns/arrays/
lima-1.0b5/lib/help/wizard/mudos_doc/efuns/buffers/
lima-1.0b5/lib/help/wizard/mudos_doc/efuns/compile/
lima-1.0b5/lib/help/wizard/mudos_doc/efuns/filesystem/
lima-1.0b5/lib/help/wizard/mudos_doc/efuns/floats/
lima-1.0b5/lib/help/wizard/mudos_doc/efuns/functions/
lima-1.0b5/lib/help/wizard/mudos_doc/efuns/general/
lima-1.0b5/lib/help/wizard/mudos_doc/efuns/mappings/
lima-1.0b5/lib/help/wizard/mudos_doc/efuns/mixed/
lima-1.0b5/lib/help/wizard/mudos_doc/efuns/numbers/
lima-1.0b5/lib/help/wizard/mudos_doc/efuns/parsing/
lima-1.0b5/lib/help/wizard/mudos_doc/lpc/constructs/
lima-1.0b5/lib/help/wizard/mudos_doc/lpc/types/
lima-1.0b5/lib/include/driver/
lima-1.0b5/lib/log/
lima-1.0b5/lib/obj/admtool/
lima-1.0b5/lib/obj/admtool/internal/
lima-1.0b5/lib/obj/admtool/mudinfo/
lima-1.0b5/lib/obj/admtool/secure/
lima-1.0b5/lib/obj/secure/
lima-1.0b5/lib/obj/secure/cmd/
lima-1.0b5/lib/obj/secure/mailers/
lima-1.0b5/lib/obj/secure/shell/
lima-1.0b5/lib/obj/secure/shell/classes/
lima-1.0b5/lib/obj/tasktool/
lima-1.0b5/lib/obj/tasktool/internal/
lima-1.0b5/lib/open/
lima-1.0b5/lib/secure/
lima-1.0b5/lib/secure/cgi/
lima-1.0b5/lib/secure/modules/
lima-1.0b5/lib/secure/simul_efun/
lima-1.0b5/lib/std/adversary/
lima-1.0b5/lib/std/adversary/advancement/
lima-1.0b5/lib/std/adversary/armor/
lima-1.0b5/lib/std/adversary/blows/
lima-1.0b5/lib/std/adversary/death/
lima-1.0b5/lib/std/adversary/formula/
lima-1.0b5/lib/std/adversary/health/
lima-1.0b5/lib/std/adversary/pulse/
lima-1.0b5/lib/std/adversary/wield/
lima-1.0b5/lib/std/classes/event_info/
lima-1.0b5/lib/std/container/
lima-1.0b5/lib/std/living/
lima-1.0b5/lib/std/modules/contrib/
lima-1.0b5/lib/std/patterns/
lima-1.0b5/lib/std/race/
lima-1.0b5/lib/std/race/restricted/
lima-1.0b5/lib/std/room/
lima-1.0b5/lib/tmp/
lima-1.0b5/lib/trans/
lima-1.0b5/lib/trans/admincmds/
lima-1.0b5/lib/trans/obj/
lima-1.0b5/lib/wiz/
/* Do not remove the headers from this file! see /USAGE for more info. */

inherit "/obj/admtool/internal/base.c";

nomask string module_name() {
    return "news";
}

nomask string module_key() {
    return "n";
}

nomask string module_user() {
    return "[Mudlib:daemons]";
}

nomask string module_priv() {
    return "Mudlib:daemons";
}

private nomask void list_newsgroups()
{
    string* grouplist = NEWS_D->get_groups();

    if ( sizeof(grouplist) == 0 )
    {
	write("    <none>\n");
	return;
    }
    grouplist = sort_array(grouplist, 1);
    more(grouplist);
}

private nomask void rcv_add_newsgroup(string str)
{
    str = lower_case(trim_spaces(str));
    if ( str == "" )
	return;

    if ( member_array(str, NEWS_D->get_groups()) != -1 )
    {
	write("** That group already exists.\n");
	return;
    }
    NEWS_D->add_group(str);
    printf("** Group '%s' added.\n", str);
}

private nomask void rcv_remove_newsgroup(string group_name)
{
    string* grouplist = NEWS_D->get_groups();

    if ( !group_name )
    {
	write("** no group name supplied.\n");
	return;
    }

    group_name = lower_case(trim_spaces(group_name));
    if ( member_array(group_name, grouplist) == -1 )
    {
	write("** That newsgroup does not exist.\n");
	return;
    }

    NEWS_D->remove_group(group_name);
    printf("** Group '%s' removed.\n", group_name);
}

private void rcv_archive_group(string group,int days)
{
    if ( member_array(group,NEWS_D->get_groups()) == -1 )
    {
	write("** That newsgroup does not exist.\n");
	return;
    }
    NEWS_D->set_archive_time(group,to_int(days));
}

private void rcv_show_archive_times()
{
    string array output=({});
    mapping archive_info=NEWS_D->get_archive_info();
    if(!sizeof(keys(archive_info)))
    {
	write("No archived newsgroups.\n");
	return;
    }
    //  foreach(string group,int day in archive_info)
    foreach(string group in sort_array(keys(archive_info),1))
    {
	int day = archive_info[group];
	output+=({sprintf("%s archives after %d days",group,day)});
    }
    more(output);
}

private void rcv_forward_mail(string group,string destination)
{
    if(member_array(group,NEWS_D->get_groups())==-1)
    {
	write ("** That newsgroup does not exist\n");
	return;
    }
    NEWS_D->add_mail_forward(group,destination);
    printf("Group %s forwarded to %s\n",group,destination);
}

private void rcv_unforward_mail(string group,string destination)
{
    if(member_array(group,NEWS_D->get_groups())==-1)
    {
	write("** That newsgroup does not exist\n");
	return;
    }
    if(destination=="0")
    {
	NEWS_D->remove_mail_forward(group);
	printf("Group %s is no longer forwarded anywhere\n",group);
	return;
    }
    NEWS_D->remove_mail_forward(group,destination);
    printf("Group %s is not forwarded to %s",group,destination);
}

private nomask void rcv_list_forward_newsgroup(string group)
{
    string array addies;
    if(member_array(group,NEWS_D->get_groups())==-1)
    {
	write("** That newsgroup does not exist\n");
	return;
    }
    addies=NEWS_D->query_mail_forward(group);
    if(!addies) {
	write("Permission denied.\n");
	return;
    }
    addies=sort_array(addies, 1);
    printf("Group %s is forwarded to the following addresses\n",group);
    more(addies);
}

private nomask void show_restrictions()
{
    string output;
    mapping restrictions=NEWS_D->list_restrictions();
    output=sprintf("Prefix restrictions\n%s",
      sprintf("%=|19s%=|30s%=|30s\n","Prefix","Write","Read") );
    //  foreach(string prefix,mixed restrict in restrictions)
    foreach(string prefix in sort_array(keys(restrictions),1))
    {
	mixed restrict = restrictions[prefix];
	output+=sprintf("%=19s%=30O%=30O\n",prefix,restrict[0],restrict[1]);
    }
    more(output);
}

nomask class command_info array module_commands() {
    return ({
      new(class command_info,
	key : "l",
	desc : "List newsgroups.",
	action : (: list_newsgroups :)),
      new(class command_info,
	key : "a",
	proto : "[group]",
	desc : "Add a new newsgroup",
	args : ({ "New newsgroup name? " }),
	action : (: rcv_add_newsgroup :)),
      new(class command_info,
	key : "r",
	proto : "[group]",
	desc : "Remove a newsgroup",
	args : ({ "Remove which newsgroup? " }),
	action : (: rcv_remove_newsgroup :)),
      new(class command_info,
	key : "A",
	proto : "[group] [#days]",
	desc : "Archive a group", 
	args : ({ "Which newsgroup? ", "How many days? " }),
	action : (: rcv_archive_group :)),
      new(class command_info,
	key : "T",
	desc : "Show archive times of groups",
	action : (: rcv_show_archive_times :)),
      new(class command_info,
	key : "f",
	proto : "[group] [email]",
	desc : "Forward a group to an email address",
	args : ({ "Which newsgroup? ", "Email destination? " }),
	action : (: rcv_forward_mail :)),
      new(class command_info,
	key : "u",
	proto : "[group] [email]",
	desc : "Remove an email a group is forwarded to",
	args : ({ "Which newsgroup? ", "Email address (0 for all) " }),
	action : (: rcv_unforward_mail :)),
      new(class command_info,
	key: "L",
	proto : "[group]",
	desc : "List emails a group is forwarded to",
	args : ({ "Which newsgroup? " }),
	action : (: rcv_list_forward_newsgroup :)),
      new(class command_info,
	key : "R",
	proto : "[prefix] [restrict]",
	desc : "Set the read restrictions of a prefix",
	args : ({ "Which prefix? ", "restriction? " }),
	action : (: call_other, NEWS_D, "set_read_restriction" :)),
      new(class command_info,
	key : "W",
	proto : "[prefix] [restrict]",
	desc : "Set the write restrictions of a prefix",
	args : ({ "Which prefix? ", "Restriction? " }),
	action : (: call_other, NEWS_D, "set_write_restriction" :)),
      new(class command_info,
	key : "S",
	desc : "Show the prefix restrictions",
	action : (: show_restrictions :)),
    });
}