This commit is contained in:
Your Name 2025-04-13 18:37:55 +03:00
parent 18278e6d6c
commit 65de41ff41
2 changed files with 10 additions and 10 deletions

18
C/irc.c
View File

@ -91,14 +91,6 @@ int IRCC_recv(IRCC_client *irc) {
if (msg_size == 0 || msg_size == -1) if (msg_size == 0 || msg_size == -1)
return IRCC_DISCONNECTED; return IRCC_DISCONNECTED;
else if (!strncmp(irc->irc_raw, "PING", 4)) {
*(strchr(irc->irc_raw, 'I')) = 'O';
if (IRCC_usend(irc, strlen(irc->irc_raw)) == -1)
return IRCC_ERROR;
return IRCC_PING;
}
return IRCC_SUCCESS; return IRCC_SUCCESS;
} }
@ -107,11 +99,18 @@ int IRCC_parse(IRCC_client *irc) {
irc->irc_msg = NULL; irc->irc_msg = NULL;
irc->irc_nick = NULL; irc->irc_nick = NULL;
if (!strncmp(irc->irc_raw, "PING", 4)) {
*(strchr(irc->irc_raw, 'I')) = 'O';
if (IRCC_usend(irc, strlen(irc->irc_raw)) == -1)
return IRCC_ERROR;
return IRCC_PING;
}
//Check end of motd //Check end of motd
if (strstr(irc->irc_raw, "PRIVMSG ") == NULL && strstr(irc->irc_raw, "MOTD")) if (strstr(irc->irc_raw, "PRIVMSG ") == NULL && strstr(irc->irc_raw, "MOTD"))
return IRCC_CONNECTED; return IRCC_CONNECTED;
//Other
else if (strstr(irc->irc_raw, "PRIVMSG ")) { else if (strstr(irc->irc_raw, "PRIVMSG ")) {
IRCC_parse_msg(strstr(irc->irc_raw, "PRIVMSG "), irc); IRCC_parse_msg(strstr(irc->irc_raw, "PRIVMSG "), irc);
return IRCC_PRIVMSG; return IRCC_PRIVMSG;
@ -235,3 +234,4 @@ void IRCC_close(IRCC_client *irc) {
SSL_CTX_free(irc->irc_sslctx); SSL_CTX_free(irc->irc_sslctx);
#endif #endif
} }

View File

@ -48,7 +48,7 @@ void recvinfo(void) {
else if (client.irc_nick != NULL && irc_status == IRCC_JOIN) else if (client.irc_nick != NULL && irc_status == IRCC_JOIN)
printf("[>] %s\n", client.irc_nick); printf("[>] %s\n", client.irc_nick);
else if (client.irc_nick != NULL && irc_status == IRCC_PART) else if (client.irc_nick != NULL && irc_status == IRCC_QUIT)
printf("[<] %s\n", client.irc_nick); printf("[<] %s\n", client.irc_nick);
} }
} }