Added Automessage Feature
This commit is contained in:
parent
ac02b2b805
commit
59c511795b
Binary file not shown.
71
bbs.c
71
bbs.c
@ -350,6 +350,8 @@ static int handler(void* user, const char* section, const char* name,
|
||||
} else {
|
||||
conf->external_editor_stdio = 0;
|
||||
}
|
||||
} else if (strcasecmp(name, "automessage write level") == 0) {
|
||||
conf->automsgwritelvl = atoi(value);
|
||||
}
|
||||
} else if (strcasecmp(section, "paths") == 0){
|
||||
if (strcasecmp(name, "ansi path") == 0) {
|
||||
@ -660,6 +662,72 @@ void display_info(int socket) {
|
||||
s_getc(socket);
|
||||
}
|
||||
|
||||
void automessage_write(int socket, struct user_record *user) {
|
||||
FILE *fptr;
|
||||
char automsg[450];
|
||||
char buffer[90];
|
||||
int i;
|
||||
struct tm timenow;
|
||||
time_t timen;
|
||||
|
||||
memset(automsg, 0, 450);
|
||||
memset(buffer, 0, 90);
|
||||
|
||||
if (user->sec_level >= conf.automsgwritelvl) {
|
||||
timen = time(NULL);
|
||||
localtime_r(&timen, &timenow);
|
||||
|
||||
sprintf(automsg, "Posted by %s @ %s", user->loginname, asctime(&timenow));
|
||||
|
||||
automsg[strlen(automsg) - 1] = '\r';
|
||||
automsg[strlen(automsg)] = '\n';
|
||||
|
||||
for (i=0;i<4;i++) {
|
||||
sprintf(buffer, "\r\n%d: ", i);
|
||||
s_putstring(socket, buffer);
|
||||
s_readstring(socket, buffer, 75);
|
||||
strcat(automsg, buffer);
|
||||
strcat(automsg, "\r\n");
|
||||
}
|
||||
|
||||
fptr = fopen("automessage.txt", "w");
|
||||
if (fptr) {
|
||||
fwrite(automsg, strlen(automsg), 1, fptr);
|
||||
fclose(fptr);
|
||||
} else {
|
||||
printf("Unable to open automessage.txt for writing\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void automessage_display(int socket) {
|
||||
struct stat s;
|
||||
FILE *fptr;
|
||||
char buffer[90];
|
||||
int i;
|
||||
s_putstring(socket, "\r\n\r\n");
|
||||
if (stat("automessage.txt", &s) == 0) {
|
||||
fptr = fopen("automessage.txt", "r");
|
||||
if (fptr) {
|
||||
for (i=0;i<5;i++) {
|
||||
memset(buffer, 0, 90);
|
||||
fgets(buffer, 88, fptr);
|
||||
buffer[strlen(buffer) - 1] = '\r';
|
||||
buffer[strlen(buffer)] = '\n';
|
||||
|
||||
s_putstring(socket, buffer);
|
||||
}
|
||||
fclose(fptr);
|
||||
} else {
|
||||
printf("Error opening automessage.txt\n");
|
||||
}
|
||||
} else {
|
||||
s_putstring(socket, "No automessage!\r\n");
|
||||
}
|
||||
s_putstring(socket, "\e[0mPress any key to continue...\r\n");
|
||||
s_getc(socket);
|
||||
}
|
||||
|
||||
void runbbs(int socket, char *config_path, char *ip) {
|
||||
char buffer[256];
|
||||
char password[17];
|
||||
@ -697,6 +765,7 @@ void runbbs(int socket, char *config_path, char *ip) {
|
||||
conf.external_editor_cmd = NULL;
|
||||
conf.log_path = NULL;
|
||||
conf.script_path = NULL;
|
||||
conf.automsgwritelvl = 10;
|
||||
|
||||
// Load BBS data
|
||||
if (ini_parse(config_path, handler, &conf) <0) {
|
||||
@ -882,6 +951,8 @@ void runbbs(int socket, char *config_path, char *ip) {
|
||||
}
|
||||
|
||||
mail_scan(socket, user);
|
||||
|
||||
automessage_display(socket);
|
||||
}
|
||||
record_last10_callers(user);
|
||||
// main menu
|
||||
|
3
bbs.h
3
bbs.h
@ -99,6 +99,7 @@ struct bbs_config {
|
||||
|
||||
int nodes;
|
||||
int newuserlvl;
|
||||
int automsgwritelvl;
|
||||
int mail_conference_count;
|
||||
struct mail_conference **mail_conferences;
|
||||
int door_count;
|
||||
@ -132,6 +133,8 @@ struct user_record {
|
||||
int timeson;
|
||||
};
|
||||
|
||||
extern void automessage_write(int socket, struct user_record *user);
|
||||
extern void automessage_display(int socket);
|
||||
extern void dolog(char *fmt, ...);
|
||||
extern void runbbs(int sock, char *config, char *ipaddress);
|
||||
extern struct fido_addr *parse_fido_addr(const char *str);
|
||||
|
@ -9,6 +9,7 @@ IRC Channel = #bbs
|
||||
Default Tagline = Brought to you by Another Magicka BBS!
|
||||
External Editor cmd = /home/andrew/MagickaBBS/doors/oedit.sh
|
||||
External Editor stdio = false
|
||||
Automessage Write Level = 10
|
||||
|
||||
[paths]
|
||||
ANSI Path = /home/andrew/MagickaBBS/ansis
|
||||
|
@ -112,6 +112,11 @@ int l_bbsTimeLeft(lua_State *L) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int l_bbsDisplayAutoMsg(lua_State *L) {
|
||||
automessage_display(gSocket);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int l_getMailAreaInfo(lua_State *L) {
|
||||
lua_pushnumber(L, gUser->cur_mail_conf);
|
||||
lua_pushstring(L, conf.mail_conferences[gUser->cur_mail_conf]->name);
|
||||
@ -157,4 +162,6 @@ void lua_push_cfunctions(lua_State *L) {
|
||||
lua_setglobal(L, "bbs_cur_mailarea_info");
|
||||
lua_pushcfunction(L, l_getFileAreaInfo);
|
||||
lua_setglobal(L, "bbs_cur_filearea_info");
|
||||
lua_pushcfunction(L, l_bbsDisplayAutoMsg);
|
||||
lua_setglobal(L, "bbs_display_automsg");
|
||||
}
|
||||
|
@ -67,6 +67,11 @@ void main_menu(int socket, struct user_record *user) {
|
||||
}
|
||||
|
||||
switch(tolower(c)) {
|
||||
case 'o':
|
||||
{
|
||||
automessage_write(socket, user);
|
||||
}
|
||||
break;
|
||||
case 'a':
|
||||
{
|
||||
if (conf.text_file_count > 0) {
|
||||
|
Reference in New Issue
Block a user