8 #include "configreader.h"
11 /* $ModDesc: Provides the /shun command, which stops a user executing all commands except PING and PONG. */
13 class Shun : public XLine
16 std::string matchtext;
18 Shun(InspIRCd* Instance, time_t s_time, long d, const char* src, const char* re, const char *shunmask) : XLine(Instance, s_time, d, src, re, "S")
20 this->matchtext = shunmask;
29 if (ServerInstance->MatchText(u->GetFullHost(), matchtext) || ServerInstance->MatchText(u->GetFullRealHost(), matchtext))
35 // XXX unused, why do we *have* to implement this
36 bool Matches(const std::string &s)
43 // Application is done by the module.
49 ServerInstance->SNO->WriteToSnoMask('x',"Expiring timed shun %s (set by %s %ld seconds ago)", this->matchtext.c_str(), this->source, this->duration);
52 const char* Displayable()
54 return matchtext.c_str();
58 //typedef std::vector<Shun> shunlist;
60 class cmd_shun : public Command
66 cmd_shun(InspIRCd* Me) : Command(Me, "SHUN", "o", 1), Srv(Me)
68 this->source = "m_shun.so";
71 CmdResult Handle(const char* const*parameters, int pcnt, User *user)
73 /* syntax: SHUN nick!user@host time :reason goes here */
74 /* 'time' is a human-readable timestring, like 2d3h2s. */
78 if (ServerInstance->XLines->DelLine(parameters[0], "S", user))
80 ServerInstance->SNO->WriteToSnoMask('x',"%s Removed R-Line on %s.",user->nick,parameters[0]);
84 // XXX todo implement stats
85 user->WriteServ("NOTICE %s :*** Shun %s not found in list, try /stats s.",user->nick,parameters[0]);
92 // Adding - XXX todo make this respect <insane> tag perhaps..
93 long duration = ServerInstance->Duration(parameters[1]);
98 r = new Shun(ServerInstance, ServerInstance->Time(), duration, user->nick, parameters[2], parameters[0]);
102 ; // Do nothing. If we get here, the regex was fucked up, and they already got told it fucked up.
107 if (ServerInstance->XLines->AddLine(r, user))
111 ServerInstance->SNO->WriteToSnoMask('x',"%s added permanent shun for %s.", user->nick, parameters[0]);
115 time_t c_requires_crap = duration + ServerInstance->Time();
116 ServerInstance->SNO->WriteToSnoMask('x', "%s added timed shun for %s, expires on %s", user->nick, parameters[0],
117 ServerInstance->TimeString(c_requires_crap).c_str());
120 ServerInstance->XLines->ApplyLines();
125 user->WriteServ("NOTICE %s :*** Shun for %s already exists", user->nick, parameters[0]);
134 class ModuleShun : public Module
139 ModuleShun(InspIRCd* Me) : Module(Me)
141 mycommand = new cmd_shun(ServerInstance);
142 ServerInstance->AddCommand(mycommand);
145 void Implements(char* List)
147 List[I_OnPreCommand] = List[I_OnStats] = 1;
150 virtual int OnStats(char symbol, User* user, string_list& out)
153 //format << Srv->Config->ServerName << " 223 " << user->nick << " :" << iter->banmask << " " << iter->set_on << " " << iter->length << " " <<
154 //iter->set_by << " " << iter->reason;
159 virtual int OnPreCommand(const std::string &command, const char* const*parameters, int pcnt, User* user, bool validated, const std::string &original_line)
161 if((command != "PONG") && (command != "PING"))
163 // Don't let them issue cmd if they are shunned..
164 XLine *rl = ServerInstance->XLines->MatchesLine("S", user);
175 virtual ~ModuleShun()
179 virtual Version GetVersion()
181 return Version(1,0,0,0,0,API_VERSION);
185 MODULE_INIT(ModuleShun)