home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 2 BBS
/
02-BBS.zip
/
bbbsr2.zip
/
scripts
/
error.bz
< prev
next >
Wrap
Text File
|
1997-06-26
|
5KB
|
171 lines
/*
* Error.bz - Run when an unknown command occures
*
* See script.gui for more information about parsecom and other bz commands.
* Remember to recompile this script after you've done some changes.
*
* This script has some commands that are allready defined. These are:
*
* User Commands:
* glob: REGEXP Gives help about Regular expressions
* glob: CLS Clears the screen
* glob: ADDON Shows the files USERMENU.GR and USERMENS.GR
* Theese files must reside in one of your
* menu directories.
* util: FILT MBBS Compability dummy-command.
* util: GR MBBS Compability dummy-command.
*
* Sysop Commands:
* glob: RUN Runs an external script.
*/
#include <stdlib.bzh>
int usermenu() {
int f;
if (bu_language>0) {
if ((f=fopen(sprintf("%s%s%u",bl_menudir,"usermenu.gr",bu_language),"rt"))!=-1) {
fclose(f);
showfile(sprintf("%s%s%u",bl_menudir,"usermenu.gr",bu_language));
} else showfile(sprintf("%s%s%u",bg_menudir,"usermenu.gr",bu_language));
if (bu_access & 255) {
if ((f=fopen(sprintf("%s%s%u",bl_menudir,"usermens.gr",bu_language),"rt"))!=-1) {
fclose(f);
showfile(sprintf("%s%s%u",bl_menudir,"usermens.gr",bu_language));
} else showfile(sprintf("%s%s%u",bg_menudir,"usermens.gr",bu_language));
}
} else {
if ((f=fopen(strcat(bl_menudir,"usermenu.gr"),"rt"))!=-1) {
fclose(f);
showfile(strcat(bl_menudir,"usermenu.gr"));
} else showfile(strcat(bg_menudir,"usermenu.gr"));
if (bu_access & 255) {
if ((f=fopen(strcat(bl_menudir,"usermens.gr"),"rt"))!=-1) {
fclose(f);
showfile(strcat(bl_menudir,"usermens.gr"));
} else showfile(strcat(bg_menudir,"usermens.gr"));
}
}
}
int main(char com, int tomenu) {
/*
* tomenu: 1=read, 2=main, 3=util, 4=file, 5=chat, 6=outb, 7=ftp
* 128=join_no_access, 129=file_cd_no_access, 130=bz::file4()
* 131=feelings
*/
char s, r;
int f;
/*
File format for commands.bbb is:
--cut--
;Command Menu Script, *bbbs_command or !os_command
;==================================================================
FOObar 2 unpack
TEST 1 *!This is a test.
ACCess !,fsysop, 1 *>b You have access!
--cut--
Optional "!regexp_of_groups" can be added before menu parameter.
Use lowercase characters!
*/
if ((f=fopen("commands.bbb","rt"))!=-1) {
do {
s=fgets(f);
if (s!="" && copy(s,1,1)!=";" && pos(" ",s)) {
r=copy(s,1,pos(" ",s)-1);
if (parsecom(r,com)==1) {
s=delete(s,1,strlen(r));
while (copy(s,1,1)==" ") s=delete(s,1,1);
if (pos(" ",s)) {
r=copy(s,1,pos(" ",s)-1);
if (copy(r,1,1)=="!") {
if (!regexp(copy(r,2,255),bv_groups)) r="";
else {
s=delete(s,1,strlen(r));
while (copy(s,1,1)==" ") s=delete(s,1,1);
if (pos(" ",s)) r=copy(s,1,pos(" ",s)-1);
}
}
if ((r=="*" || r==tomenu) && pos(" ",s)) {
s=delete(s,1,strlen(r));
while (copy(s,1,1)==" ") s=delete(s,1,1);
fclose(f);
if (copy(s,1,1)=="*") bbbs(copy(s,2,256));
else
if (copy(s,1,1)=="!") system(copy(s,2,256),1);
else spawn(s);
exit(0);
}
}
}
}
} while (!feof(f));
fclose(f);
}
/* Local commands */
switch (parsecom("FILT/GR",com)) {
case 1:{ /* FILT */
if (tomenu==3) { /* utilmenu */
printf("Noise filter disabled.\n");
exit(0);
}
break;
}
case 2:{ /* GR */
if (tomenu==3) { /* utilmenu */
printf("G&R commands disabled.\n");
exit(0);
}
break;
}
}
/* Global commands */
if (tomenu!=131)
switch (parsecom("REGEXP/CLS/ADDON/RUN",com)) {
case 1:{ /* REGEXP */
help("","regexp");
exit(0);
}
case 2:{ /* CLS */
printf("\e[1;1H\e[2J");
exit(0);
}
case 3:{ /* ADDON */
usermenu();
exit(0);
}
case 4:{ /* RUN */
if (bu_access & 1) {
s=input("Script: ",69,1);
if (s!="") spawn(s);
}
exit(0);
}
}
/* Just print the error message */
if (bn_zstatus!=5 && bn_zstatus!=6 && bn_zstatus!=9) {
if (tomenu==128) printf("%s\n",bv_txt[22]); /* join_no_access */
else
if (tomenu==129) printf(bv_txt[629]); /* file_cd_no_access */
else
if (tomenu==131) printf(bv_txt[23],com); /* chat */
else
printf(bv_txt[23],com); /* invalid command */
}
bv_comstring="";
exit(0);
}