Загрузить файлы в «»
This commit is contained in:
parent
1c4180cc36
commit
168feddfe7
29
main.c
29
main.c
@ -44,6 +44,20 @@ void WriteToFile(void) {
|
|||||||
fclose(fp);
|
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) {
|
int main(void) {
|
||||||
if (chdir(DIR))
|
if (chdir(DIR))
|
||||||
die("Cant chdir");
|
die("Cant chdir");
|
||||||
@ -55,9 +69,13 @@ int main(void) {
|
|||||||
die("Conn refused");
|
die("Conn refused");
|
||||||
|
|
||||||
//Register and join in channel
|
//Register and join in channel
|
||||||
|
recvinfo();
|
||||||
IRCC_register(&client, NICK);
|
IRCC_register(&client, NICK);
|
||||||
|
|
||||||
|
//Recv motd and join in channel
|
||||||
|
recvinfo();
|
||||||
|
sleep(5);
|
||||||
for (size_t i = 0; i < sizeof(channels) / sizeof(char *); i++) {
|
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;
|
size_t join_size = strlen("JOIN \r\n") + strlen(channels[i]) + 1;
|
||||||
char *tmp = malloc(join_size);
|
char *tmp = malloc(join_size);
|
||||||
if (tmp == NULL)
|
if (tmp == NULL)
|
||||||
@ -68,12 +86,5 @@ int main(void) {
|
|||||||
free(tmp);
|
free(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (1) {
|
recvinfo();
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user