]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_antibear.cpp
Wheeee for HUGE commits. Convert all numerics to WriteNumeric so that OnNumeric can...
[user/henk/code/inspircd.git] / src / modules / m_antibear.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
6  * See: http://www.inspircd.org/wiki/index.php/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #include "inspircd.h"
15 #include "xline.h"
16
17 /* $ModDesc: Sends a numeric on connect which cripples a common type of trojan/spambot */
18
19 class ModuleAntiBear : public Module
20 {
21  private:
22
23  public:
24         ModuleAntiBear(InspIRCd* Me) : Module(Me)
25         {
26                 
27                 Implementation eventlist[] = { I_OnUserRegister, I_OnPreCommand };
28                 ServerInstance->Modules->Attach(eventlist, this, 2);
29         }
30         
31         virtual ~ModuleAntiBear()
32         {
33         }
34         
35         virtual Version GetVersion()
36         {
37                 return Version(1,1,0,0,VF_VENDOR,API_VERSION);
38         }
39
40
41         virtual int OnPreCommand(const std::string &command, const char* const* parameters, int pcnt, User *user, bool validated, const std::string &original_line)
42         {
43                 if (command == "NOTICE" && !validated && pcnt > 1 && user->GetExt("antibear_timewait"))
44                 {
45                         if (!strncmp(parameters[1], "\1TIME Mon May 01 18:54:20 2006", 30))
46                         {
47                                 ZLine* zl = new ZLine(ServerInstance, ServerInstance->Time(), 86400, ServerInstance->Config->ServerName,
48                                                 "Unless you're stuck in a time warp, you appear to be a bear bot!", user->GetIPString());
49                                 if (ServerInstance->XLines->AddLine(zl,NULL))
50                                 {
51                                         ServerInstance->XLines->ApplyLines();
52                                 }
53                                 else
54                                         delete zl;
55
56                                 return 1;
57                         }
58                         
59                         user->Shrink("antibear_timewait");
60                         // Block the command, so the user doesn't receive a no such nick notice
61                         return 1;
62                 }
63                 
64                 return 0;
65         }
66
67         virtual int OnUserRegister(User* user)
68         {
69                 user->WriteNumeric(439, "%s :This server has anti-spambot mechanisms enabled.", user->nick);
70                 user->WriteNumeric(931, "%s :Malicious bots, spammers, and other automated systems of dubious origin are NOT welcome here.", user->nick);
71                 user->WriteServ("PRIVMSG %s :\1TIME\1", user->nick);
72                 user->Extend("antibear_timewait");
73                 return 0;
74         }
75 };
76
77 MODULE_INIT(ModuleAntiBear)