-#include <stdio.h>
+/* +------------------------------------+
+ * | Inspire Internet Relay Chat Daemon |
+ * +------------------------------------+
+ *
+ * Inspire is copyright (C) 2002-2004 ChatSpike-Dev.
+ * E-mail:
+ * <brain@chatspike.net>
+ * <Craig@chatspike.net>
+ *
+ * Written by Craig Edwards, Craig McLure, and others.
+ * This program is free but copyrighted software; see
+ * the file COPYING for details.
+ *
+ * ---------------------------------------------------
+ */
+
+using namespace std;
+#include <stdio.h>
#include "users.h"
#include "channels.h"
#include "modules.h"
+#include "helperfuncs.h"
/* $ModDesc: Provides channel modes +a and +q */
-char dummyvalue[] = "on";
+char fakevalue[] = "on";
class ModuleChanProtect : public Module
{
FirstInGetsFounder = Conf->ReadFlag("options","noservices",0);
}
+ virtual void On005Numeric(std::string &output)
+ {
+ std::stringstream line(output);
+ std::string temp1, temp2;
+ while (!line.eof())
+ {
+ line >> temp1;
+ if (temp1.substr(0,10) == "CHANMODES=")
+ {
+ // append the chanmode to the end
+ temp1 = temp1.substr(10,temp1.length());
+ temp1 = "CHANMODES=qa" + temp1;
+ }
+ temp2 = temp2 + temp1 + " ";
+ }
+ if (temp2.length())
+ output = temp2.substr(0,temp2.length()-1);
+ }
+
+ virtual void OnUserKick(userrec* source, userrec* user, chanrec* chan, std::string reason)
+ {
+ // FIX: when someone gets kicked from a channel we must remove their Extensibles!
+ user->Shrink("cm_founder_"+std::string(chan->name));
+ user->Shrink("cm_protect_"+std::string(chan->name));
+ }
+
+ virtual void OnUserPart(userrec* user, chanrec* channel)
+ {
+ // FIX: when someone parts a channel we must remove their Extensibles!
+ user->Shrink("cm_founder_"+std::string(channel->name));
+ user->Shrink("cm_protect_"+std::string(channel->name));
+ }
+
virtual void OnRehash()
{
// on a rehash we delete our classes for good measure and create them again.
// this way is best as it adds data thats accessible to other modules
// (so long as you document your code properly) without breaking anything
// because its encapsulated neatly in a map.
- if (user->Extend("cm_founder_"+std::string(channel->name),dummyvalue))
+
+ // Change requested by katsklaw... when the first in is set to get founder,
+ // to make it clearer that +q has been given, send that one user the +q notice
+ // so that their client's syncronization and their sanity are left intact.
+ WriteServ(user->fd,"MODE %s +q %s",channel->name,user->nick);
+ if (user->Extend("cm_founder_"+std::string(channel->name),fakevalue))
{
Srv->Log(DEBUG,"Marked user "+std::string(user->nick)+" as founder for "+std::string(channel->name));
}
{
if (!theuser->GetExt("cm_founder_"+std::string(chan->name)))
{
- theuser->Extend("cm_founder_"+std::string(chan->name),dummyvalue);
+ theuser->Extend("cm_founder_"+std::string(chan->name),fakevalue);
return 1;
}
}
{
if (!theuser->GetExt("cm_protect_"+std::string(chan->name)))
{
- theuser->Extend("cm_protect_"+std::string(chan->name),dummyvalue);
+ theuser->Extend("cm_protect_"+std::string(chan->name),fakevalue);
return 1;
}
}
}
return 0;
}
+
+ virtual void OnSendList(userrec* user, chanrec* channel, char mode)
+ {
+ if (mode == 'q')
+ {
+ chanuserlist cl = Srv->GetUsers(channel);
+ for (int i = 0; i < cl.size(); i++)
+ {
+ if (cl[i]->GetExt("cm_founder_"+std::string(channel->name)))
+ {
+ WriteServ(user->fd,"386 %s %s %s",user->nick, channel->name,cl[i]->nick);
+ }
+ }
+ WriteServ(user->fd,"387 %s %s :End of channel founder list",user->nick, channel->name);
+ }
+ if (mode == 'a')
+ {
+ chanuserlist cl = Srv->GetUsers(channel);
+ for (int i = 0; i < cl.size(); i++)
+ {
+ if (cl[i]->GetExt("cm_protect_"+std::string(channel->name)))
+ {
+ WriteServ(user->fd,"388 %s %s %s",user->nick, channel->name,cl[i]->nick);
+ }
+ }
+ WriteServ(user->fd,"389 %s %s :End of channel protected user list",user->nick, channel->name);
+ }
+
+ }
virtual ~ModuleChanProtect()
{
virtual Version GetVersion()
{
- return Version(1,0,0,0);
+ return Version(1,0,0,0,VF_STATIC|VF_VENDOR);
}
virtual string_list OnChannelSync(chanrec* chan)