Anope IRC Services
Anope Development => Modules => Topic started by: John on November 21, 2013, 12:03:30 AM
-
Hi Folks
This module is a good addition to the Help system placed on some networks. Unfortunately, I seem to have a small error with this.
The module can be found here (https://modules.anope.org/index.php?page=view&id=117) and my comment below that.
Just in case the comment isn't obvious, I'll add it here too.
Anope Version: 1.8.6
Module Version: 1.0.1
Comments:
Works fine for me, except for 1 error. Every time a nickname is changed, doesn't matter if the nickname is NOT on the helpchannel or not, it will trigger the error.
Warning: [he_queue] Invalid event count in he_hook_nick (Count is 2, expected 1. Event will not be processed.
If this could be fixed it would make me very happy, stop all the nick changes from driving me nucking futs.
Here is the offending int block.
int he_hook_nick(int count, char **av) {
User *u = NULL;
char *data = NULL;
Helpqueue *p = hqueue;
User *helper = NULL;
User *ticket_u = NULL;
if(count != 1) {
alog("Warning: [he_queue] Invalid event count in he_hook_nick (Count is %d, expected 1. Event will not be processed.", count);
return MOD_CONT;
}
if(hqueue == NULL) {
return MOD_CONT;
}
u = finduser(av[0]);
if(u != NULL) {
data = moduleGetData(&u->moduleData, "c_id");
if(data != NULL) {
while(p != NULL) {
if(strcmp(data,p->c_id) == 0) {
if(strlen(p->helper) > 0) {
helper = finduser(p->helper);
if(helper != NULL) {
moduleNoticeLang(s_HelpServ, helper, LANG_HELPME_CHANGE_NICK, p->c_id, p->nick, av[0]);
}
}
strcpy(p->nick, av[0]);
break;
}
else {
if(strlen(p->helper) > 0) {
if(strcmp(data,p->helper_c_id) == 0) {
ticket_u = finduser(p->nick);
if(ticket_u != NULL) {
moduleNoticeLang(s_HelpServ, ticket_u, LANG_HELPME_CHANGE_HELPERNICK, p->helper, av[0]);
}
}
strcpy(p->helper, av[0]);
}
}
p = p->next;
}
free(data);
}
}
return MOD_CONT;
}
I don't want to have to just comment out this alog, since it's there for a purpose, but if I'm unable to find any other fix then I'll simply remove the output. Thanks in advance.
-
per https://github.com/anope/anope/blob/1.8/docs/EVENTS
EVENT_CHANGE_NICK
A user has just changed its nick.
av[0] The new nickname of the user. Event is called after the user has been changed
to this nickname.
av[1] The old nickname of the user.
The array count will always be 2 [0, 1]
and from https://github.com/anope/anope/blob/1.8/src/users.c
send_event(EVENT_CHANGE_NICK, 2, nick, oldnick);
your code is
if(count != 1) {
alog("Warning: [he_queue] Invalid event count in he_hook_nick (Count is %d, expected 1. Event will not be processed.", count);
return MOD_CONT;
}
it should be
if(count != 2) {
alog("Warning: [he_queue] Invalid event count in he_hook_nick (Count is %d, expected 2. Event will not be processed.", count);
return MOD_CONT;
}
-
Awesome, thank you, Trystan 8)
I have now been able to fix several small issues that have been plaguing me a while. I'm a happy chappy.
After checking out some of the sites and code you mentioned, shouldnt the block be more like this?
if(count != 0) {
alog("Warning: [he_queue] Invalid event count in he_hook_nick (Count is %d, expected 0. Event will not be processed.", count);
return MOD_CONT;
}
I couldn't find send_event(EVENT_CHANGE_NICK, 2, nick, oldnick);
but I did find and read (line 65) static void change_user_nick(User * user, const char *nick)
and it never mentioned a 2 argument.