Made sysop/user chat working
This commit is contained in:
parent
126b07cf84
commit
de14e49f5c
18
ChangeLog
18
ChangeLog
@ -4,8 +4,6 @@ $Id$
|
||||
menus do not work.
|
||||
All other users on Intel machines (99,9% I think) can use this version.
|
||||
|
||||
WARNING, sysop chat doesn't work right now.
|
||||
|
||||
|
||||
v0.37.2 23-Feb-2003.
|
||||
|
||||
@ -54,11 +52,12 @@ v0.37.2 23-Feb-2003.
|
||||
Fixed user idle logoff when new mailcheck took too long.
|
||||
Added email reply when reading new (e)mail.
|
||||
To page the sysop, the CPAG and CCAN commands to mbtask are now
|
||||
used. Until the chatserver is ready, there is no buildin sysop
|
||||
user chat.
|
||||
used.
|
||||
Removed all old chat code that worked on the tty device.
|
||||
Added chat client site. This is more or less complete but does
|
||||
not yet respond to sysop chat requests.
|
||||
Added chat client site. If the sysop responds to the page
|
||||
request, the user is dropped into chatmode in the sysop
|
||||
channel as soon as the user does nothing (ie in a menu or still
|
||||
in page mode).
|
||||
|
||||
mbmon:
|
||||
Reports sysop available or left the system when mbmon starts
|
||||
@ -71,19 +70,22 @@ v0.37.2 23-Feb-2003.
|
||||
The show lastcallers now adjusts the number of lines available.
|
||||
The show server clients screen now adjusts to the number of
|
||||
lines available.
|
||||
Added chatserver client, this is more or less complete now and
|
||||
does communicate with the development server.
|
||||
Added chatserver client, there are 2 modes, one id general chat
|
||||
and the other is respond to a users page request where the
|
||||
channel is automatic set.
|
||||
|
||||
mbtask:
|
||||
Safer logging of user log messages.
|
||||
In personal message text the text after a ; character is not
|
||||
ignored anymore.
|
||||
With mbtask start, the ports locktimes are reset to zero.
|
||||
Added CSYS command to report if sysop is available.
|
||||
Added CPAG command to page the sysop.
|
||||
Added CCAN command to cancel the sysop page.
|
||||
Added CCKP command to check for a page.
|
||||
Added CCON, CCLO, CPUT and CGET commands for chatserver. The
|
||||
chatserver commands will be added and are in development.
|
||||
Basic chatting now works.
|
||||
|
||||
lang:
|
||||
Changed language prompts 15, 16 and 152.
|
||||
|
6
TODO
6
TODO
@ -22,8 +22,6 @@ libdiesel.a:
|
||||
processed, instead the previous macro value will be returned.
|
||||
|
||||
mbsebbs:
|
||||
N: Rewrite chat to use "mbtask". Write chat functions into "mbmon"
|
||||
|
||||
N: Implement session and time/day limits.
|
||||
|
||||
N: Display archives.
|
||||
@ -149,11 +147,7 @@ mbindex:
|
||||
mbmon:
|
||||
L: Logfile tail functions.
|
||||
|
||||
L: Chat with bbs users.
|
||||
|
||||
mbtask:
|
||||
L: Add chat protocol.
|
||||
|
||||
N: Add events.
|
||||
|
||||
mbnewusr:
|
||||
|
@ -455,9 +455,9 @@ void DispMsg(char *msg)
|
||||
/*
|
||||
* Sysop/user chat
|
||||
*/
|
||||
void Chat(void)
|
||||
void Chat(int sysop)
|
||||
{
|
||||
int curpos = 0, stop = FALSE, data;
|
||||
int curpos = 0, stop = FALSE, data, rc;
|
||||
unsigned char ch = 0;
|
||||
char sbuf[81], resp[128], *cnt, *msg;
|
||||
static char buf[200];
|
||||
@ -466,7 +466,7 @@ void Chat(void)
|
||||
rsize = lines - 7;
|
||||
rpointer = 0;
|
||||
|
||||
sprintf(buf, "CCON,2,%d,%s", mypid, CFG.sysop);
|
||||
sprintf(buf, "CCON,3,%d,%s,%s;", mypid, CFG.sysop, sysop ? "1":"0");
|
||||
Syslog('-', "> %s", buf);
|
||||
if (socket_send(buf) == 0) {
|
||||
strcpy(buf, socket_receive());
|
||||
@ -495,6 +495,16 @@ void Chat(void)
|
||||
memset(&sbuf, 0, sizeof(sbuf));
|
||||
memset(&rbuf, 0, sizeof(rbuf));
|
||||
|
||||
if (sysop) {
|
||||
/*
|
||||
* Join channel #sysop automatic
|
||||
*/
|
||||
sprintf(buf, "CPUT:2,%d,/JOIN #sysop;", mypid);
|
||||
if (socket_send(buf) == 0) {
|
||||
strcpy(buf, socket_receive());
|
||||
}
|
||||
}
|
||||
|
||||
Syslog('-', "Start loop");
|
||||
|
||||
while (stop == FALSE) {
|
||||
@ -507,20 +517,30 @@ void Chat(void)
|
||||
sprintf(buf, "CGET:1,%d;", mypid);
|
||||
if (socket_send(buf) == 0) {
|
||||
strcpy(buf, socket_receive());
|
||||
if (strncmp(buf, "100:1,", 6) == 0) {
|
||||
if (strncmp(buf, "100:2,", 6) == 0) {
|
||||
Syslog('-', "> CGET:1,%d;", mypid);
|
||||
Syslog('-', "< %s", buf);
|
||||
strncpy(resp, strtok(buf, ":"), 10); /* Should be 100 */
|
||||
strncpy(resp, strtok(NULL, ","), 5); /* Should be 1 */
|
||||
strncpy(resp, strtok(NULL, ","), 5); /* Should be 2 */
|
||||
strncpy(resp, strtok(NULL, ","), 5); /* 1= fatal error */
|
||||
rc = atoi(resp);
|
||||
strncpy(resp, strtok(NULL, "\0"), 80); /* The message */
|
||||
resp[strlen(resp)-1] = '\0';
|
||||
DispMsg(resp);
|
||||
if (rc == 1) {
|
||||
Syslog('+', "Chat server error: %s", resp);
|
||||
stop = TRUE;
|
||||
data = FALSE;
|
||||
}
|
||||
} else {
|
||||
data = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (stop)
|
||||
break;
|
||||
|
||||
/*
|
||||
* Update top bars
|
||||
*/
|
||||
@ -550,19 +570,23 @@ void Chat(void)
|
||||
putchar(7);
|
||||
}
|
||||
} else if ((ch == '\r') && curpos) {
|
||||
if (strncasecmp(sbuf, "/exit", 5) == 0)
|
||||
stop = TRUE;
|
||||
sprintf(buf, "CPUT:2,%d,%s;", mypid, sbuf);
|
||||
Syslog('-', "> %s", buf);
|
||||
if (socket_send(buf) == 0) {
|
||||
strcpy(buf, socket_receive());
|
||||
Syslog('-', "< %s", buf);
|
||||
if (strncmp(buf, "100:1,", 6) == 0) {
|
||||
if (strncmp(buf, "100:2,", 6) == 0) {
|
||||
strncpy(resp, strtok(buf, ":"), 10); /* Should be 100 */
|
||||
strncpy(resp, strtok(NULL, ","), 5); /* Should be 1 */
|
||||
strncpy(resp, strtok(NULL, ","), 5); /* Should be 2 */
|
||||
strncpy(resp, strtok(NULL, ","), 5); /* 1= fatal error, end chat */
|
||||
rc = atoi(resp);
|
||||
strncpy(resp, strtok(NULL, "\0"), 80); /* The message */
|
||||
resp[strlen(resp)-1] = '\0';
|
||||
DispMsg(resp);
|
||||
if (rc == 1) {
|
||||
Syslog('+', "Chat server error: %s", resp);
|
||||
stop = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
curpos = 0;
|
||||
@ -581,14 +605,20 @@ void Chat(void)
|
||||
sprintf(buf, "CGET:1,%d;", mypid);
|
||||
if (socket_send(buf) == 0) {
|
||||
strcpy(buf, socket_receive());
|
||||
if (strncmp(buf, "100:1,", 6) == 0) {
|
||||
if (strncmp(buf, "100:2,", 6) == 0) {
|
||||
Syslog('-', "> CGET:1,%d;", mypid);
|
||||
Syslog('-', "< %s", buf);
|
||||
strncpy(resp, strtok(buf, ":"), 10); /* Should be 100 */
|
||||
strncpy(resp, strtok(NULL, ","), 5); /* Should be 1 */
|
||||
strncpy(resp, strtok(NULL, ","), 5); /* Should be 2 */
|
||||
strncpy(resp, strtok(NULL, ","), 5); /* 1= fatal error */
|
||||
rc = atoi(resp);
|
||||
strncpy(resp, strtok(NULL, "\0"), 80); /* The message */
|
||||
resp[strlen(resp)-1] = '\0';
|
||||
DispMsg(resp);
|
||||
if (rc == 1) {
|
||||
Syslog('+', "Chat server error: %s", resp);
|
||||
data = FALSE;
|
||||
}
|
||||
} else {
|
||||
data = FALSE;
|
||||
}
|
||||
@ -598,7 +628,7 @@ void Chat(void)
|
||||
/*
|
||||
* Close server connection
|
||||
*/
|
||||
sprintf(buf, "CCLO,1,%d", mypid);
|
||||
sprintf(buf, "CCLO,1,%d;", mypid);
|
||||
Syslog('-', "> %s", buf);
|
||||
if (socket_send(buf) == 0) {
|
||||
strcpy(buf, socket_receive());
|
||||
@ -694,10 +724,11 @@ int main(int argc, char *argv[])
|
||||
mvprintw( 9, 6, "3. View Filesystem Usage");
|
||||
mvprintw(10, 6, "4. View BBS System Information");
|
||||
mvprintw(11, 6, "5. View BBS Lastcallers List");
|
||||
mvprintw(12, 6, "6. Chat with user");
|
||||
mvprintw(13, 6, "7. View Software Information");
|
||||
mvprintw(12, 6, "6. Chat with any user");
|
||||
mvprintw(13, 6, "7. Respond to sysop page");
|
||||
mvprintw(14, 6, "8. View Software Information");
|
||||
|
||||
switch(select_menu(7)) {
|
||||
switch(select_menu(8)) {
|
||||
case 0:
|
||||
die(0);
|
||||
break;
|
||||
@ -717,9 +748,12 @@ int main(int argc, char *argv[])
|
||||
ShowLastcaller();
|
||||
break;
|
||||
case 6:
|
||||
Chat();
|
||||
Chat(FALSE);
|
||||
break;
|
||||
case 7:
|
||||
Chat(TRUE);
|
||||
break;
|
||||
case 8:
|
||||
soft_info();
|
||||
break;
|
||||
}
|
||||
|
@ -55,6 +55,7 @@ int rsize = 5; /* Chat receive size */
|
||||
extern pid_t mypid;
|
||||
|
||||
|
||||
void Showline(int, int, char *);
|
||||
void DispMsg(char *);
|
||||
void clrtoeol(void);
|
||||
unsigned char testkey(int, int);
|
||||
@ -91,6 +92,37 @@ unsigned char testkey(int y, int x)
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Colorize the chat window
|
||||
*/
|
||||
void Showline(int y, int x, char *msg)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (strlen(msg)) {
|
||||
if (msg[0] == '<') {
|
||||
locate(y, x);
|
||||
colour(LIGHTCYAN, BLACK);
|
||||
putchar('<');
|
||||
colour(BLUE, BLACK);
|
||||
for (i = 1; i < strlen(msg); i++) {
|
||||
if (msg[i] == '>') {
|
||||
colour(LIGHTCYAN, BLACK);
|
||||
putchar(msg[i]);
|
||||
colour(CYAN, BLACK);
|
||||
} else {
|
||||
putchar(msg[i]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
colour(RED, BLACK);
|
||||
mvprintw(y, x, msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Display received chat message in the chat window.
|
||||
*/
|
||||
@ -99,7 +131,7 @@ void DispMsg(char *msg)
|
||||
int i;
|
||||
|
||||
strncpy(rbuf[rpointer], msg, 80);
|
||||
mvprintw(2 + rpointer, 1, rbuf[rpointer]);
|
||||
Showline(2 + rpointer, 1, rbuf[rpointer]);
|
||||
if (rpointer == rsize) {
|
||||
/*
|
||||
* Scroll buffer
|
||||
@ -108,7 +140,7 @@ void DispMsg(char *msg)
|
||||
locate(i + 2, 1);
|
||||
clrtoeol();
|
||||
sprintf(rbuf[i], "%s", rbuf[i+1]);
|
||||
mvprintw(i + 2, 1, rbuf[i]);
|
||||
Showline(i + 2, 1, rbuf[i]);
|
||||
}
|
||||
} else {
|
||||
rpointer++;
|
||||
@ -136,7 +168,7 @@ void clrtoeol(void)
|
||||
*/
|
||||
void Chat(char *username, char *channel)
|
||||
{
|
||||
int curpos = 0, stop = FALSE, data;
|
||||
int curpos = 0, stop = FALSE, data, rc;
|
||||
unsigned char ch;
|
||||
char sbuf[81], resp[128], *cnt, *msg;
|
||||
static char buf[200];
|
||||
@ -173,7 +205,7 @@ void Chat(char *username, char *channel)
|
||||
clrtoeol();
|
||||
mvprintw(1, 2, "MBSE BBS Chat Server");
|
||||
|
||||
sprintf(buf, "CCON,2,%d,%s", mypid, CFG.sysop);
|
||||
sprintf(buf, "CCON,3,%d,%s,0;", mypid, exitinfo.Name);
|
||||
Syslog('-', "> %s", buf);
|
||||
if (socket_send(buf) == 0) {
|
||||
strcpy(buf, socket_receive());
|
||||
@ -186,8 +218,8 @@ void Chat(char *username, char *channel)
|
||||
mvprintw(4, 1, msg);
|
||||
sleep(2);
|
||||
Pause();
|
||||
return;
|
||||
chat_with_sysop = FALSE;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -201,6 +233,19 @@ void Chat(char *username, char *channel)
|
||||
memset(&sbuf, 0, sizeof(sbuf));
|
||||
memset(&rbuf, 0, sizeof(rbuf));
|
||||
|
||||
/*
|
||||
* If username and channelname are given, send the /nick and /join
|
||||
* commands to the chatserver.
|
||||
*/
|
||||
if (username && channel) {
|
||||
sprintf(buf, "CPUT:2,%d,/nick %s;", mypid, username);
|
||||
if (socket_send(buf) == 0)
|
||||
strcpy(buf, socket_receive());
|
||||
sprintf(buf, "CPUT:2,%d,/join %s;", mypid, channel);
|
||||
if (socket_send(buf) == 0)
|
||||
strcpy(buf, socket_receive());
|
||||
}
|
||||
|
||||
Syslog('-', "Start loop");
|
||||
chatting = TRUE;
|
||||
|
||||
@ -214,27 +259,35 @@ void Chat(char *username, char *channel)
|
||||
sprintf(buf, "CGET:1,%d;", mypid);
|
||||
if (socket_send(buf) == 0) {
|
||||
strcpy(buf, socket_receive());
|
||||
if (strncmp(buf, "100:1,", 6) == 0) {
|
||||
if (strncmp(buf, "100:2,", 6) == 0) {
|
||||
Syslog('-', "> CGET:1,%d;", mypid);
|
||||
Syslog('-', "< %s", buf);
|
||||
strncpy(resp, strtok(buf, ":"), 10); /* Should be 100 */
|
||||
strncpy(resp, strtok(NULL, ","), 5); /* Should be 1 */
|
||||
strncpy(resp, strtok(NULL, ","), 5); /* Should be 2 */
|
||||
strncpy(resp, strtok(NULL, ","), 5); /* 1= fatal, chat ended */
|
||||
rc = atoi(resp);
|
||||
strncpy(resp, strtok(NULL, "\0"), 80); /* The message */
|
||||
resp[strlen(resp)-1] = '\0';
|
||||
DispMsg(resp);
|
||||
if (rc == 1) {
|
||||
Syslog('+', "Chat server error: %s", resp);
|
||||
stop = TRUE;
|
||||
data = FALSE;
|
||||
}
|
||||
} else {
|
||||
data = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (stop)
|
||||
break;
|
||||
|
||||
/*
|
||||
* Check for a pressed key, if so then process it
|
||||
*/
|
||||
ch = testkey(exitinfo.iScreenLen -1, curpos + 2);
|
||||
if (ch == '@') {
|
||||
break;
|
||||
} else if (isprint(ch)) {
|
||||
if (isprint(ch)) {
|
||||
if (curpos < 77) {
|
||||
putchar(ch);
|
||||
fflush(stdout);
|
||||
@ -253,19 +306,23 @@ void Chat(char *username, char *channel)
|
||||
putchar(7);
|
||||
}
|
||||
} else if ((ch == '\r') && curpos) {
|
||||
if (strncasecmp(sbuf, "/exit", 5) == 0)
|
||||
stop = TRUE;
|
||||
sprintf(buf, "CPUT:2,%d,%s;", mypid, sbuf);
|
||||
Syslog('-', "> %s", buf);
|
||||
if (socket_send(buf) == 0) {
|
||||
strcpy(buf, socket_receive());
|
||||
Syslog('-', "< %s", buf);
|
||||
if (strncmp(buf, "100:1,", 6) == 0) {
|
||||
if (strncmp(buf, "100:2,", 6) == 0) {
|
||||
strncpy(resp, strtok(buf, ":"), 10); /* Should be 100 */
|
||||
strncpy(resp, strtok(NULL, ","), 5); /* Should be 1 */
|
||||
strncpy(resp, strtok(NULL, ","), 5); /* Should be 2 */
|
||||
strncpy(resp, strtok(NULL, ","), 5); /* 1= fatal, chat ended */
|
||||
rc = atoi(resp);
|
||||
strncpy(resp, strtok(NULL, "\0"), 80); /* The message */
|
||||
resp[strlen(resp)-1] = '\0';
|
||||
DispMsg(resp);
|
||||
if (rc == 1) {
|
||||
Syslog('+', "Chat server error: %s", resp);
|
||||
stop = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
curpos = 0;
|
||||
@ -286,14 +343,20 @@ void Chat(char *username, char *channel)
|
||||
sprintf(buf, "CGET:1,%d;", mypid);
|
||||
if (socket_send(buf) == 0) {
|
||||
strcpy(buf, socket_receive());
|
||||
if (strncmp(buf, "100:1,", 6) == 0) {
|
||||
if (strncmp(buf, "100:2,", 6) == 0) {
|
||||
Syslog('-', "> CGET:1,%d;", mypid);
|
||||
Syslog('-', "< %s", buf);
|
||||
strncpy(resp, strtok(buf, ":"), 10); /* Should be 100 */
|
||||
strncpy(resp, strtok(NULL, ","), 5); /* Should be 1 */
|
||||
strncpy(resp, strtok(NULL, ","), 5); /* Should be 2 */
|
||||
strncpy(resp, strtok(NULL, ","), 5); /* 1= fatal error */
|
||||
rc = atoi(resp);
|
||||
strncpy(resp, strtok(NULL, "\0"), 80); /* The message */
|
||||
resp[strlen(resp)-1] = '\0';
|
||||
DispMsg(resp);
|
||||
if (rc == 1) {
|
||||
Syslog('+', "Chat server error: %s", resp);
|
||||
data = FALSE; /* Even if there is more, prevent a loop */
|
||||
}
|
||||
} else {
|
||||
data = FALSE;
|
||||
}
|
||||
@ -317,7 +380,7 @@ void Chat(char *username, char *channel)
|
||||
/*
|
||||
* Close server connection
|
||||
*/
|
||||
sprintf(buf, "CCLO,1,%d", mypid);
|
||||
sprintf(buf, "CCLO,1,%d;", mypid);
|
||||
Syslog('-', "> %s", buf);
|
||||
if (socket_send(buf) == 0) {
|
||||
strcpy(buf, socket_receive());
|
||||
|
@ -198,7 +198,7 @@ void Page_Sysop(char *String)
|
||||
/*
|
||||
* First cancel page request
|
||||
*/
|
||||
sprintf(buf, "CCAN:1,%d", mypid);
|
||||
sprintf(buf, "CCAN:1,%d;", mypid);
|
||||
socket_send(buf);
|
||||
socket_receive();
|
||||
Syslog('+', "Sysop responded to paging request");
|
||||
@ -212,7 +212,7 @@ void Page_Sysop(char *String)
|
||||
/*
|
||||
* Cancel page request
|
||||
*/
|
||||
sprintf(buf, "CCAN:1,%d", mypid);
|
||||
sprintf(buf, "CCAN:1,%d;", mypid);
|
||||
socket_send(buf);
|
||||
strcpy(buf, socket_receive());
|
||||
}
|
||||
|
@ -82,11 +82,10 @@ void Check_PM(void)
|
||||
|
||||
|
||||
/*
|
||||
* This is the users onlinetime check. Must be REWRITTEN!!
|
||||
* This is the users onlinetime check.
|
||||
*/
|
||||
void TimeCheck(void)
|
||||
{
|
||||
char temp[81];
|
||||
time_t Now;
|
||||
int Elapsed;
|
||||
|
||||
@ -115,7 +114,7 @@ void TimeCheck(void)
|
||||
}
|
||||
}
|
||||
|
||||
if(exitinfo.iTimeLeft <= 0) {
|
||||
if (exitinfo.iTimeLeft <= 0) {
|
||||
printf("\n%s\n", (char *) Language(130));
|
||||
sleep(3);
|
||||
Syslog('!', "Users time limit exceeded ... user disconnected!");
|
||||
|
@ -90,6 +90,7 @@ void fill_portlist(pp_list **fdp, pp_list *new)
|
||||
strncpy(tmp->tty, new->tty, 6);
|
||||
tmp->mflags = new->mflags;
|
||||
tmp->dflags = new->dflags;
|
||||
tmp->locktime = 0;
|
||||
|
||||
if (*fdp == NULL) {
|
||||
*fdp = tmp;
|
||||
|
@ -53,6 +53,7 @@ typedef struct _ch_user_rec {
|
||||
int pointer; /* Message pointer */
|
||||
unsigned chatting : 1; /* Is chatting in a channel */
|
||||
unsigned chanop : 1; /* Is a chanop */
|
||||
unsigned sysop : 1; /* User is sysop in channel #sysop */
|
||||
} _chat_users;
|
||||
|
||||
|
||||
@ -118,16 +119,30 @@ void chat_msg(int, char *, char *);
|
||||
|
||||
void chat_dump(void)
|
||||
{
|
||||
int i;
|
||||
int i, first;
|
||||
|
||||
first = TRUE;
|
||||
for (i = 0; i < MAXCLIENT; i++)
|
||||
if (chat_users[i].pid)
|
||||
Syslog('u', "%5d %-36s %2d %s", chat_users[i].pid, chat_users[i].name, chat_users[i].channel,
|
||||
chat_users[i].chatting?"True":"False");
|
||||
if (chat_users[i].pid) {
|
||||
if (first) {
|
||||
Syslog('u', " pid username ch chats sysop");
|
||||
Syslog('u', "----- ------------------------------------ -- ----- -----");
|
||||
first = FALSE;
|
||||
}
|
||||
Syslog('u', "%5d %-36s %2d %s %s", chat_users[i].pid, chat_users[i].name, chat_users[i].channel,
|
||||
chat_users[i].chatting?"True ":"False", chat_users[i].sysop?"True ":"False");
|
||||
}
|
||||
first = TRUE;
|
||||
for (i = 0; i < MAXCHANNELS; i++)
|
||||
if (chat_channels[i].owner)
|
||||
if (chat_channels[i].owner) {
|
||||
if (first) {
|
||||
Syslog('c', "channel name owner cnt activ");
|
||||
Syslog('c', "-------------------- ----- --- -----");
|
||||
first = FALSE;
|
||||
}
|
||||
Syslog('c', "%-20s %5d %3d %s", chat_channels[i].name, chat_channels[i].owner, chat_channels[i].users,
|
||||
chat_channels[i].active?"True":"False");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -329,11 +344,16 @@ char *chat_connect(char *data)
|
||||
{
|
||||
char *pid, *usr;
|
||||
static char buf[200];
|
||||
int i, j, count = 0;
|
||||
int i, j, count = 0, sys = FALSE;
|
||||
|
||||
Syslog('-', "CCON:%s", data);
|
||||
memset(&buf, 0, sizeof(buf));
|
||||
|
||||
if (IsSema((char *)"upsalarm")) {
|
||||
sprintf(buf, "100:1,Power failure, running on UPS;");
|
||||
return buf;
|
||||
}
|
||||
|
||||
/*
|
||||
* Search free userslot
|
||||
*/
|
||||
@ -342,16 +362,18 @@ char *chat_connect(char *data)
|
||||
/*
|
||||
* Oke, found
|
||||
*/
|
||||
pid = strtok(data, ","); /* Should be 2 */
|
||||
pid = strtok(data, ","); /* Should be 3 */
|
||||
pid = strtok(NULL, ","); /* The pid */
|
||||
usr = strtok(NULL, ";"); /* Username */
|
||||
usr = strtok(NULL, ","); /* Username */
|
||||
sys = atoi(strtok(NULL, ";")); /* Sysop flag */
|
||||
chat_users[i].pid = atoi(pid);
|
||||
strncpy(chat_users[i].name, usr, 36);
|
||||
chat_users[i].connected = time(NULL);
|
||||
chat_users[i].pointer = buffer_head;
|
||||
chat_users[i].channel = -1;
|
||||
chat_users[i].sysop = sys;
|
||||
|
||||
Syslog('-', "Connected user %s (%s) with chatserver, slot %d", usr, pid, i);
|
||||
Syslog('-', "Connected user %s (%s) with chatserver, slot %d, sysop %s", usr, pid, i, sys ? "True":"False");
|
||||
|
||||
/*
|
||||
* Now put welcome message into the ringbuffer and report success.
|
||||
@ -411,6 +433,11 @@ char *chat_put(char *data)
|
||||
Syslog('-', "CPUT:%s", data);
|
||||
memset(&buf, 0, sizeof(buf));
|
||||
|
||||
if (IsSema((char *)"upsalarm")) {
|
||||
sprintf(buf, "100:2,1,Power alarm, running on UPS;");
|
||||
return buf;
|
||||
}
|
||||
|
||||
pid = strtok(data, ",");
|
||||
pid = strtok(NULL, ",");
|
||||
msg = strtok(NULL, "\0");
|
||||
@ -421,7 +448,7 @@ char *chat_put(char *data)
|
||||
/*
|
||||
* We are connected and known, first send the input back to ourself.
|
||||
*/
|
||||
system_msg(chat_users[i].pid, msg);
|
||||
// system_msg(chat_users[i].pid, msg);
|
||||
|
||||
if (msg[0] == '/') {
|
||||
/*
|
||||
@ -435,13 +462,9 @@ char *chat_put(char *data)
|
||||
(strncasecmp(msg, "/quit", 5) == 0) ||
|
||||
(strncasecmp(msg, "/bye", 4) == 0)) {
|
||||
part(chat_users[i].pid, (char *)"Quitting");
|
||||
/*
|
||||
* Just send messages, the client should later do a
|
||||
* real disconnect.
|
||||
*/
|
||||
sprintf(buf, "Goodbye");
|
||||
system_msg(chat_users[i].pid, buf);
|
||||
goto ack;
|
||||
goto hangup;
|
||||
}
|
||||
if (strncasecmp(msg, "/join", 5) == 0) {
|
||||
cmd = strtok(msg, " \0");
|
||||
@ -492,12 +515,16 @@ char *chat_put(char *data)
|
||||
}
|
||||
}
|
||||
Syslog('-', "Pid %s was not connected to chatserver");
|
||||
sprintf(buf, "100:1,ERROR - Not connected to server;");
|
||||
sprintf(buf, "100:2,1,ERROR - Not connected to server;");
|
||||
return buf;
|
||||
|
||||
ack:
|
||||
sprintf(buf, "100:0;");
|
||||
return buf;
|
||||
|
||||
hangup:
|
||||
sprintf(buf, "100:2,1,Disconnecting;");
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
@ -509,6 +536,12 @@ char *chat_get(char *data)
|
||||
int i;
|
||||
|
||||
// Syslog('-', "CGET:%s", data);
|
||||
|
||||
if (IsSema((char *)"upsalarm")) {
|
||||
sprintf(buf, "100:2,1,Power failure, running on UPS;");
|
||||
return buf;
|
||||
}
|
||||
|
||||
memset(&buf, 0, sizeof(buf));
|
||||
pid = strtok(data, ",");
|
||||
pid = strtok(NULL, ";");
|
||||
@ -524,7 +557,7 @@ char *chat_get(char *data)
|
||||
/*
|
||||
* Message is for us.
|
||||
*/
|
||||
sprintf(buf, "100:1,%s;", chat_messages[chat_users[i].pointer].message);
|
||||
sprintf(buf, "100:2,0,%s;", chat_messages[chat_users[i].pointer].message);
|
||||
Syslog('-', "%s", buf);
|
||||
return buf;
|
||||
}
|
||||
@ -533,7 +566,44 @@ char *chat_get(char *data)
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
sprintf(buf, "100:1,ERROR - Not connected to server;");
|
||||
sprintf(buf, "100:2,1,ERROR - Not connected to server;");
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Check for sysop present for forced chat
|
||||
*/
|
||||
char *chat_checksysop(char *data)
|
||||
{
|
||||
static char buf[20];
|
||||
char *pid;
|
||||
int i;
|
||||
|
||||
memset(&buf, 0, sizeof(buf));
|
||||
pid = strtok(data, ",");
|
||||
pid = strtok(NULL, ";");
|
||||
|
||||
if (reg_ispaging(pid)) {
|
||||
Syslog('-', "Check sysopchat for pid %s, user has paged", pid);
|
||||
|
||||
/*
|
||||
* Now check if sysop is present in the sysop channel
|
||||
*/
|
||||
for (i = 0; i < MAXCLIENT; i++) {
|
||||
if (atoi(pid) != chat_users[i].pid) {
|
||||
if (chat_users[i].chatting && chat_users[i].sysop) {
|
||||
Syslog('-', "Sending ACK on check");
|
||||
sprintf(buf, "100:1,1;");
|
||||
reg_sysoptalk(pid);
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sprintf(buf, "100:1,0;");
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
@ -9,5 +9,6 @@ char *chat_connect(char *);
|
||||
char *chat_close(char *);
|
||||
char *chat_put(char *);
|
||||
char *chat_get(char *);
|
||||
char *chat_checksysop(char *);
|
||||
|
||||
#endif
|
||||
|
@ -262,8 +262,8 @@ char *exe_cmd(char *in)
|
||||
}
|
||||
|
||||
/*
|
||||
* CSYS:1,1; Sysop available for chat (from mbmon)
|
||||
* CSYS:1,0; Sysop goes away (from mbmon)
|
||||
* CSYS:2,pid,1; Sysop available for chat (from mbmon)
|
||||
* CSYS:2,pid,0; Sysop goes away (from mbmon)
|
||||
* 100:0; Allways Ok.
|
||||
*/
|
||||
if (strncmp(cmd, "CSYS", 4) == 0) {
|
||||
@ -305,10 +305,21 @@ char *exe_cmd(char *in)
|
||||
return reg_checkpage(token);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check for sysop in chatmode for forced sysop chat
|
||||
*
|
||||
* CISC:1,pid;
|
||||
* 100:1,1; Yes (and drop into chatmode)
|
||||
* 100:1,0; No
|
||||
*/
|
||||
if (strncmp(cmd, "CISC", 4) == 0) {
|
||||
return chat_checksysop(token);
|
||||
}
|
||||
|
||||
/*
|
||||
* Connect to chatserver
|
||||
*
|
||||
* CCON:2,pid,username; Connect to chatserver with username
|
||||
* CCON:3,pid,username,n; Connect to chatserver with username, n=1 user is the sysop
|
||||
* 100:1,error; If error
|
||||
* 100:0; Ok
|
||||
*/
|
||||
@ -331,7 +342,8 @@ char *exe_cmd(char *in)
|
||||
* Put message on server
|
||||
*
|
||||
* CPUT:2,pid,message; Put message on server
|
||||
* 100:1,error; Error
|
||||
* 100:2,0,error; Error, not fatal and continue chat
|
||||
* 100:2,1,error; Error, fatal and disconnect
|
||||
* 100:0; Ok
|
||||
*/
|
||||
if (strncmp(cmd, "CPUT", 4) == 0) {
|
||||
@ -342,7 +354,8 @@ char *exe_cmd(char *in)
|
||||
* Get message from server
|
||||
*
|
||||
* CGET:1,pid; Get message from server
|
||||
* 100:1,message; If message present
|
||||
* 100:2,0,message; If message present
|
||||
* 100:2,1,error; Error and disconnect
|
||||
* 100:0; No message
|
||||
*/
|
||||
if (strncmp(cmd, "CGET", 4) == 0) {
|
||||
@ -524,6 +537,7 @@ char *exe_cmd(char *in)
|
||||
* If we got this far, there must be an error.
|
||||
*/
|
||||
stat_inc_serr();
|
||||
Syslog('!', "Comm systax error: \"%s:%s\"", cmd, printable(token, 0));
|
||||
return ebuf;
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,6 @@ int reg_newcon(char *data)
|
||||
reginfo[retval].started = time(NULL);
|
||||
reginfo[retval].lastcon = time(NULL);
|
||||
reginfo[retval].altime = 600;
|
||||
reginfo[retval].channel = -1; /* Default chat channel */
|
||||
|
||||
/*
|
||||
* Everyone says do not disturb, unless the flag
|
||||
@ -372,17 +371,6 @@ int reg_sysop(char *data)
|
||||
sysop_present = atoi(strtok(NULL, ";"));
|
||||
|
||||
if ((rec = reg_find(pid)) != -1) {
|
||||
if (sysop_present) {
|
||||
/*
|
||||
* Allthough the sysop is not really chatting, still put channel 0
|
||||
* into chatmode for the sysop's process.
|
||||
*/
|
||||
reginfo[rec].channel = 0;
|
||||
reginfo[rec].chatting = TRUE;
|
||||
} else {
|
||||
reginfo[rec].channel = -1;
|
||||
reginfo[rec].chatting = FALSE;
|
||||
}
|
||||
reginfo[rec].lastcon = time(NULL);
|
||||
}
|
||||
|
||||
@ -587,13 +575,11 @@ int reg_page(char *data)
|
||||
return 2;
|
||||
|
||||
/*
|
||||
* Check if another user is pagin the sysop or is already
|
||||
* chatting with the sysop, if so, mark sysop busy.
|
||||
* Check if another user is paging the sysop or has paged the sysop.
|
||||
* If so, mark sysop busy.
|
||||
*/
|
||||
for (i = 1; i < MAXCLIENT; i++) {
|
||||
if (reginfo[i].pid && (reginfo[i].pid != atoi(pid)) && (reginfo[i].channel == 0) && (reginfo[i].chatting))
|
||||
return 1;
|
||||
if (reginfo[i].pid && (reginfo[i].pid != atoi(pid)) && (reginfo[i].paging))
|
||||
if (reginfo[i].pid && (reginfo[i].pid != atoi(pid)) && (reginfo[i].paging || reginfo[i].haspaged))
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -604,7 +590,6 @@ int reg_page(char *data)
|
||||
* All seems well, accept the page
|
||||
*/
|
||||
reginfo[rec].paging = TRUE;
|
||||
reginfo[rec].channel = 0;
|
||||
strncpy(reginfo[rec].reason, reason, 80);
|
||||
reginfo[rec].lastcon = time(NULL);
|
||||
return 0;
|
||||
@ -623,7 +608,7 @@ int reg_cancel(char *data)
|
||||
cnt = strtok(data, ",");
|
||||
pid = strtok(NULL, ";");
|
||||
|
||||
Syslog('+', "reg_cancel: pid=%d", pid);
|
||||
Syslog('+', "reg_cancel: pid=%s", pid);
|
||||
|
||||
if ((rec = reg_find(pid)) == -1)
|
||||
return -1;
|
||||
@ -631,7 +616,6 @@ int reg_cancel(char *data)
|
||||
if (reginfo[rec].paging) {
|
||||
reginfo[rec].paging = FALSE;
|
||||
reginfo[rec].haspaged = TRUE;
|
||||
reginfo[rec].channel = -1;
|
||||
}
|
||||
reginfo[rec].lastcon = time(NULL);
|
||||
return 0;
|
||||
@ -663,3 +647,34 @@ char *reg_checkpage(char *data)
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Check if this user has paged or is paging
|
||||
*/
|
||||
int reg_ispaging(char *pid)
|
||||
{
|
||||
int rec;
|
||||
|
||||
if ((rec = reg_find(pid)) == -1)
|
||||
return FALSE;
|
||||
|
||||
return (reginfo[rec].paging || reginfo[rec].haspaged);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Mark that this user is now talking to the sysop
|
||||
*/
|
||||
void reg_sysoptalk(char *pid)
|
||||
{
|
||||
int rec;
|
||||
|
||||
if ((rec = reg_find(pid)) == -1)
|
||||
return;
|
||||
|
||||
reginfo[rec].paging = FALSE;
|
||||
reginfo[rec].haspaged = FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
@ -23,20 +23,15 @@ typedef struct _reg_info {
|
||||
time_t lastcon; /* Last connection */
|
||||
int altime; /* Alarm time */
|
||||
unsigned silent : 1; /* Do not disturb */
|
||||
unsigned chatting : 1; /* User is chatting */
|
||||
unsigned ismsg : 1; /* Message waiting */
|
||||
unsigned istcp : 1; /* Is a TCP/IP session */
|
||||
unsigned paging : 1; /* Is paging sysop */
|
||||
unsigned haspaged : 1; /* Has paged sysop */
|
||||
unsigned moderator : 1; /* Is channel moderator */
|
||||
int channel; /* Chat channel */
|
||||
int ptr_in; /* Input buffer pointer */
|
||||
int ptr_out; /* Output buffer ptr */
|
||||
char fname[RB][36]; /* Message from user */
|
||||
char msg[RB][81]; /* The message itself */
|
||||
char reason[81]; /* Chat reason */
|
||||
char chname[21]; /* Short channel name */
|
||||
char chsubj[61]; /* Channel subject */
|
||||
} reg_info;
|
||||
|
||||
|
||||
@ -59,6 +54,8 @@ int reg_sysop(char *); /* Registrate sysop presence */
|
||||
int reg_page(char *); /* Page sysop for chat */
|
||||
int reg_cancel(char *); /* Cancel sysop page */
|
||||
char *reg_checkpage(char *); /* Check paging status */
|
||||
int reg_ispaging(char *); /* Check if user with pid paged */
|
||||
void reg_sysoptalk(char *); /* Is now talking to the sysop */
|
||||
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user