diff options
Diffstat (limited to 'src/modules/m_sajoin.cpp')
-rw-r--r-- | src/modules/m_sajoin.cpp | 56 |
1 files changed, 33 insertions, 23 deletions
diff --git a/src/modules/m_sajoin.cpp b/src/modules/m_sajoin.cpp index 553211c60..bbf683226 100644 --- a/src/modules/m_sajoin.cpp +++ b/src/modules/m_sajoin.cpp @@ -25,43 +25,53 @@ using namespace std; /* $ModDesc: Provides support for unreal-style SAJOIN command */ Server *Srv; - -void handle_sajoin(char **parameters, int pcnt, userrec *user) + +class cmd_sajoin : public command_t { - userrec* dest = Srv->FindNick(std::string(parameters[0])); - if (dest) + public: + cmd_sajoin() : command_t("SAJOIN", 'o', 2) { - /* might be nicer to make checking valid channel names an api function sometime --w00t */ - if (parameters[1][0] != '#') - { - /* we didn't need to check this for each character ;) */ - Srv->SendTo(NULL,user,"NOTICE "+std::string(user->nick)+" :*** Invalid characters in channel name"); - return; - } + this->source = "m_sajoin.cpp"; + } - for (unsigned int x = 0; x < strlen(parameters[1]); x++) + void Handle (char **parameters, int pcnt, userrec *user) + { + userrec* dest = Srv->FindNick(std::string(parameters[0])); + if (dest) { - if ((parameters[1][x] == ' ') || (parameters[1][x] == ',')) - { - Srv->SendTo(NULL,user,"NOTICE "+std::string(user->nick)+" :*** Invalid characters in channel name"); - return; - } - } + /* might be nicer to make checking valid channel names an api function sometime --w00t */ + if (parameters[1][0] != '#') + { + /* we didn't need to check this for each character ;) */ + Srv->SendTo(NULL,user,"NOTICE "+std::string(user->nick)+" :*** Invalid characters in channel name"); + return; + } - Srv->SendOpers(std::string(user->nick)+" used SAJOIN to make "+std::string(dest->nick)+" join "+parameters[1]); - Srv->JoinUserToChannel(dest,std::string(parameters[1]),std::string(dest->nick)); - } -} + for (unsigned int x = 0; x < strlen(parameters[1]); x++) + { + if ((parameters[1][x] == ' ') || (parameters[1][x] == ',')) + { + Srv->SendTo(NULL,user,"NOTICE "+std::string(user->nick)+" :*** Invalid characters in channel name"); + return; + } + } + Srv->SendOpers(std::string(user->nick)+" used SAJOIN to make "+std::string(dest->nick)+" join "+parameters[1]); + Srv->JoinUserToChannel(dest,std::string(parameters[1]),std::string(dest->nick)); + } + } +}; class ModuleSajoin : public Module { + cmd_sajoin* mycommand; public: ModuleSajoin(Server* Me) : Module::Module(Me) { Srv = Me; - Srv->AddCommand("SAJOIN",handle_sajoin,'o',2,"m_sajoin.so"); + mycommand = new cmd_sajoin(); + Srv->AddCommand(mycommand); } virtual ~ModuleSajoin() |