]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_uninvite.cpp
cmode(), cflags(), cstatus() -> chanrec::GetStatusChar(), chanrec::GetStatusFlags...
[user/henk/code/inspircd.git] / src / modules / m_uninvite.cpp
index e9c2078cb9f1199b0b98d8babe78a0f787e84e4a..70e73cfad501e69ef045b4a93d435e62f71441fd 100644 (file)
@@ -24,8 +24,10 @@ using namespace std;
 #include "modules.h"
 #include "helperfuncs.h"
 #include "message.h"
+#include "inspircd.h"
 
 static Server *Srv;
+extern InspIRCd* ServerInstance;
         
 class cmd_uninvite : public command_t
 {
@@ -33,54 +35,55 @@ class cmd_uninvite : public command_t
        cmd_uninvite () : command_t("UNINVITE", 0, 2)
        {
                this->source = "m_uninvite.so";
+               syntax = "<nick> <channel>";
        }
 
-       void Handle (char **parameters, int pcnt, userrec *user)
+       void Handle (const char** parameters, int pcnt, userrec *user)
        {
-                userrec* u = Find(parameters[0]);
-                chanrec* c = FindChan(parameters[1]);
-                         
-                if ((!c) || (!u))
-                {        
-                        if (!c)
-                        {
-                                WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[1]);
-                        }
-                        else
-                        {
-                                WriteServ(user->fd,"401 %s %s :No such nick/channel",user->nick, parameters[0]);
-                        }
-                                
-                        return; 
-                }        
-
-                if (c->binarymodes & CM_INVITEONLY)
-                {
-                        if (cstatus(user,c) < STATUS_HOP)
-                        {
-                                WriteServ(user->fd,"482 %s %s :You must be at least a half-operator to change modes on this channel",user->nick, c->name);
-                                return;
-                        }
-                }
+               userrec* u = ServerInstance->FindNick(parameters[0]);
+               chanrec* c = ServerInstance->FindChan(parameters[1]);
+                        
+               if ((!c) || (!u))
+               {       
+                       if (!c)
+                       {
+                               user->WriteServ("401 %s %s :No such nick/channel",user->nick, parameters[1]);
+                       }
+                       else
+                       {
+                               user->WriteServ("401 %s %s :No such nick/channel",user->nick, parameters[0]);
+                       }
+                               
+                       return; 
+               }       
+
+               if (c->modes[CM_INVITEONLY])
+               {
+                       if (c->GetStatus(user) < STATUS_HOP)
+                       {
+                               user->WriteServ("482 %s %s :You must be at least a half-operator to change modes on this channel",user->nick, c->name);
+                               return;
+                       }
+               }
 
                irc::string xname(c->name);
 
-                if (!u->IsInvited(xname))
-                {
-                        WriteServ(user->fd,"491 %s %s %s :Is not invited to channel %s",user->nick,u->nick,c->name,c->name);
-                        return;
-                }
-                if (!has_channel(user,c))
-                {
-                        WriteServ(user->fd,"492 %s %s :You're not on that channel!",user->nick, c->name);
-                        return;
-                }
-
-                u->RemoveInvite(xname);
-                WriteServ(user->fd,"494 %s %s %s :Uninvited",user->nick,c->name,u->nick);
-               WriteServ(u->fd,"493 %s :You were uninvited from %s by %s",u->nick,c->name,user->nick);
-                WriteChannel(c,user,"NOTICE %s :*** %s uninvited %s.",c->name,user->nick,u->nick);
-        }
+               if (!u->IsInvited(xname))
+               {
+                       user->WriteServ("491 %s %s %s :Is not invited to channel %s",user->nick,u->nick,c->name,c->name);
+                       return;
+               }
+               if (!c->HasUser(user))
+               {
+                       user->WriteServ("492 %s %s :You're not on that channel!",user->nick, c->name);
+                       return;
+               }
+
+               u->RemoveInvite(xname);
+               user->WriteServ("494 %s %s %s :Uninvited",user->nick,c->name,u->nick);
+               u->WriteServ("493 %s :You were uninvited from %s by %s",u->nick,c->name,user->nick);
+               c->WriteChannelWithServ(Srv->GetServerName().c_str(), "NOTICE %s :*** %s uninvited %s.", c->name, user->nick, u->nick);
+       }
 };
 
 class ModuleUninvite : public Module