diff --git a/main.c b/main.c index a9fba5f..b46f725 100644 --- a/main.c +++ b/main.c @@ -15,7 +15,6 @@ FILE *logFile = 0x0; int logLevel = 1; int highSock = 0x0; -int joinChan = 0x0; time_t startTime; int onIRC = 0; @@ -154,8 +153,7 @@ if (net == 1) { writeLog(0,"TUve Network\n"); if (strstr(dataFresh,"PING ") != 0x0) { - strtok(dataFresh," "); - sWriteSocket(tuveSocket,"PONG %s\n",strtok(NULL,"\n")); + sWriteSocket(tuveSocket,"PONG!\n"); } else { cmd = strtok_r(dataFresh,":",&data_tok); @@ -174,19 +172,19 @@ for (chunk = strtok_r(dataFresh,"\n",&chunk_tok);chunk;chunk = strtok_r(NULL,"\n",&chunk_tok)) { cmd = strtok_r(chunk," ",&data_tok); - //printf("CMD1: [%s]\n",cmd); if (cmd[0] == ':') { if (strstr(cmd,"!") != 0x0) { - for (i=1;cmd[i] != '!';i++) + memset(&IRCnick,0x0,32); + for (i=1;cmd[i] != '!';i++) { IRCnick[i-1] = cmd[i]; - IRCnick[i] = '\0'; + } + IRCnick[i] = 0x0; writeLog(0,"IRC NICK: [%s]\n",IRCnick); } cmd = strtok_r(NULL," ",&data_tok); } - //printf("CMD2: [%s]\n",cmd); if (cmd == 0x0) writeLog(0,"NULL CMD\n"); else if (!strcmp(cmd,"PING")) diff --git a/socket.c b/socket.c index 8c4f25b..8595ac0 100644 --- a/socket.c +++ b/socket.c @@ -69,8 +69,8 @@ else { writeLog(2,"IRC Socket: [%i]\n",mySocket); ircSocket = mySocket; - sWriteSocket(ircSocket,"NICK TV_B\n"); - sWriteSocket(ircSocket,"USER TV_B 8 * :TUve Bridge\n"); + sWriteSocket(ircSocket,"NICK TVB\n"); + sWriteSocket(ircSocket,"USER TVB 8 * :TUve Bridge\n"); sWriteSocket(ircSocket,"JOIN #UbixOS\n"); } diff --git a/tuvebridge.h b/tuvebridge.h index 00b17da..08ee347 100644 --- a/tuvebridge.h +++ b/tuvebridge.h @@ -25,51 +25,12 @@ #define MYPORT 9999 // the port users will be connecting to #define BACKLOG 10 // how many pending connections queue will hold #define LOG_FILE "./logs/tuvebot.log" -#define PING_INTERVAL 20 -#define MAX_PING 2 -#define MAX_COUNT 2 -#define MAX_TOPIC_LEN 128 -#define MAX_CHAN_LEN 32 -#define VERSION "v0.40" #define MYSQL_HOST_NAME "ivorytower.ubixonline.com" #define MYSQL_USERNAME "tuve" #define MYSQL_PASSWORD "5558585" #define MYSQL_DB_NAME "tuve" -/* Cannel Modes */ -#define CHAN_MODES 8 // Count Of Channel Modes -#define CHAN_RANDOM 0 // Random Videos -#define CHAN_QUEUE 1 // Users Queues -#define CHAN_TIME 2 // Video Time Limit -#define CHAN_RATING 3 // Video Parental Rating -#define CHAN_CLASS 4 // Video Classs -#define CHAN_LIVE 5 // Channel Is In Live Stream Mode -#define CHAN_EXCLUSIVE 6 // Channel Is In Exclusive Mode -#define CHAN_NOADS 7 // Channel Has No Advertisements - -typedef struct botChanList { - struct botChanList *prev; - struct botChanList *next; - int modes[CHAN_MODES]; - char topic[MAX_TOPIC_LEN]; - char channel[MAX_CHAN_LEN]; - short updated; - short sM; - unsigned int schedule[10][3]; - int sCount; - int sCur; - int cid; - } botChanList_t; - -typedef struct myConnections { - struct myConnections *prev; - struct myConnections *next; - int fd; - int recLen; - char data[1024]; - char host[128]; - time_t signedOn; - } myConnections_t; +#define VERSION "v0.40" /* Global variables very not safe @@ -77,18 +38,9 @@ extern int tuveSocket; extern int ircSocket; -extern int connected; -extern pthread_mutex_t chanMutex; -extern botChanList_t *chans; - extern int highSock; extern FILE *logFile; extern time_t startTime; -extern int joinChan; - -/* Threads */ -void *bridgeTUve_Thread(void *threadid); //Main Thread For TUve Network -void *bridgeIRC_Thread(void *threadid); //Main Thread For IRC Network /* Socket Functions */ int sConnect(int net,const char *host,int port); @@ -99,37 +51,6 @@ /* Log Functions */ int writeLog(int level,char const * __restrict, ...); -/* Channel Functions */ -int tuveChanList(myConnections_t *userConnection); -int tuveChanPart(const char *channel,myConnections_t *userConnection); -int tuveChanJoin(const char *channel,myConnections_t *userConnection); -int tuveAddChan(const char *channel,myConnections_t *userConnection); -int tuveAddToChanList(const char *channel,myConnections_t *userConnection); -int tuveSendAllInChan(const char *channel,myConnections_t *userConnection,char *output); -int tuveDelUserChans(myConnections_t *userConnection,char *msg); -int tuveRemoveFromChanList(const char *channel,myConnections_t *userConnection); -int tuveSetTopic(myConnections_t *userConnection,char *chan,char *topic); -int tuveSendAllInUsersChans(myConnections_t *userConnection,char *output); -int tuveDelChan(const char *channel,myConnections_t *userConnection); -int tuveKick(char *by,char *chan,char *nick,char *msg); -int tuveBan(const char *channel,const char *nick); -int tuveUnBan(const char *channel,const char *nick); -int tuveVerifyBan(const char *channel,const char *nick); - -/* Bot Functions */ -void *tuveBotThread(void *threadid); -int tuveBotCMD(myConnections_t *userConnection,char *chan,char *data); -int tuveBotSetSong(char *chan,char *playTime,char *file,char *title); -int tuveBotNoSong(char *chan); - /* Database Functions */ int dbInit(); MYSQL_RES *dbQuery(const char *query,short type); - -/* Bridge Functions */ - -int botJoinChans(); -int botStoreTopic(char *data); -botChanList_t *botFindChan(char *channel); -botChanList_t *botAddChan(char *channel); -int botDoLogin(char *cmdData);