if (client->nick)
printf("USER SET NICKNAME %s\n", client->nick);
fflush(stdout);
+ if (client->nick && client->username)
+ newUser(client);
} else if(strcmp(command, "USER") == 0) {
+ if (argc < 4) // FIXME: error message
+ return 0;
+ // set username
+ free(client->username); // FIXME: maybe don't allow to change it after registration?
+ client->username = malloc(strlen(args[0])+2);
+ if (!client->username)
+ abort();
+ client->username[0] = '~';
+ strcpy(client->username + 1, args[0]);
+ // set realname
+ free(client->realname); // ditto
+ client->realname = strdup(args[3]);
+ if (!client->realname)
+ abort();
// Send welcome
- newUser(client);
+ if (client->nick && client->username)
+ newUser(client);
} else if(strcmp(command, "MOTD") == 0) {
// Send welcome
sendMOTD(client);
if (argc == 0) // FIXME: error message
return 0;
// TODO: actual host
- copy_strf(&databuf, ":%s 302 %s :%s=+user@~localhost\n", hostname, client->nick, args[0]);
+ copy_strf(&databuf, ":%s 302 %s :%s=+~user@localhost\n", hostname, client->nick, args[0]);
send_log(client->FD, databuf.buf, databuf.len, 0);
} else if(strcmp(command, "WHO") == 0) {
if (!client->nick) // FIXME: error message
// TODO: actual host info
struct client_data *cl = findClient(args[0]);
if (cl)
- copy_strf(&databuf, ":%s 352 %s * user ~localhost %s %s H :1 Patchouli Knowledge\n", hostname, client->nick, hostname, args[0]);
+ copy_strf(&databuf, ":%s 352 %s * ~user localhost %s %s H :1 Patchouli Knowledge\n", hostname, client->nick, hostname, args[0]);
copy_strf(&databuf, ":%s 315 %s %s :End of WHO list\n", hostname, client->nick, args[0]);
send_log(client->FD, databuf.buf, databuf.len, 0);
} else {
}
void newUser(struct client_data *client) {
- copy_strf(&databuf, ":%s 001 %s :Welcome to PatchyIRCD!!!\n", hostname, client->nick);
+ copy_strf(&databuf, ":%s 001 %s :Welcome to the Patchy Network, %s\n", hostname, client->nick, client->nick);
send_log(client->FD, databuf.buf, databuf.len, 0);
- copy_strf(&databuf, ":%s 002 %s :Your host is PatchyIRCD V0.0.1\n", hostname, client->nick);
+ copy_strf(&databuf, ":%s 002 %s :Your host is PatchyIRCD, running version 0.0.1\n", hostname, client->nick);
send_log(client->FD, databuf.buf, databuf.len, 0);
copy_strf(&databuf, ":%s 003 %s :This server was created when I had cybersex with your mother.\n", hostname, client->nick);
send_log(client->FD, databuf.buf, databuf.len, 0);
+ copy_strf(&databuf, ":%s 004 %s PatchyIRCD 0.0.1 i nt\n", hostname, client->nick);
+ send_log(client->FD, databuf.buf, databuf.len, 0);
+ // FIXME: output nicklen from the actual macro
+ copy_strf(&databuf, ":%s 005 %s CASEMAPPING=rfc1459 NICKLEN=31 :are supported by this server\n", hostname, client->nick);
+ send_log(client->FD, databuf.buf, databuf.len, 0);
copy_strf(&databuf, ":%s 251 %s :This server exists\n", hostname, client->nick);
send_log(client->FD, databuf.buf, databuf.len, 0);
copy_strf(&databuf, ":%s 252 %s :Jannies don't exist\n", hostname, client->nick);