#define SOCKET_FLAG_QUITTED 0x100
#define SOCKET_FLAG_FAST_JUMP 0x200
#define SOCKET_FLAG_SILENT 0x400
+#define SOCKET_FLAG_CHANGENICK 0x800
#define SOCKET_HAVE_BOTCLASSVALUE1 0x10000000
#define SOCKET_HAVE_BOTCLASSVALUE2 0x20000000
void *botclassvalue2;
void *botclassvalue3;
+ void *changenick_channels; //parted channels due raw 437
+
struct ClientSocket *next;
};
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;
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);