X-Git-Url: http://git.pk910.de/?a=blobdiff_plain;f=src%2FIRCParser.c;h=e92b3462279b6c18895ff66d4eb0b29c349104cc;hb=d2f5566813cad3f8e9e5d05bd1a4f768ec079050;hp=17aeef45ed25ecfaf89d056c2b94d39c4214f497;hpb=8b89857bfaca58d04c19b31a73f1d7d8575940db;p=NeonServV5.git diff --git a/src/IRCParser.c b/src/IRCParser.c index 17aeef4..e92b346 100644 --- a/src/IRCParser.c +++ b/src/IRCParser.c @@ -566,11 +566,17 @@ static IRC_CMD(raw_notice) { return 1; } +static void client_renamed(struct ClientSocket *client); + static IRC_CMD(raw_nick) { if(from == NULL || argc == 0) return 0; struct UserNode *user = getUserByMask(from); if(user == NULL) return 0; - if(!is_firstBotSeeUser(client, user)) return 1; //we ignore it - but it's not a parse error + if(isBot(user)) { + if(client->user != user) return 1; + client_renamed(client); + } + else if(!is_firstBotSeeUser(client, user)) return 1; //we ignore it - but it's not a parse error event_nick(user, argv[0]); renameUser(user, argv[0]); return 1; @@ -684,8 +690,40 @@ static IRC_CMD(raw_332) { return 1; } +struct ClientRenamePartedChannel { + char channel[CHANNELLEN+1]; + struct ClientRenamePartedChannel *next; +}; + +static IRC_CMD(raw_437) { //can NOT change nick + struct ClientRenamePartedChannel *partedchan = malloc(sizeof(*partedchan)); + strcpy(partedchan->channel, argv[1]); + if((client->flags & SOCKET_FLAG_CHANGENICK)) + partedchan->next = client->changenick_channels; + else + partedchan->next = NULL; + client->changenick_channels = partedchan; + client->flags |= SOCKET_FLAG_CHANGENICK; + putsock(client, "PART %s", argv[1]); + putsock(client, "NICK %s", client->nick); + return 1; +} + +static void client_renamed(struct ClientSocket *client) { + if((client->flags & SOCKET_FLAG_CHANGENICK)) { + struct ClientRenamePartedChannel *partedchan, *nextchan; + for(partedchan = client->changenick_channels; partedchan; partedchan = nextchan) { + nextchan = partedchan->next; + putsock(client, "JOIN %s", partedchan->channel); + free(partedchan); + } + client->flags &= ~SOCKET_FLAG_CHANGENICK; + } +} + void init_parser() { //all the raws we receive... + register_irc_function("437", raw_437); register_irc_function("002", raw_002); register_irc_function("251", raw_251); register_irc_function("254", raw_254);