Updates for chat from the bbs
This commit is contained in:
parent
c1f5ccef3c
commit
58ea13aff8
@ -12,6 +12,10 @@ v0.37.2 23-Feb-2003.
|
||||
general:
|
||||
System prepared for setting the official FTSC product code,
|
||||
this will be 0x11FF. The code is not yet activated.
|
||||
Removed external (sysop) chat, chat paging times and other
|
||||
chat stuff that is of no use anymore. The sysop shows his
|
||||
presence by running mbmon. The mbchat program is obsolete.
|
||||
Menu item 22 is added, this is user chat session.
|
||||
|
||||
common.a:
|
||||
New function to get the real case of a filename.
|
||||
@ -52,6 +56,9 @@ v0.37.2 23-Feb-2003.
|
||||
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.
|
||||
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.
|
||||
|
||||
mbmon:
|
||||
Reports sysop available or left the system when mbmon starts
|
||||
|
@ -59,8 +59,7 @@ H_MISC = misc/dropfile.html misc/fileid.html misc/index.htm \
|
||||
misc/ftpserver.html misc/ipmailer.html misc/outbound.html \
|
||||
misc/usleep.html misc/webserver.html
|
||||
|
||||
H_PROGS = programs/mbchat.html \
|
||||
programs/mbfido.html programs/mbmon.html \
|
||||
H_PROGS = programs/mbfido.html programs/mbmon.html \
|
||||
programs/mbtoberep.html programs/mblogin.html \
|
||||
programs/index.htm programs/mbcico.html \
|
||||
programs/mbfile.html programs/mbmsg.html \
|
||||
|
@ -13,10 +13,10 @@
|
||||
<BODY>
|
||||
<BLOCKQUOTE>
|
||||
<center><img SRC="images/mbse.jpg" BORDER=0></center>
|
||||
<div align=center><h1>MBSE BBS System Guide v0.37.01</h1></div>
|
||||
<div align=center><h1>MBSE BBS System Guide v0.37.02</h1></div>
|
||||
<HR>
|
||||
|
||||
<div align=right><h5>Last update 02-Mar-2003</h5></div>
|
||||
<div align=right><h5>Last update 23-Mar-2003</h5></div>
|
||||
<P>
|
||||
|
||||
|
||||
@ -92,7 +92,6 @@
|
||||
<ol>
|
||||
<li><a href="programs/mbaff.html">mbaff, Announce newfiles and filefind</a></li>
|
||||
<li><a href="programs/mball.html">mball, Allfiles and newfiles list creator</a></li>
|
||||
<li><a href="programs/mbchat.html">mbchat, Sysop to user chat utility</a></li>
|
||||
<li><a href="programs/mbcico.html">mbcico, The Fidonet mailer ala ifcico</a></li>
|
||||
<li><a href="programs/mbdiff.html">mbdiff, Nodelist difference processor</a></li>
|
||||
<li><a href="programs/mbfido.html">mbfido, Fidonet mail and files procesor</a></li>
|
||||
|
@ -12,7 +12,7 @@
|
||||
</HEAD>
|
||||
<BODY>
|
||||
<BLOCKQUOTE>
|
||||
<DIV align=right><h5>Last update 23-Feb-2003</h5></DIV>
|
||||
<DIV align=right><h5>Last update 01-Apr-2003</h5></DIV>
|
||||
|
||||
<DIV align=center><h1>MBSE BBS Global Menus</h1></DIV>
|
||||
<hr>
|
||||
@ -160,6 +160,13 @@
|
||||
even if the display line is empty. In that case an empty line is displayed.<br>
|
||||
<strong>Optional data:</strong> None.<br>
|
||||
<P>
|
||||
|
||||
<LI value="22"><strong>Chat session</strong> This connects the user to the
|
||||
chatserver. The user is connected with his unix name as default name. The chat
|
||||
server is a very simple IRC look alike server.<br>
|
||||
<strong>Optional data:</strong> None yet, maybe the channel later.<br>
|
||||
<P>
|
||||
|
||||
</OL>
|
||||
|
||||
<HR>
|
||||
|
@ -12,16 +12,13 @@
|
||||
</HEAD>
|
||||
<BODY>
|
||||
<BLOCKQUOTE>
|
||||
<h5>Last update 10-May-2002</h5>
|
||||
<P> <P>
|
||||
|
||||
<h1>MBSE BBS Programs.</h1>
|
||||
<div align=right><h5>Last update 23-Mar-2003</h5></div>
|
||||
<div align=center><h1>MBSE BBS Programs.</h1></div>
|
||||
|
||||
|
||||
<ol>
|
||||
<li><A HREF="mbaff.html">mbaff, Announce newfiles and filefind</A>
|
||||
<li><A HREF="mball.html">mball, Allfiles and newfiles list creator</A>
|
||||
<li><A HREF="mbchat.html">mbchat, Sysop to user chat utility</A>
|
||||
<li><A HREF="mbcico.html">mbcico, The Fidonet mailer ala ifcico</A>
|
||||
<li><A HREF="mbdiff.html">mbdiff, Nodelist difference processor</A>
|
||||
<li><A HREF="mbfido.html">mbfido, Fidonet mail and files procesor</A>
|
||||
|
@ -12,7 +12,7 @@
|
||||
</HEAD>
|
||||
<BODY>
|
||||
<BLOCKQUOTE>
|
||||
<div align="right"><h5>Last update 02-Feb-2003</h5></div>
|
||||
<div align="right"><h5>Last update 01-Apr-2003</h5></div>
|
||||
|
||||
<div align="center"><H1>MBSE BBS Setup - Global Setup</H1></div>
|
||||
<P>
|
||||
@ -159,43 +159,22 @@ menu.
|
||||
<IMG SRC="../images/mbsetup1.6.S.gif" width="589" height="343">
|
||||
<P>
|
||||
|
||||
<h3>1.9. Safe cracker door.</h3>
|
||||
<h3>1.9. Sysop paging</h3>
|
||||
<p>
|
||||
This is a door I found in RapidBBS, it is a simple number guessing game.
|
||||
For sysop chat a protocol is used to communicate with the mbtask daemon which
|
||||
has a very simple IRC like chatserver. For sysop/user chat a forced channel
|
||||
with the name #sysop is used.
|
||||
<pre>
|
||||
<strong>Digit 1 </strong>The first digit to guess
|
||||
<strong>Digit 2 </strong>The second digit to guess
|
||||
<strong>Digit 3 </strong>The third digit to guess
|
||||
<strong>Max trys </strong>The maximum number of trys per day
|
||||
<strong>Max numb </strong>The highest number to guess
|
||||
<strong>Num gen </strong>Automatic number generation
|
||||
<strong>Prize </strong>The prize to win
|
||||
<strong>Welcome </strong>The welcome file to display
|
||||
<strong>Opened </strong>The file to display to the winner
|
||||
</pre>
|
||||
<p>
|
||||
|
||||
<h3>1.10. Sysop paging</h3>
|
||||
<p>
|
||||
For sysop chat we use a program that will connect to the users tty. This is
|
||||
not a nice solution because it will not work over a network, but at least
|
||||
it works.
|
||||
<pre>
|
||||
<strong>Ext. chat </strong>External chat program, not in use!
|
||||
<strong>Chat device </strong>The device where the sysop is called (beeped)
|
||||
<strong>Call script </strong>For future use
|
||||
<strong>Page length </strong>The length of a page in seconds
|
||||
<strong>Page times </strong>Maximum number of times a user may page the sysop
|
||||
<strong>Sysop area </strong>Message from user to Sysop area number
|
||||
<strong>Ask reason </strong>Ask reason for chat, this will be logged
|
||||
<strong>Use Extern </strong>Use external chat
|
||||
<strong>Log Chat </strong>Log the chat conversation
|
||||
<strong>Prompt Chk. </strong>Check at menu prompts for Sysop breaking in
|
||||
<strong>Freeze Time </strong>Freeze users time during chat
|
||||
<strong>Sunday..Saturday </strong>The times the Sysop is normal available
|
||||
</pre><p>
|
||||
|
||||
<h3>1.11. Fileecho Processing.</h3>
|
||||
<h3>1.10. Fileecho Processing.</h3>
|
||||
<p>
|
||||
A note, when you change the number of Systems or Groups, the databases affected
|
||||
will be updated automatic.
|
||||
@ -221,7 +200,7 @@ the file /opt/mbse/english/macro/filemgr.help to reflect the new settings.
|
||||
Default all these switches are set to Yes.
|
||||
|
||||
<p>
|
||||
<h3>1.12. Edit Fidonet mail and echomail processing.</h3>
|
||||
<h3>1.11. Edit Fidonet mail and echomail processing.</h3>
|
||||
<p>
|
||||
Note that the first 2 mailboards must also exist in the normal mail areas if
|
||||
you want to see what is in them. Here they are defined for quick access of the
|
||||
@ -278,10 +257,10 @@ if they are larger then 32 KBytes. Splitting is used for newfiles reports
|
||||
and gated news articles to Fidonet.
|
||||
<P>
|
||||
|
||||
<h3>1.13. Edit Internet mail and news processing.</h3>
|
||||
<h3>1.12. Edit Internet mail and news processing.</h3>
|
||||
<p>
|
||||
Email and news is setup here. There are three possible configurations which you
|
||||
can set with 1.15.11:
|
||||
can set with 1.12.11:
|
||||
<ul>
|
||||
<li><strong>No internet</strong>. If you don't have any connection to the internet
|
||||
use this setting. Email will come from the default Fidonet UUCP gate and will be send out
|
||||
@ -347,7 +326,7 @@ In UUCP mode the NNTP entries are replaced by:
|
||||
|
||||
|
||||
<P>
|
||||
<h3>1.14. Allfiles and Newfiles lists.</h3>
|
||||
<h3>1.13. Allfiles and Newfiles lists.</h3>
|
||||
<p>
|
||||
These are the settings that affect the generation of newfiles and allfiles reports.
|
||||
<pre>
|
||||
@ -356,7 +335,7 @@ These are the settings that affect the generation of newfiles and allfiles repor
|
||||
<strong>Groups </strong>The number of newfile groups the newfiles database can hold
|
||||
</pre><p>
|
||||
|
||||
<h3>1.15. Mailer Setup.</h3>
|
||||
<h3>1.14. Mailer Setup.</h3>
|
||||
<p>
|
||||
Note that you can't disable FTS-0001 sessions as that is a mandatory session
|
||||
protocol in Fidonet. There are 40 phonenumber translations present, this is for
|
||||
@ -385,7 +364,7 @@ XX,CM and TCP/IP systems (internet) should use the XX,CM,IBN,IFC flags.
|
||||
<strong>Max. MBytes </strong>Maximum MBytes to request, 0 is unlimited
|
||||
</pre>
|
||||
|
||||
<h3>1.16. FTPD Settings.</h3>
|
||||
<h3>1.15. FTPD Settings.</h3>
|
||||
<p>
|
||||
A new program is <strong>mbftpd</strong>. This is a replacement for the normal
|
||||
ftp server for Linux with special futures for MBSE BBS. This is not working
|
||||
@ -411,7 +390,7 @@ yet and is not included in the distribution. Setting it up is adviced.
|
||||
<strong>User mbse </strong>If user <strong>mbse</strong> is allowed. Dangerous!
|
||||
</pre>
|
||||
|
||||
<h3>1.17. Edit HTML pages setup.</h3>
|
||||
<h3>1.16. Edit HTML pages setup.</h3>
|
||||
<p>
|
||||
Here you setup the HTML pages that can be created with the <strong>
|
||||
mbfile web</strong> command. These are HTML pages of your download
|
||||
@ -444,7 +423,7 @@ there is no user authentication yet available.
|
||||
</pre>
|
||||
<P>
|
||||
|
||||
<h3>1.18. Manager flag Descriptions.</h3>
|
||||
<h3>1.17. Manager flag Descriptions.</h3>
|
||||
<p>
|
||||
In this menu you can give the 32 area-/filemgr flags a meaningfull description.
|
||||
<p>
|
||||
|
@ -633,15 +633,15 @@ struct sysconfig {
|
||||
int iMaxPageTimes; /* Max Pages per call */
|
||||
unsigned iAskReason : 1; /* Ask Reason */
|
||||
int iSysopArea; /* Msg Area if Sysop not in */
|
||||
unsigned iExternalChat : 1; /* Use External Chat */
|
||||
char sExternalChat[50]; /* External Chat Program */
|
||||
unsigned iAutoLog : 1; /* Log Chats ? */
|
||||
char sChatDevice[20]; /* Chat Device */
|
||||
unsigned xxExternalChat : 1;
|
||||
char xExternalChat[50];
|
||||
unsigned iAutoLog : 1; /* Log Chats */
|
||||
char xChatDevice[20];
|
||||
unsigned iChatPromptChk; /* Check for chat at prompt */
|
||||
unsigned iStopChatTime; /* Stop time during chat */
|
||||
char cStartTime[7][6]; /* Starting Times */
|
||||
char cStopTime[7][6]; /* Stop Times */
|
||||
char sCallScript[51]; /* Sysop External Call scr. */
|
||||
char xStartTime[7][6];
|
||||
char xStopTime[7][6];
|
||||
char xCallScript[51];
|
||||
|
||||
/* Mail Options */
|
||||
char xquotestr[11]; /* Quote String */
|
||||
|
@ -155,7 +155,7 @@ menu.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/mbse.h ../lib/structs
|
||||
pop3.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/mbse.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/mbinet.h ../lib/msgtext.h ../lib/msg.h msgutil.h pop3.h
|
||||
lastcallers.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/mbse.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/clcomm.h ../lib/common.h input.h language.h lastcallers.h
|
||||
timeout.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/mbse.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/msg.h timeout.h funcs.h bye.h filesub.h language.h
|
||||
chat.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/mbse.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h chat.h funcs.h input.h language.h misc.h whoson.h
|
||||
chat.o: ../config.h ../lib/libs.h ../lib/ansi.h ../lib/memwatch.h ../lib/mbse.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/mberrors.h chat.h funcs.h input.h language.h misc.h whoson.h
|
||||
file.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/mbse.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h filesub.h file.h funcs.h input.h language.h misc.h timeout.h exitinfo.h whoson.h change.h
|
||||
mbstat.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h ../lib/mberrors.h mbstat.h
|
||||
misc.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/mbse.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/clcomm.h ../lib/common.h ../lib/mberrors.h funcs.h input.h language.h misc.h timeout.h exitinfo.h
|
||||
|
390
mbsebbs/chat.c
390
mbsebbs/chat.c
@ -4,7 +4,7 @@
|
||||
* Purpose ...............: Sysop to user chat utility
|
||||
*
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1997-2002
|
||||
* Copyright (C) 1997-2003
|
||||
*
|
||||
* Michiel Broek FIDO: 2:280/2802
|
||||
* Beekmansbos 10
|
||||
@ -30,6 +30,7 @@
|
||||
|
||||
#include "../config.h"
|
||||
#include "../lib/libs.h"
|
||||
#include "../lib/ansi.h"
|
||||
#include "../lib/memwatch.h"
|
||||
#include "../lib/mbse.h"
|
||||
#include "../lib/structs.h"
|
||||
@ -37,6 +38,7 @@
|
||||
#include "../lib/records.h"
|
||||
#include "../lib/common.h"
|
||||
#include "../lib/clcomm.h"
|
||||
#include "../lib/mberrors.h"
|
||||
#include "chat.h"
|
||||
#include "funcs.h"
|
||||
#include "input.h"
|
||||
@ -45,150 +47,286 @@
|
||||
#include "whoson.h"
|
||||
|
||||
|
||||
|
||||
#define DEVICE "/tmp/chatdev"
|
||||
int chat_with_sysop = FALSE; /* Global sysop chat flag */
|
||||
int chatting = FALSE; /* Global chatting flag */
|
||||
char rbuf[50][80]; /* Chat receive buffer */ /* FIXME: must be a dynamic buffer */
|
||||
int rpointer = 0; /* Chat receive pointer */
|
||||
int rsize = 5; /* Chat receive size */
|
||||
extern pid_t mypid;
|
||||
|
||||
|
||||
void Chat(int channel)
|
||||
void DispMsg(char *);
|
||||
void clrtoeol(void);
|
||||
unsigned char testkey(int, int);
|
||||
|
||||
|
||||
|
||||
unsigned char testkey(int y, int x)
|
||||
{
|
||||
FILE *pGetDev, *pLog, *pBusy, *pChat;
|
||||
int ch;
|
||||
int iLetter = 0;
|
||||
char sDevice[20];
|
||||
char *sLog = NULL;
|
||||
char temp[81] = "";
|
||||
int rc;
|
||||
unsigned char ch = 0;
|
||||
|
||||
if (CFG.iAutoLog)
|
||||
sLog = calloc(56, sizeof(char));
|
||||
|
||||
WhosDoingWhat(SYSOPCHAT);
|
||||
|
||||
clear();
|
||||
|
||||
if((pGetDev = fopen(DEVICE,"r")) == NULL)
|
||||
WriteError("Can't open file:", DEVICE);
|
||||
else {
|
||||
fscanf(pGetDev, "%19s", sDevice);
|
||||
fclose(pGetDev);
|
||||
}
|
||||
|
||||
if(( pChat = fopen(sDevice,"w")) == NULL)
|
||||
perror("Error");
|
||||
|
||||
/*
|
||||
* Check to see if it must load a external chat program
|
||||
* Check the length of the chat program is greater than Zero
|
||||
* Check if user has execute permisson on the chat program
|
||||
*/
|
||||
if(!CFG.iExternalChat || (strlen(CFG.sExternalChat) < 1) || \
|
||||
(access(CFG.sExternalChat, X_OK) != 0)) {
|
||||
if ((pBusy = fopen("/tmp/.BusyChatting", "w")) == NULL)
|
||||
WriteError("Unable to open BusyChatting file", "/tmp/.BusyChatting");
|
||||
else {
|
||||
fprintf(pBusy, "%s", pTTY);
|
||||
fclose(pBusy);
|
||||
}
|
||||
|
||||
sprintf(temp, "/tmp/.chat.%s", pTTY);
|
||||
if(( pBusy = fopen(temp, "w")) == NULL)
|
||||
WriteError("Unable to open chat.tty file", temp);
|
||||
else
|
||||
fclose(pBusy);
|
||||
|
||||
colour(10, 0);
|
||||
printf("%s\n\r", (char *) Language(59));
|
||||
Nopper();
|
||||
locate(y, x);
|
||||
fflush(stdout);
|
||||
|
||||
if ((ttyfd = open("/dev/tty", O_RDWR|O_NONBLOCK)) < 0) {
|
||||
perror("open /dev/tty");
|
||||
exit(MBERR_TTYIO_ERROR);
|
||||
}
|
||||
Setraw();
|
||||
|
||||
sleep(2);
|
||||
|
||||
Syslog('+', "Sysop chat started");
|
||||
|
||||
fprintf(pChat, "%s is ready ... \n\r",exitinfo.sUserName);
|
||||
|
||||
while (1) {
|
||||
ch = getc(stdin);
|
||||
ch &= '\377';
|
||||
/* The next statement doesn't work, the chat will start again */
|
||||
if (ch == '\007') {
|
||||
Syslog('+', "Sysop chat ended - User exited chat");
|
||||
unlink("/tmp/chatdev");
|
||||
sprintf(temp, "/tmp/.chat.%s", pTTY);
|
||||
unlink(temp);
|
||||
unlink("/tmp/.BusyChatting");
|
||||
rc = Waitchar(&ch, 50);
|
||||
if (rc == 1) {
|
||||
if (ch == KEY_ESCAPE)
|
||||
rc = Escapechar(&ch);
|
||||
}
|
||||
Unsetraw();
|
||||
break;
|
||||
}
|
||||
putchar(ch);
|
||||
putc(ch, pChat);
|
||||
|
||||
if(CFG.iAutoLog) {
|
||||
if(ch != '\b')
|
||||
iLetter++; /* Count the letters user presses for logging */
|
||||
sprintf(sLog, "%s%c", sLog, ch);
|
||||
close(ttyfd);
|
||||
if (rc == 1)
|
||||
return ch;
|
||||
else
|
||||
return '\0';
|
||||
}
|
||||
|
||||
if (ch == '\n') {
|
||||
ch = '\r';
|
||||
putchar(ch);
|
||||
putc(ch, pChat);
|
||||
}
|
||||
|
||||
if (ch == '\r') {
|
||||
ch = '\n';
|
||||
putchar(ch);
|
||||
putc(ch, pChat);
|
||||
}
|
||||
|
||||
if (ch == '\b') {
|
||||
ch = ' ';
|
||||
putchar(ch);
|
||||
putc(ch, pChat);
|
||||
ch = '\b';
|
||||
putchar(ch);
|
||||
putc(ch, pChat);
|
||||
/*
|
||||
* Display received chat message in the chat window.
|
||||
*/
|
||||
void DispMsg(char *msg)
|
||||
{
|
||||
int i;
|
||||
|
||||
if(CFG.iAutoLog)
|
||||
sLog[--iLetter] = '\0';
|
||||
strncpy(rbuf[rpointer], msg, 80);
|
||||
mvprintw(2 + rpointer, 1, rbuf[rpointer]);
|
||||
if (rpointer == rsize) {
|
||||
/*
|
||||
* Scroll buffer
|
||||
*/
|
||||
for (i = 0; i <= rsize; i++) {
|
||||
locate(i + 2, 1);
|
||||
clrtoeol();
|
||||
sprintf(rbuf[i], "%s", rbuf[i+1]);
|
||||
mvprintw(i + 2, 1, rbuf[i]);
|
||||
}
|
||||
|
||||
/* Check if log chat is on and if so log chat to disk */
|
||||
if(CFG.iAutoLog) {
|
||||
if(iLetter >= 55 || ch == '\n') {
|
||||
iLetter = 0;
|
||||
sprintf(temp, "%s/etc/%s", getenv("MBSE_ROOT"), CFG.chat_log);
|
||||
if(( pLog = fopen(temp, "a+")) != NULL) {
|
||||
fflush(pLog);
|
||||
fprintf(pLog, "%s [%s]: %s\n", exitinfo.sUserName, (char *) GetLocalHM(), sLog);
|
||||
fclose(pLog);
|
||||
strcpy(sLog, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(access("/tmp/chatdev", R_OK) != 0) {
|
||||
colour(10, 0);
|
||||
printf("\n\n\n%s\n\n\r", (char *) Language(60));
|
||||
Syslog('+', "Sysop chat ended");
|
||||
sprintf(temp, "/tmp/.chat.%s", pTTY);
|
||||
unlink(temp);
|
||||
unlink("/tmp/.BusyChatting");
|
||||
Unsetraw();
|
||||
Pause();
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* End of ExternalChat Check */
|
||||
} else {
|
||||
system(CFG.sExternalChat);
|
||||
printf("\n\n");
|
||||
rpointer++;
|
||||
}
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Clear to End Of Line
|
||||
*/
|
||||
void clrtoeol(void)
|
||||
{
|
||||
fprintf(stdout, ANSI_CLREOL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Chat, if the parameters are not NULL, a connection with the named
|
||||
* channel is made with the give username which will be forced to the
|
||||
* used nick name. This mode is used for forced sysop chat.
|
||||
* If the parameters are NULL, then it's up to the user what happens.
|
||||
*/
|
||||
void Chat(char *username, char *channel)
|
||||
{
|
||||
int curpos = 0, stop = FALSE, data;
|
||||
unsigned char ch;
|
||||
char sbuf[81], resp[128], *cnt, *msg;
|
||||
static char buf[200];
|
||||
|
||||
WhosDoingWhat(SYSOPCHAT);
|
||||
clear();
|
||||
|
||||
rsize = exitinfo.iScreenLen - 5;
|
||||
rpointer = 0;
|
||||
|
||||
if (username && channel) {
|
||||
colour(LIGHTGREEN, BLACK);
|
||||
/* *** Sysop is starting chat *** */
|
||||
printf("\007%s\n\r", (char *) Language(59));
|
||||
fflush(stdout);
|
||||
sleep(1);
|
||||
printf("\007");
|
||||
fflush(stdout);
|
||||
sleep(1);
|
||||
printf("\007");
|
||||
fflush(stdout);
|
||||
Syslog('+', "Sysop chat started");
|
||||
chat_with_sysop = TRUE;
|
||||
} else {
|
||||
Syslog('+', "User started chatting");
|
||||
}
|
||||
|
||||
/*
|
||||
* Setup the screen, this is only possible in ANSI mode.
|
||||
*/
|
||||
clear();
|
||||
locate(1, 1);
|
||||
colour(WHITE, BLUE);
|
||||
clrtoeol();
|
||||
mvprintw(1, 2, "MBSE BBS Chat Server");
|
||||
|
||||
sprintf(buf, "CCON,2,%d,%s", mypid, CFG.sysop);
|
||||
Syslog('-', "> %s", buf);
|
||||
if (socket_send(buf) == 0) {
|
||||
strcpy(buf, socket_receive());
|
||||
Syslog('-', "< %s", buf);
|
||||
if (strncmp(buf, "100:1,", 6) == 0) {
|
||||
cnt = strtok(buf, ",");
|
||||
msg = strtok(NULL, "\0");
|
||||
msg[strlen(msg)-1] = '\0';
|
||||
colour(LIGHTRED, BLACK);
|
||||
mvprintw(4, 1, msg);
|
||||
sleep(2);
|
||||
Pause();
|
||||
return;
|
||||
chat_with_sysop = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if(CFG.iAutoLog)
|
||||
free(sLog);
|
||||
locate(exitinfo.iScreenLen - 2, 1);
|
||||
colour(WHITE, BLUE);
|
||||
clrtoeol();
|
||||
mvprintw(exitinfo.iScreenLen - 2, 2, "Chat, type \"/EXIT\" to exit");
|
||||
|
||||
fclose(pChat);
|
||||
colour(LIGHTGRAY, BLACK);
|
||||
mvprintw(exitinfo.iScreenLen - 1, 1, ">");
|
||||
memset(&sbuf, 0, sizeof(sbuf));
|
||||
memset(&rbuf, 0, sizeof(rbuf));
|
||||
|
||||
Syslog('-', "Start loop");
|
||||
chatting = TRUE;
|
||||
|
||||
while (stop == FALSE) {
|
||||
|
||||
/*
|
||||
* Check for new message, loop fast until no more data available.
|
||||
*/
|
||||
data = TRUE;
|
||||
while (data) {
|
||||
sprintf(buf, "CGET:1,%d;", mypid);
|
||||
if (socket_send(buf) == 0) {
|
||||
strcpy(buf, socket_receive());
|
||||
if (strncmp(buf, "100:1,", 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, "\0"), 80); /* The message */
|
||||
resp[strlen(resp)-1] = '\0';
|
||||
DispMsg(resp);
|
||||
} else {
|
||||
data = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 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 (curpos < 77) {
|
||||
putchar(ch);
|
||||
fflush(stdout);
|
||||
sbuf[curpos] = ch;
|
||||
curpos++;
|
||||
} else {
|
||||
putchar(7);
|
||||
fflush(stdout);
|
||||
}
|
||||
} else if ((ch == KEY_BACKSPACE) || (ch == KEY_RUBOUT) || (ch == KEY_DEL)) {
|
||||
if (curpos) {
|
||||
curpos--;
|
||||
sbuf[curpos] = '\0';
|
||||
printf("\b \b");
|
||||
} else {
|
||||
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) {
|
||||
strncpy(resp, strtok(buf, ":"), 10); /* Should be 100 */
|
||||
strncpy(resp, strtok(NULL, ","), 5); /* Should be 1 */
|
||||
strncpy(resp, strtok(NULL, "\0"), 80); /* The message */
|
||||
resp[strlen(resp)-1] = '\0';
|
||||
DispMsg(resp);
|
||||
}
|
||||
}
|
||||
curpos = 0;
|
||||
memset(&sbuf, 0, sizeof(sbuf));
|
||||
locate(exitinfo.iScreenLen - 1, 2);
|
||||
clrtoeol();
|
||||
mvprintw(exitinfo.iScreenLen - 1, 1, ">");
|
||||
}
|
||||
}
|
||||
chatting = FALSE;
|
||||
|
||||
|
||||
/*
|
||||
* Before sending the close command, purge all outstanding messages.
|
||||
*/
|
||||
data = TRUE;
|
||||
while (data) {
|
||||
sprintf(buf, "CGET:1,%d;", mypid);
|
||||
if (socket_send(buf) == 0) {
|
||||
strcpy(buf, socket_receive());
|
||||
if (strncmp(buf, "100:1,", 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, "\0"), 80); /* The message */
|
||||
resp[strlen(resp)-1] = '\0';
|
||||
DispMsg(resp);
|
||||
} else {
|
||||
data = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (username && channel) {
|
||||
/*
|
||||
* Disjoin sysop channel
|
||||
*/
|
||||
|
||||
/* *** Sysop has terminated chat *** */
|
||||
sprintf(buf, "%s", (char *) Language(60));
|
||||
DispMsg(buf);
|
||||
Syslog('+', "Sysop chat ended");
|
||||
chat_with_sysop = FALSE;
|
||||
} else {
|
||||
Syslog('+', "User chat ended");
|
||||
}
|
||||
|
||||
/*
|
||||
* Close server connection
|
||||
*/
|
||||
sprintf(buf, "CCLO,1,%d", mypid);
|
||||
Syslog('-', "> %s", buf);
|
||||
if (socket_send(buf) == 0) {
|
||||
strcpy(buf, socket_receive());
|
||||
Syslog('-', "< %s", buf);
|
||||
if (strncmp(buf, "100:1,", 6)) {
|
||||
}
|
||||
}
|
||||
sleep(2);
|
||||
clear();
|
||||
}
|
||||
|
||||
|
||||
|
@ -3,6 +3,6 @@
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
void Chat(int); /* Chat Function */
|
||||
void Chat(char *, char *); /* Chat Function */
|
||||
|
||||
#endif
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Purpose ...............: Main startup
|
||||
*
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1997-2002
|
||||
* Copyright (C) 1997-2003
|
||||
*
|
||||
* Michiel Broek FIDO: 2:280/2802
|
||||
* Beekmansbos 10
|
||||
@ -157,10 +157,6 @@ int main(int argc, char **argv)
|
||||
*/
|
||||
TermInit(1);
|
||||
|
||||
sprintf(temp, "chat.%s", pTTY);
|
||||
if (access(temp, F_OK) == 0)
|
||||
unlink(temp);
|
||||
|
||||
/*
|
||||
* Now it's time to check if the bbs is open. If not, we
|
||||
* log the user off.
|
||||
|
@ -67,6 +67,8 @@
|
||||
#include "signature.h"
|
||||
|
||||
|
||||
extern pid_t mypid;
|
||||
|
||||
|
||||
/*
|
||||
* Menu stack, 50 levels deep.
|
||||
@ -93,7 +95,7 @@ void menu()
|
||||
{
|
||||
FILE *pMenuFile;
|
||||
int iFoundKey = FALSE, Key, IsANSI;
|
||||
char *Input, *Semfile, *sMenuPathFileName;
|
||||
char *Input, *Semfile, *sMenuPathFileName, buf[81];
|
||||
|
||||
Input = calloc(PATH_MAX, sizeof(char));
|
||||
sMenuPathFileName = calloc(PATH_MAX, sizeof(char));
|
||||
@ -191,19 +193,23 @@ void menu()
|
||||
free(Semfile);
|
||||
|
||||
/*
|
||||
* Check if SysOp wants to chat to user everytime user
|
||||
* gets prompt. Make sure /tmp/chatdev exists before
|
||||
* before calling chat(). Make sure if a second user
|
||||
* logs in, that .BusyChatting does exist.
|
||||
* Check if SysOp wants to chat to user everytime user gets prompt.
|
||||
*/
|
||||
if (CFG.iChatPromptChk && (access("/tmp/chatdev", R_OK) == 0) && (access("/tmp/.BusyChatting", F_OK) != 0))
|
||||
Chat(0);
|
||||
if (CFG.iChatPromptChk) {
|
||||
sprintf(buf, "CISC:1,%d", mypid);
|
||||
if (socket_send(buf) == 0) {
|
||||
strcpy(buf, socket_receive());
|
||||
if (strcmp(buf, "100:1,1;") == 0) {
|
||||
Syslog('+', "Forced sysop/user chat");
|
||||
Chat(exitinfo.Name, (char *)"#sysop");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Check users timeleft
|
||||
*/
|
||||
TimeCheck();
|
||||
|
||||
alarm_on();
|
||||
|
||||
if (exitinfo.HotKeys) {
|
||||
@ -409,6 +415,11 @@ void DoMenu(int Type)
|
||||
/* display menuline only */
|
||||
break;
|
||||
|
||||
case 22:
|
||||
/* Chat with any user */
|
||||
Chat(NULL, NULL);
|
||||
break;
|
||||
|
||||
case 101:
|
||||
FileArea_List(menus.OptionalData);
|
||||
break;
|
||||
|
@ -5,7 +5,7 @@
|
||||
* BBS and unix accounts.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1997-2002
|
||||
* Copyright (C) 1997-2003
|
||||
*
|
||||
* Michiel Broek FIDO: 2:280/2802
|
||||
* Beekmansbos 10
|
||||
@ -66,6 +66,7 @@ char UnixName[9]; /* Unix Name */
|
||||
extern char *ieHandle; /* Users Handle */
|
||||
extern time_t t_start; /* Program starttime */
|
||||
int do_mailout = FALSE; /* Just for linking */
|
||||
int chat_with_sysop = FALSE; /* Just for linking */
|
||||
|
||||
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
* Todo ..................: Implement new config settings.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1997-2002
|
||||
* Copyright (C) 1997-2003
|
||||
*
|
||||
* Michiel Broek FIDO: 2:280/2802
|
||||
* Beekmansbos 10
|
||||
@ -191,10 +191,22 @@ void Page_Sysop(char *String)
|
||||
fflush(stdout);
|
||||
sleep(1);
|
||||
|
||||
// if drop into chat
|
||||
// Chat();
|
||||
// free(Reason);
|
||||
// return;
|
||||
sprintf(buf, "CISC:1,%d", mypid);
|
||||
if (socket_send(buf) == 0) {
|
||||
strcpy(buf, socket_receive());
|
||||
if (strcmp(buf, "100:1,1;") == 0) {
|
||||
/*
|
||||
* First cancel page request
|
||||
*/
|
||||
sprintf(buf, "CCAN:1,%d", mypid);
|
||||
socket_send(buf);
|
||||
socket_receive();
|
||||
Syslog('+', "Sysop responded to paging request");
|
||||
Chat(exitinfo.Name, (char *)"#sysop");
|
||||
free(Reason);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Purpose ...............: Timecheck functions
|
||||
*
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1997-2002
|
||||
* Copyright (C) 1997-2003
|
||||
*
|
||||
* Michiel Broek FIDO: 2:280/2802
|
||||
* Beekmansbos 10 Internet: mbroek@users.sourceforge.net
|
||||
@ -47,6 +47,7 @@
|
||||
|
||||
|
||||
extern pid_t mypid; /* Pid of this program */
|
||||
extern int chat_with_sysop; /* True if chatting with sysop */
|
||||
|
||||
|
||||
/*
|
||||
@ -103,11 +104,10 @@ void TimeCheck(void)
|
||||
iUserTimeLeft -= Elapsed;
|
||||
sprintf(sUserTimeleft, "%d", iUserTimeLeft);
|
||||
|
||||
sprintf(temp, "/tmp/.chat.%s", pTTY);
|
||||
/*
|
||||
* Update users counter if not chatting
|
||||
*/
|
||||
if(!CFG.iStopChatTime || (access(temp, F_OK) != 0)) {
|
||||
if (!CFG.iStopChatTime || (! chat_with_sysop)) {
|
||||
exitinfo.iTimeLeft -= Elapsed;
|
||||
exitinfo.iConnectTime += Elapsed;
|
||||
exitinfo.iTimeUsed += Elapsed;
|
||||
|
@ -2086,6 +2086,7 @@ char *getmenutype(int val)
|
||||
case 19: return (char *)"Display textfile with more";
|
||||
case 20: return (char *)"Display .A?? file with Enter";
|
||||
case 21: return (char *)"Display Text Only";
|
||||
case 22: return (char *)"User chat session";
|
||||
|
||||
case 101: return (char *)"Select new file area";
|
||||
case 102: return (char *)"List files in current area";
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Purpose ...............: Global Setup Program
|
||||
*
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1997-2002
|
||||
* Copyright (C) 1997-2003
|
||||
*
|
||||
* Michiel Broek FIDO: 2:280/2802
|
||||
* Beekmansbos 10
|
||||
@ -551,94 +551,35 @@ void e_paging(void)
|
||||
set_color(WHITE, BLACK);
|
||||
mvprintw( 5, 2, "1.9 EDIT SYSOP PAGING");
|
||||
set_color(CYAN, BLACK);
|
||||
mvprintw( 7, 2, "1. Ext. Chat");
|
||||
mvprintw( 8, 2, "2. Chat Device");
|
||||
mvprintw( 9, 2, "3. Call Script");
|
||||
mvprintw(10, 2, "4. Page Length");
|
||||
mvprintw(11, 2, "5. Page Times");
|
||||
mvprintw(12, 2, "6. Sysop Area");
|
||||
mvprintw(13, 2, "7. Ask Reason");
|
||||
mvprintw(14, 2, "8. Use Extern");
|
||||
mvprintw(15, 2, "9. Log Chat");
|
||||
mvprintw(16, 2, "10. Prompt Chk.");
|
||||
mvprintw(17, 2, "11. Freeze Time");
|
||||
|
||||
mvprintw(11,42, "12. Sunday");
|
||||
mvprintw(12,42, "13. Monday");
|
||||
mvprintw(13,42, "14. Tuesday");
|
||||
mvprintw(14,42, "15. Wednesday");
|
||||
mvprintw(15,42, "16. Thursday");
|
||||
mvprintw(16,42, "17. Friday");
|
||||
mvprintw(17,42, "18. Saterday");
|
||||
mvprintw( 7, 2, "1. Page Length");
|
||||
mvprintw( 8, 2, "2. Page Times");
|
||||
mvprintw( 9, 2, "3. Sysop Area");
|
||||
mvprintw(10, 2, "4. Ask Reason");
|
||||
mvprintw(11, 2, "5. Log Chat");
|
||||
mvprintw(12, 2, "6. Prompt Chk.");
|
||||
mvprintw(13, 2, "7. Freeze Time");
|
||||
|
||||
for (;;) {
|
||||
set_color(WHITE, BLACK);
|
||||
show_str( 7,20,49, CFG.sExternalChat);
|
||||
show_str( 8,20,19, CFG.sChatDevice);
|
||||
show_str( 9,20,50, CFG.sCallScript);
|
||||
show_int(10,20, CFG.iPageLength);
|
||||
show_int(11,20, CFG.iMaxPageTimes);
|
||||
show_int(12,20, CFG.iSysopArea);
|
||||
show_bool(13,20, CFG.iAskReason);
|
||||
show_bool(14,20, CFG.iExternalChat);
|
||||
show_bool(15,20, CFG.iAutoLog);
|
||||
show_bool(16,20, CFG.iChatPromptChk);
|
||||
show_bool(17,20, CFG.iStopChatTime);
|
||||
show_int( 7,20, CFG.iPageLength);
|
||||
show_int( 8,20, CFG.iMaxPageTimes);
|
||||
show_int( 9,20, CFG.iSysopArea);
|
||||
show_bool(10,20, CFG.iAskReason);
|
||||
show_bool(11,20, CFG.iAutoLog);
|
||||
show_bool(12,20, CFG.iChatPromptChk);
|
||||
show_bool(13,20, CFG.iStopChatTime);
|
||||
|
||||
show_str(11,58,5, CFG.cStartTime[0]);
|
||||
show_str(12,58,5, CFG.cStartTime[1]);
|
||||
show_str(13,58,5, CFG.cStartTime[2]);
|
||||
show_str(14,58,5, CFG.cStartTime[3]);
|
||||
show_str(15,58,5, CFG.cStartTime[4]);
|
||||
show_str(16,58,5, CFG.cStartTime[5]);
|
||||
show_str(17,58,5, CFG.cStartTime[6]);
|
||||
|
||||
show_str(11,65,5, CFG.cStopTime[0]);
|
||||
show_str(12,65,5, CFG.cStopTime[1]);
|
||||
show_str(13,65,5, CFG.cStopTime[2]);
|
||||
show_str(14,65,5, CFG.cStopTime[3]);
|
||||
show_str(15,65,5, CFG.cStopTime[4]);
|
||||
show_str(16,65,5, CFG.cStopTime[5]);
|
||||
show_str(17,65,5, CFG.cStopTime[6]);
|
||||
|
||||
switch(select_menu(18)) {
|
||||
switch(select_menu(7)) {
|
||||
case 0: return;
|
||||
|
||||
case 1: E_STR( 7,20,49, CFG.sExternalChat, "The name of the ^External Chat^ program.")
|
||||
case 2: E_STR( 8,20,19, CFG.sChatDevice, "The ^device^ to use for chat")
|
||||
case 3: E_STR( 9,20,50, CFG.sCallScript, "The ^Call Script^ to connect to remote sysop")
|
||||
case 4: E_INT( 10,20, CFG.iPageLength, "The ^Length^ of paging in seconds")
|
||||
case 5: E_INT( 11,20, CFG.iMaxPageTimes, "The ^Maximum times^ a user may page in a session")
|
||||
case 6: E_INT( 12,20, CFG.iSysopArea, "The ^Message Area^ for ^Message to sysop^ when page fails")
|
||||
case 7: E_BOOL(13,20, CFG.iAskReason, "Ask the user the ^reason for chat^")
|
||||
case 8: E_BOOL(14,20, CFG.iExternalChat, "Use ^External Chat^ program")
|
||||
case 9: E_BOOL(15,20, CFG.iAutoLog, "^Automatic log^ chat sessions")
|
||||
case 10:E_BOOL(16,20, CFG.iChatPromptChk, "Check for chat at the ^prompt^")
|
||||
case 11:E_BOOL(17,20, CFG.iStopChatTime, "^Stop^ users time during chat")
|
||||
case 12:strcpy(CFG.cStartTime[0], edit_str(11,58,5, CFG.cStartTime[0], (char *)"Start Time paging on ^Sunday^"));
|
||||
strcpy(CFG.cStopTime[0], edit_str(11,65,5, CFG.cStopTime[0], (char *)"Stop Time paging on ^Sunday^"));
|
||||
break;
|
||||
case 13:strcpy(CFG.cStartTime[1], edit_str(12,58,5, CFG.cStartTime[1], (char *)"Start Time paging on ^Monday^"));
|
||||
strcpy(CFG.cStopTime[1], edit_str(12,65,5, CFG.cStopTime[1], (char *)"Stop Time paging on ^Monday^"));
|
||||
break;
|
||||
case 14:strcpy(CFG.cStartTime[2], edit_str(13,58,5, CFG.cStartTime[2], (char *)"Start Time paging on ^Tuesday^"));
|
||||
strcpy(CFG.cStopTime[2], edit_str(13,65,5, CFG.cStopTime[2], (char *)"Stop Time paging on ^Tuesday^"));
|
||||
break;
|
||||
case 15:strcpy(CFG.cStartTime[3], edit_str(14,58,5, CFG.cStartTime[3], (char *)"Start Time paging on ^Wednesday^"));
|
||||
strcpy(CFG.cStopTime[3], edit_str(14,65,5, CFG.cStopTime[3], (char *)"Stop Time paging on ^Wednesday^"));
|
||||
break;
|
||||
case 16:strcpy(CFG.cStartTime[4], edit_str(15,58,5, CFG.cStartTime[4], (char *)"Start Time paging on ^Thursday^"));
|
||||
strcpy(CFG.cStopTime[4], edit_str(15,65,5, CFG.cStopTime[4], (char *)"Stop Time paging on ^Thursday^"));
|
||||
break;
|
||||
case 17:
|
||||
strcpy(CFG.cStartTime[5], edit_str(16,58,5, CFG.cStartTime[5], (char *)"Start Time paging on ^Friday^"));
|
||||
strcpy(CFG.cStopTime[5], edit_str(16,65,5, CFG.cStopTime[5], (char *)"Stop Time paging on ^Friday^"));
|
||||
break;
|
||||
case 18:strcpy(CFG.cStartTime[6], edit_str(17,58,5, CFG.cStartTime[6], (char *)"Start Time paging on ^Saterday^"));
|
||||
strcpy(CFG.cStopTime[6], edit_str(17,65,5, CFG.cStopTime[6], (char *)"Stop Time paging on ^Saterday^"));
|
||||
break;
|
||||
case 1: E_INT( 7,20, CFG.iPageLength, "The ^Length^ of paging in seconds")
|
||||
case 2: E_INT( 8,20, CFG.iMaxPageTimes, "The ^Maximum times^ a user may page in a session")
|
||||
case 3: E_INT( 9,20, CFG.iSysopArea, "The ^Message Area^ for ^Message to sysop^ when page fails")
|
||||
case 4: E_BOOL(10,20, CFG.iAskReason, "Ask the user the ^reason for chat^")
|
||||
case 5: E_BOOL(11,20, CFG.iAutoLog, "^Automatic log^ chat sessions")
|
||||
case 6: E_BOOL(12,20, CFG.iChatPromptChk, "Check for chat at the ^prompt^")
|
||||
case 7: E_BOOL(13,20, CFG.iStopChatTime, "^Stop^ users time during chat")
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -1882,28 +1823,14 @@ int global_doc(FILE *fp, FILE *toc, int page)
|
||||
page = newpage(fp, page);
|
||||
addtoc(fp, toc, 1, 10, page, (char *)"Sysop paging");
|
||||
|
||||
fprintf(fp, " Ext. Chat program %s\n", CFG.sExternalChat);
|
||||
fprintf(fp, " Chat device %s\n", CFG.sChatDevice);
|
||||
fprintf(fp, " Call sysop script %s\n", CFG.sCallScript);
|
||||
fprintf(fp, " Page length %d seconds\n", CFG.iPageLength);
|
||||
fprintf(fp, " Page times %d\n", CFG.iMaxPageTimes);
|
||||
fprintf(fp, " Sysop msg area %d\n", CFG.iSysopArea);
|
||||
fprintf(fp, " Ask chat reason %s\n", getboolean(CFG.iAskReason));
|
||||
fprintf(fp, " Use external chat %s\n", getboolean(CFG.iExternalChat));
|
||||
fprintf(fp, " Log chat %s\n", getboolean(CFG.iAutoLog));
|
||||
fprintf(fp, " Check at prompt %s\n", getboolean(CFG.iChatPromptChk));
|
||||
fprintf(fp, " Freeze online time %s\n", getboolean(CFG.iStopChatTime));
|
||||
|
||||
fprintf(fp, "\n Weekday Start Stop\n");
|
||||
fprintf(fp, " ------------- ----- -----\n");
|
||||
fprintf(fp, " Sunday %s %s\n", CFG.cStartTime[0], CFG.cStopTime[0]);
|
||||
fprintf(fp, " Monday %s %s\n", CFG.cStartTime[1], CFG.cStopTime[1]);
|
||||
fprintf(fp, " Tuesday %s %s\n", CFG.cStartTime[2], CFG.cStopTime[2]);
|
||||
fprintf(fp, " Wednesday %s %s\n", CFG.cStartTime[3], CFG.cStopTime[3]);
|
||||
fprintf(fp, " Thursday %s %s\n", CFG.cStartTime[4], CFG.cStopTime[4]);
|
||||
fprintf(fp, " Friday %s %s\n", CFG.cStartTime[5], CFG.cStopTime[5]);
|
||||
fprintf(fp, " Saterday %s %s\n", CFG.cStartTime[6], CFG.cStopTime[6]);
|
||||
|
||||
addtoc(fp, toc, 1, 11, page, (char *)"Fileecho processing");
|
||||
|
||||
fprintf(fp, " Keep days on hold %d\n", CFG.tic_days);
|
||||
|
@ -195,7 +195,7 @@ int GetMenuType(void)
|
||||
mvprintw(12, 6, "6. BBS List menus");
|
||||
|
||||
switch (select_menu(6)) {
|
||||
case 1: return GetSubmenu(1, 21);
|
||||
case 1: return GetSubmenu(1, 22);
|
||||
case 2: return GetSubmenu(101, 19);
|
||||
case 3: return GetSubmenu(201, 21);
|
||||
case 4: return GetSubmenu(301, 20);
|
||||
|
@ -87,11 +87,11 @@ mbtask.o: ../config.h libs.h ../lib/structs.h ../paths.h ../lib/mberrors.h signa
|
||||
outstat.o: ../config.h libs.h ../lib/structs.h ../lib/mberrors.h taskutil.h taskstat.h scanout.h ../lib/nodelist.h callstat.h ports.h outstat.h
|
||||
signame.o: ../config.h signame.h
|
||||
taskdisk.o: ../config.h libs.h ../lib/structs.h taskdisk.h taskutil.h
|
||||
taskregs.o: ../config.h libs.h ../lib/structs.h taskstat.h taskregs.h taskutil.h
|
||||
taskregs.o: ../config.h libs.h ../lib/structs.h taskstat.h taskregs.h taskchat.h taskutil.h
|
||||
taskutil.o: ../config.h libs.h ../lib/structs.h signame.h scanout.h crc.h taskutil.h
|
||||
ports.o: ../config.h libs.h ../lib/structs.h taskutil.h ../lib/nodelist.h ports.h
|
||||
calllist.o: ../config.h libs.h ../lib/structs.h taskstat.h taskutil.h callstat.h outstat.h mbtask.h calllist.h
|
||||
ping.o: ../config.h libs.h ../lib/structs.h ../lib/mberrors.h taskstat.h taskutil.h ping.h
|
||||
crc.o: ../config.h libs.h crc.h
|
||||
taskchat.o: ../config.h libs.h ../lib/structs.h taskutil.h taskchat.h
|
||||
taskchat.o: ../config.h libs.h ../lib/structs.h taskutil.h taskregs.h taskchat.h
|
||||
# End of generated dependencies
|
||||
|
@ -258,16 +258,9 @@ void load_maincfg(void)
|
||||
CFG.iMaxPageTimes = 5;
|
||||
CFG.iAskReason = TRUE;
|
||||
CFG.iSysopArea = 1;
|
||||
CFG.iExternalChat = FALSE;
|
||||
strcpy(CFG.sExternalChat, "/usr/local/bin/chat");
|
||||
CFG.iAutoLog = TRUE;
|
||||
strcpy(CFG.sChatDevice, "/dev/tty01");
|
||||
CFG.iChatPromptChk = TRUE;
|
||||
CFG.iStopChatTime = TRUE;
|
||||
for (i = 0; i < 7; i++) {
|
||||
sprintf(CFG.cStartTime[i], "18:00");
|
||||
sprintf(CFG.cStopTime[i], "23:59");
|
||||
}
|
||||
|
||||
/*
|
||||
* Fill ticconf defaults
|
||||
|
@ -35,7 +35,7 @@
|
||||
#include "taskregs.h"
|
||||
#include "taskchat.h"
|
||||
|
||||
#define MAXCHANNELS 100 /* Maximum chat channels */
|
||||
#define MAXCHANNELS 10 /* Maximum chat channels */
|
||||
#define MAXMESSAGES 100 /* Maximum ringbuffer for messages */
|
||||
|
||||
|
||||
@ -73,6 +73,19 @@ typedef struct _chatmsg {
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* List of channels
|
||||
*/
|
||||
typedef struct _channel_rec {
|
||||
char name[21]; /* Channel name */
|
||||
pid_t owner; /* Channel owner */
|
||||
int users; /* Users in channel */
|
||||
time_t created; /* Creation time */
|
||||
unsigned active : 1; /* Channel active */
|
||||
} _channel;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* List of banned users from a channel. This is a dynamic list.
|
||||
*/
|
||||
@ -82,17 +95,42 @@ typedef struct _banned {
|
||||
} banned_users;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* The buffers
|
||||
*/
|
||||
_chat_messages chat_messages[MAXMESSAGES];
|
||||
_chat_users chat_users[MAXCLIENT];
|
||||
_channel chat_channels[MAXCHANNELS];
|
||||
|
||||
|
||||
int buffer_head = 0; /* Messages buffer head */
|
||||
extern struct sysconfig CFG; /* System configuration */
|
||||
|
||||
|
||||
/*
|
||||
* Prototypes
|
||||
*/
|
||||
void chat_msg(int, char *, char *);
|
||||
|
||||
|
||||
|
||||
|
||||
void chat_dump(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
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");
|
||||
for (i = 0; i < MAXCHANNELS; i++)
|
||||
if (chat_channels[i].owner)
|
||||
Syslog('c', "%-20s %5d %3d %s", chat_channels[i].name, chat_channels[i].owner, chat_channels[i].users,
|
||||
chat_channels[i].active?"True":"False");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Put a system message into the chatbuffer
|
||||
@ -128,10 +166,158 @@ void chat_help(pid_t pid)
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Join a channel
|
||||
*/
|
||||
int join(pid_t, char *);
|
||||
int join(pid_t pid, char *channel)
|
||||
{
|
||||
int i, j;
|
||||
char buf[81];
|
||||
|
||||
Syslog('-', "Join pid %d to channel %s", pid, channel);
|
||||
for (i = 0; i < MAXCHANNELS; i++) {
|
||||
if (strcasecmp(chat_channels[i].name, channel) == 0) {
|
||||
/*
|
||||
* Excisting channel, add user to channel.
|
||||
*/
|
||||
chat_channels[i].users++;
|
||||
for (j = 0; j < MAXCLIENT; j++) {
|
||||
if (chat_users[j].pid == pid) {
|
||||
chat_users[j].channel = i;
|
||||
chat_users[j].chatting = TRUE;
|
||||
Syslog('-', "Added user %d to channel %d", j, i);
|
||||
chat_dump();
|
||||
sprintf(buf, "%s has joined channel #%s, now %d users", chat_users[j].name, channel, chat_channels[i].users);
|
||||
chat_msg(i, NULL, buf);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* No matching channel found, add a new channel.
|
||||
*/
|
||||
for (i = 0; i < MAXCHANNELS; i++) {
|
||||
if (chat_channels[i].active == FALSE) {
|
||||
/*
|
||||
* Got one, register channel.
|
||||
*/
|
||||
strncpy(chat_channels[i].name, channel, 20);
|
||||
chat_channels[i].owner = pid;
|
||||
chat_channels[i].users = 1;
|
||||
chat_channels[i].created = time(NULL);
|
||||
chat_channels[i].active = TRUE;
|
||||
Syslog('-', "Created channel %d", i);
|
||||
/*
|
||||
* Register user to channel
|
||||
*/
|
||||
for (j = 0; j < MAXCLIENT; j++) {
|
||||
if (chat_users[j].pid == pid) {
|
||||
chat_users[j].channel = i;
|
||||
chat_users[j].chatting = TRUE;
|
||||
Syslog('-', "Added user %d to channel %d", j, i);
|
||||
sprintf(buf, "Created channel #%s", channel);
|
||||
chat_msg(i, NULL, buf);
|
||||
}
|
||||
}
|
||||
chat_dump();
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* No matching or free channels
|
||||
*/
|
||||
Syslog('+', "Cannot create chat channel %s, no free channels", channel);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Part from a channel
|
||||
*/
|
||||
int part(pid_t, char*);
|
||||
int part(pid_t pid, char *reason)
|
||||
{
|
||||
int i;
|
||||
char buf[81];
|
||||
|
||||
Syslog('-', "Part pid %d from channel, reason %s", pid, reason);
|
||||
|
||||
for (i = 0; i < MAXCLIENT; i++) {
|
||||
if ((chat_users[i].pid == pid) && chat_users[i].chatting) {
|
||||
chat_channels[chat_users[i].channel].users--;
|
||||
|
||||
/*
|
||||
* Inform other users
|
||||
*/
|
||||
if (reason != NULL)
|
||||
chat_msg(chat_users[i].channel, chat_users[i].name, reason);
|
||||
sprintf(buf, "%s has left channel #%s, %d users left", chat_users[i].name, chat_channels[chat_users[i].channel].name,
|
||||
chat_channels[chat_users[i].channel].users);
|
||||
chat_msg(chat_users[i].channel, NULL, buf);
|
||||
|
||||
/*
|
||||
* First clean channel
|
||||
*/
|
||||
Syslog('-', "User leaves channel %s", chat_channels[chat_users[i].channel].name);
|
||||
if (chat_channels[chat_users[i].channel].users == 0) {
|
||||
/*
|
||||
* Last user from channel, clear channel
|
||||
*/
|
||||
Syslog('-', "Remove channel %s, no more users left", chat_channels[chat_users[i].channel].name);
|
||||
memset(&chat_channels[chat_users[i].channel], 0, sizeof(_channel));
|
||||
}
|
||||
chat_users[i].channel = -1;
|
||||
chat_users[i].chatting = FALSE;
|
||||
chat_dump();
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
Syslog('-', "No channel found");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void chat_init(void)
|
||||
{
|
||||
memset(&chat_users, 0, sizeof(chat_users));
|
||||
memset(&chat_messages, 0, sizeof(chat_messages));
|
||||
memset(&chat_channels, 0, sizeof(chat_channels));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void chat_cleanuser(pid_t pid)
|
||||
{
|
||||
part(pid, (char *)"I'm hanging up!");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Send message into channel
|
||||
*/
|
||||
void chat_msg(int channel, char *nick, char *msg)
|
||||
{
|
||||
int i;
|
||||
char buf[128];
|
||||
|
||||
if (nick == NULL)
|
||||
sprintf(buf, "%s", msg);
|
||||
else
|
||||
sprintf(buf, "<%s> %s", nick, msg);
|
||||
buf[79] = '\0';
|
||||
|
||||
for (i = 0; i < MAXCLIENT; i++) {
|
||||
if ((chat_users[i].channel == channel) && chat_users[i].chatting) {
|
||||
system_msg(chat_users[i].pid, buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -243,18 +429,19 @@ char *chat_put(char *data)
|
||||
*/
|
||||
if (strncasecmp(msg, "/help", 5) == 0) {
|
||||
chat_help(atoi(pid));
|
||||
sprintf(buf, "100:0;");
|
||||
return buf;
|
||||
goto ack;
|
||||
}
|
||||
if (strncasecmp(msg, "/exit", 5) == 0) {
|
||||
if ((strncasecmp(msg, "/exit", 5) == 0) ||
|
||||
(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);
|
||||
sprintf(buf, "100:0;");
|
||||
return buf;
|
||||
goto ack;
|
||||
}
|
||||
if (strncasecmp(msg, "/join", 5) == 0) {
|
||||
cmd = strtok(msg, " \0");
|
||||
@ -266,9 +453,20 @@ char *chat_put(char *data)
|
||||
system_msg(chat_users[i].pid, buf);
|
||||
} else {
|
||||
Syslog('-', "Trying to join channel %s", cmd);
|
||||
join(chat_users[i].pid, cmd+1);
|
||||
}
|
||||
sprintf(buf, "100:0;");
|
||||
return buf;
|
||||
goto ack;
|
||||
}
|
||||
if (strncasecmp(msg, "/part", 5) == 0) {
|
||||
cmd = strtok(msg, " \0");
|
||||
Syslog('-', "\"%s\"", cmd);
|
||||
cmd = strtok(NULL, "\0");
|
||||
Syslog('-', "\"%s\"", cmd);
|
||||
if (part(chat_users[i].pid, cmd) == FALSE) {
|
||||
sprintf(buf, "Not in a channel");
|
||||
system_msg(chat_users[i].pid, buf);
|
||||
}
|
||||
goto ack;
|
||||
}
|
||||
/*
|
||||
* If still here, the command was not recognized.
|
||||
@ -276,8 +474,7 @@ char *chat_put(char *data)
|
||||
cmd = strtok(msg, " \t\r\n\0");
|
||||
sprintf(buf, "%s :Unknown command", cmd+1);
|
||||
system_msg(chat_users[i].pid, buf);
|
||||
sprintf(buf, "100:0;");
|
||||
return buf;
|
||||
goto ack;
|
||||
}
|
||||
if (chat_users[i].channel == -1) {
|
||||
/*
|
||||
@ -285,16 +482,22 @@ char *chat_put(char *data)
|
||||
*/
|
||||
sprintf(buf, "No channel joined. Try /join #channel");
|
||||
system_msg(chat_users[i].pid, buf);
|
||||
sprintf(buf, "100:0;");
|
||||
return buf;
|
||||
chat_dump();
|
||||
goto ack;
|
||||
} else {
|
||||
chat_msg(chat_users[i].channel, chat_users[i].name, msg);
|
||||
chat_dump();
|
||||
}
|
||||
sprintf(buf, "100:0;");
|
||||
return buf;
|
||||
goto ack;
|
||||
}
|
||||
}
|
||||
Syslog('-', "Pid %s was not connected to chatserver");
|
||||
sprintf(buf, "100:1,ERROR - Not connected to server;");
|
||||
return buf;
|
||||
|
||||
ack:
|
||||
sprintf(buf, "100:0;");
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
@ -305,7 +508,7 @@ char *chat_get(char *data)
|
||||
char *pid;
|
||||
int i;
|
||||
|
||||
Syslog('-', "CGET:%s", data);
|
||||
// Syslog('-', "CGET:%s", data);
|
||||
memset(&buf, 0, sizeof(buf));
|
||||
pid = strtok(data, ",");
|
||||
pid = strtok(NULL, ";");
|
||||
|
@ -4,6 +4,7 @@
|
||||
/* $Id$ */
|
||||
|
||||
void chat_init(void);
|
||||
void chat_cleanuser(pid_t);
|
||||
char *chat_connect(char *);
|
||||
char *chat_close(char *);
|
||||
char *chat_put(char *);
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "../lib/structs.h"
|
||||
#include "taskstat.h"
|
||||
#include "taskregs.h"
|
||||
#include "taskchat.h"
|
||||
#include "taskutil.h"
|
||||
|
||||
extern reg_info reginfo[MAXCLIENT]; /* Array with clients */
|
||||
@ -130,6 +131,9 @@ int reg_closecon(char *data)
|
||||
mailers--;
|
||||
if (reginfo[rec].istcp)
|
||||
ipmailers--;
|
||||
if ((strcmp(reginfo[rec].prg, (char *)"mbsebbs") == 0) || (strcmp(reginfo[rec].prg, (char *)"mbmon") == 0))
|
||||
chat_cleanuser(atoi(pid));
|
||||
|
||||
Syslog('-', "Unregistered client pgm \"%s\", pid %s, slot %d, mailers %d, TCP/IP %d",
|
||||
reginfo[rec].prg, pid, rec, mailers, ipmailers);
|
||||
memset(®info[rec], 0, sizeof(reg_info));
|
||||
@ -156,11 +160,11 @@ void reg_check(void)
|
||||
mailers--;
|
||||
if (reginfo[i].istcp)
|
||||
ipmailers--;
|
||||
if ((strcmp(reginfo[i].prg, (char *)"mbsebbs") == 0) || (strcmp(reginfo[i].prg, (char *)"mbmon") == 0))
|
||||
chat_cleanuser(reginfo[i].pid);
|
||||
|
||||
Syslog('?', "Stale registration found for pid %d (%s), mailers now %d, TCP/IP now %d",
|
||||
reginfo[i].pid, reginfo[i].prg, mailers, ipmailers);
|
||||
|
||||
// FIXME: If this was a moderators chat channel, kill the whole channel
|
||||
|
||||
memset(®info[i], 0, sizeof(reg_info));
|
||||
stat_dec_clients();
|
||||
}
|
||||
|
Reference in New Issue
Block a user