diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2005-03-27 18:46:29 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2005-03-27 18:46:29 +0000 |
commit | 0afad3dfbca96a60bd14535cb93f27097417b933 (patch) | |
tree | 8a06fad263acc66a2d9ce18b393153ccb363df15 /src/commands.cpp | |
parent | 8d7a4231075eaf72244dbf0da82052f71a89be58 (diff) |
Made config parsing code a bit more lenient
Added error checking to make sure opertypes exist before opering a user!
Added 005 handling for modules
Started on KILL event for modules
Started on OnModuleLoad event for modules
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@918 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/commands.cpp')
-rw-r--r-- | src/commands.cpp | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/src/commands.cpp b/src/commands.cpp index dbb7a43a4..c47da8a61 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -762,7 +762,7 @@ void handle_whois(char **parameters, int pcnt, userrec *user) { WriteServ(user->fd,"301 %s %s :%s",user->nick, dest->nick, dest->awaymsg); } - if (strchr(dest->modes,'o')) + if ((strchr(dest->modes,'o')) && (strcmp(dest->oper,""))) { WriteServ(user->fd,"313 %s %s :is %s %s on %s",user->nick, dest->nick, (strchr("aeiou",dest->oper[0]) ? "an" : "a"),dest->oper, Network); @@ -1487,6 +1487,7 @@ void handle_oper(char **parameters, int pcnt, userrec *user) char TypeName[MAXBUF]; char Hostname[MAXBUF]; int i,j; + bool found = false; for (int i = 0; i < ConfValueEnum("oper",&config_f); i++) { @@ -1494,14 +1495,6 @@ void handle_oper(char **parameters, int pcnt, userrec *user) ConfValue("oper","password",i,Password,&config_f); if ((!strcmp(LoginName,parameters[0])) && (!strcmp(Password,parameters[1]))) { - /* correct oper credentials */ - ConfValue("oper","type",i,OperType,&config_f); - WriteOpers("*** %s (%s@%s) is now an IRC operator of type %s",user->nick,user->ident,user->host,OperType); - WriteServ(user->fd,"381 %s :You are now an IRC operator of type %s",user->nick,OperType); - WriteServ(user->fd,"MODE %s :+o",user->nick); - char global[MAXBUF]; - snprintf(global,MAXBUF,"M %s +o",user->nick); - NetSendToAll(global); for (j =0; j < ConfValueEnum("type",&config_f); j++) { ConfValue("type","name",j,TypeName,&config_f); @@ -1513,13 +1506,29 @@ void handle_oper(char **parameters, int pcnt, userrec *user) ConfValue("type","host",j,Hostname,&config_f); ChangeDisplayedHost(user,Hostname); strlcpy(user->oper,TypeName,NICKMAX); + found = true; } } - if (!strchr(user->modes,'o')) + if (found) + { + /* correct oper credentials */ + ConfValue("oper","type",i,OperType,&config_f); + WriteOpers("*** %s (%s@%s) is now an IRC operator of type %s",user->nick,user->ident,user->host,OperType); + WriteServ(user->fd,"381 %s :You are now an IRC operator of type %s",user->nick,OperType); + if (!strchr(user->modes,'o')) + { + strcat(user->modes,"o"); + WriteServ(user->fd,"MODE %s :+o",user->nick); + char global[MAXBUF]; + snprintf(global,MAXBUF,"M %s +o",user->nick); + NetSendToAll(global); + FOREACH_MOD OnOper(user); + } + } + else { - strcat(user->modes,"o"); + WriteOpers("*** BROKEN CONFIGURATION! *** Oper type %s for oper %s not found!",OperType,LoginName); } - FOREACH_MOD OnOper(user); return; } } |