add motd to magichat..
This commit is contained in:
parent
3f837d98ba
commit
e34be09ad8
@ -226,7 +226,7 @@ void chat_system(struct user_record *user) {
|
|||||||
input_b = encapsulate_quote(inputbuffer);
|
input_b = encapsulate_quote(inputbuffer);
|
||||||
raw("{ \"bbs\": \"%s\", \"nick\": \"%s\", \"msg\": \"%s\" }", conf.mgchat_bbstag, user->loginname, input_b);
|
raw("{ \"bbs\": \"%s\", \"nick\": \"%s\", \"msg\": \"%s\" }", conf.mgchat_bbstag, user->loginname, input_b);
|
||||||
free(input_b);
|
free(input_b);
|
||||||
sprintf(buffer2, "%s: %s", user->loginname, inputbuffer);
|
sprintf(buffer2, "(%s)[%s]: %s", conf.mgchat_bbstag, user->loginname, inputbuffer);
|
||||||
append_screenbuffer(buffer2);
|
append_screenbuffer(buffer2);
|
||||||
do_update = 1;
|
do_update = 1;
|
||||||
}
|
}
|
||||||
|
@ -46,10 +46,13 @@ int main(int argc, char **argv) {
|
|||||||
int i, j, k;
|
int i, j, k;
|
||||||
char buffer[1024];
|
char buffer[1024];
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
|
char motd[256];
|
||||||
jsmn_parser parser;
|
jsmn_parser parser;
|
||||||
jsmntok_t tokens[8];
|
jsmntok_t tokens[8];
|
||||||
int r;
|
int r;
|
||||||
int nbytes;
|
int nbytes;
|
||||||
|
FILE *fptr;
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
printf("Usage: magichat [port]\n");
|
printf("Usage: magichat [port]\n");
|
||||||
return 0;
|
return 0;
|
||||||
@ -207,6 +210,22 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fptr = fopen("motd.txt", "r");
|
||||||
|
if (fptr) {
|
||||||
|
fgets(motd, 256, fptr);
|
||||||
|
while (!feof(fptr)) {
|
||||||
|
if (motd[strlen(buffer) - 1] == '\n') {
|
||||||
|
motd[strlen(buffer) - 1] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf(buffer, 1024, "{\"bbs\": \"SYSTEM\", \"nick\": \"SYSTEM\", \"msg\": \"%s\" }", motd);
|
||||||
|
send(clients[j]->fd, buffer, strlen(buffer) + 1, 0);
|
||||||
|
fgets(motd, 256, fptr);
|
||||||
|
}
|
||||||
|
fclose(fptr);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user