Загрузить файлы в «»

This commit is contained in:
8nlight 2023-08-07 18:08:35 +03:00
parent 1c4180cc36
commit 168feddfe7

29
main.c
View File

@ -44,6 +44,20 @@ void WriteToFile(void) {
fclose(fp);
}
void recvinfo(void) {
while (1) {
unsigned int irc_status = IRCC_recv(&client);
if (irc_status == IRCC_DISCONNECTED)
die("Disconnected");
else if (client.nick != NULL && client.channel != NULL && client.msg != NULL && irc_status == IRCC_PRIVMSG)
WriteToFile();
else if (strstr(client.raw, "No Ident") || irc_status == IRCC_CONNECTED)
return;
}
}
int main(void) {
if (chdir(DIR))
die("Cant chdir");
@ -55,9 +69,13 @@ int main(void) {
die("Conn refused");
//Register and join in channel
recvinfo();
IRCC_register(&client, NICK);
//Recv motd and join in channel
recvinfo();
sleep(5);
for (size_t i = 0; i < sizeof(channels) / sizeof(char *); i++) {
sleep(3);
size_t join_size = strlen("JOIN \r\n") + strlen(channels[i]) + 1;
char *tmp = malloc(join_size);
if (tmp == NULL)
@ -68,12 +86,5 @@ int main(void) {
free(tmp);
}
while (1) {
unsigned int irc_status = IRCC_recv(&client);
if (irc_status == IRCC_DISCONNECTED)
die("Disconnected");
else if (client.nick != NULL && client.channel != NULL && client.msg != NULL && irc_status == IRCC_PRIVMSG)
WriteToFile();
}
recvinfo();
}