void kill_link(userrec *user,const char* r);
void kill_link_silent(userrec *user,const char* r);
void call_handler(const char* commandname,char **parameters, int pcnt, userrec *user);
+bool is_valid_cmd(const char* commandname, int pcnt, userrec * user);
std::string GetRevision();
int loop_call(handlerfunc fn, char **parameters, int pcnt, userrec *u, int start, int end, int joins);
void kick_channel(userrec *src,userrec *user, chanrec *Ptr, char* reason);
* used for privilage checks, etc.
*/
virtual void CallCommandHandler(std::string commandname, char** parameters, int pcnt, userrec* user);
+
+ virtual bool IsValidModuleCommand(std::string commandname, int pcnt, userrec* user);
/** Change displayed hostname of a user.
* You should always call this method to change a user's host rather than writing directly to the
}
+bool is_valid_cmd(const char* commandname, int pcnt, userrec * user)
+{
+ for (unsigned int i = 0; i < cmdlist.size(); i++)
+ {
+ if (!strcasecmp(cmdlist[i].command,commandname))
+ {
+ if (cmdlist[i].handler_function)
+ {
+ if (pcnt>=cmdlist[i].min_params)
+ {
+ if (strchr(user->modes,cmdlist[i].flags_needed))
+ {
+ return true;
+ }
+ }
+ }
+ }
+ }
+ return false;
+}
+
// calls a handler function for a command
void call_handler(const char* commandname,char **parameters, int pcnt, userrec *user)
call_handler(commandname.c_str(),parameters,pcnt,user);
}
+bool Server::IsValidModuleCommand(std::string commandname, int pcnt, userrec* user)
+{
+ return is_valid_cmd(commandname, pcnt, user)
+}
+
void Server::Log(int level, std::string s)
{
log(level,"%s",s.c_str());
this->HandleLinks(parameters,pcnt,user);
return 1;
}
+ else if (Srv->IsValidModuleCommand(command, pcnt, user))
+ {
+ // this bit of code cleverly routes all module commands
+ // to all remote severs *automatically* so that modules
+ // can just handle commands locally, without having
+ // to have any special provision in place for remote
+ // commands and linking protocols.
+ std::deque<std::string> params;
+ params.clear();
+ for (int j = 0; j < pcnt; j++)
+ {
+ if (strchr(parameters[j],' '))
+ {
+ params.push_back(":" + std::string(parameters[j]));
+ }
+ else
+ {
+ params.push_back(std::string(parameters[j]));
+ }
+ }
+ DoOneToMany(user->nick,command,params);
+ }
return 0;
}