Загрузить файлы в «»
This commit is contained in:
parent
1c4180cc36
commit
168feddfe7
29
main.c
29
main.c
@ -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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user