1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2010 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
16 class ModulePassForward : public Module
19 std::string nickrequired, forwardmsg, forwardcmd;
25 Implementation eventlist[] = { I_OnPostConnect, I_OnRehash };
26 ServerInstance->Modules->Attach(eventlist, this, 2);
31 return Version("Sends server password to NickServ", VF_VENDOR);
34 void OnRehash(User* user)
37 nickrequired = Conf.ReadValue("passforward", "nick", "NickServ", 0);
38 forwardmsg = Conf.ReadValue("passforward", "forwardmsg", "NOTICE $nick :*** Forwarding PASS to $nickrequired", 0);
39 forwardcmd = Conf.ReadValue("passforward", "cmd", "PRIVMSG $nickrequired :IDENTIFY $pass", 0);
42 void FormatStr(std::string& result, const std::string& format, const std::string &nick, const std::string &pass)
44 for (unsigned int i = 0; i < format.length(); i++)
49 if (format.substr(i, 13) == "$nickrequired")
51 result.append(nickrequired);
54 else if (format.substr(i, 5) == "$nick")
59 else if (format.substr(i,5) == "$pass")
72 virtual void OnPostConnect(User* ruser)
74 LocalUser* user = IS_LOCAL(ruser);
75 if (!user || user->password.empty())
78 if (!nickrequired.empty())
80 /* Check if nick exists and its server is ulined */
81 User* u = ServerInstance->FindNick(nickrequired.c_str());
82 if (!u || !ServerInstance->ULine(u->server))
87 FormatStr(tmp,forwardmsg, user->nick, user->password);
91 FormatStr(tmp,forwardcmd, user->nick, user->password);
92 ServerInstance->Parser->ProcessBuffer(tmp,user);
96 MODULE_INIT(ModulePassForward)