From ab9d8fd1af3ebf028506ec543f74fd13471742dd Mon Sep 17 00:00:00 2001 From: brain Date: Fri, 16 Dec 2005 18:23:50 +0000 Subject: Porting to new command system git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2535 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_sajoin.cpp | 56 ++++++++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 23 deletions(-) (limited to 'src/modules/m_sajoin.cpp') 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() -- cgit v1.2.3