]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/modules/m_abbreviation.cpp
bc04cc307d3f8e1294a1eacea2378d48478676c8
[user/henk/code/inspircd.git] / src / modules / m_abbreviation.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 "wildcard.h"
16
17 /* $ModDesc: Provides the ability to abbreviate commands. */
18
19 class ModuleAbbreviation : public Module
20 {
21
22  public:
23         
24         ModuleAbbreviation(InspIRCd* Me)
25                 : Module(Me)
26         {
27                 Me->Modules->Attach(I_OnPreCommand, this);
28                 /* Must do this first */
29                 Me->Modules->SetPriority(this, I_OnPreCommand, PRIO_FIRST);
30         }
31
32         virtual Version GetVersion()
33         {
34                 return Version(1,2,0,0,VF_VENDOR,API_VERSION);
35         }
36
37         virtual int OnPreCommand(std::string &command, std::vector<std::string> &parameters, User *user, bool validated, const std::string &original_line)
38         {
39                 /* Command is already validated, has a length of 0, or last character is not a . */
40                 if (validated || command.empty() || *command.rbegin() != '.')
41                         return 0;
42
43                 /* Whack the . off the end */
44                 command.erase(command.end() - 1);
45
46                 ServerInstance->Logs->Log("m_abbreviation", DEBUG, "Abbreviated command: %s", command.c_str());
47
48                 return false;
49         }
50 };
51
52 MODULE_INIT(ModuleAbbreviation)