- PCREFilter(pcre* r, const std::string &rea, const std::string &act, long gline_time, const std::string &pat, const std::string &flags)
- : FilterResult(pat, rea, act, gline_time, flags), regexp(r)
- {
- }
+ /** Create a R-Line.
+ * @param s_time The set time
+ * @param d The duration of the xline
+ * @param src The sender of the xline
+ * @param re The reason of the xline
+ * @param regex Pattern to match with
+ * @
+ */
+ RLine(InspIRCd* Instance, time_t s_time, long d, std::string src, std::string re, std::string regexs)
+ : XLine(Instance, s_time, d, src, re, "R")
+ {
+ matchtext = regexs;
+
+ if (!rxengine)
+ {
+ ServerInstance->SNO->WriteToSnoMask('x', "Cannot create regexes until engine is set to a loaded provider!");
+ throw ModuleException("Regex engine not set or loaded!");
+ }
+
+ /* This can throw on failure, but if it does we DONT catch it here, we catch it and display it
+ * where the object is created, we might not ALWAYS want it to output stuff to snomask x all the time
+ */
+ regex = RegexFactoryRequest(mymodule, rxengine, regexs).Create();
+ }
+
+ /** Destructor
+ */
+ ~RLine()
+ {
+ delete regex;
+ }
+
+ bool Matches(User *u)
+ {
+ if (u->exempt)
+ return false;
+
+ std::string compare = u->nick + "!" + u->ident + "@" + u->host + " " + u->fullname;
+ return regex->Matches(compare);
+ }
+
+ bool Matches(const std::string &compare)
+ {
+ return regex->Matches(compare);
+ }
+
+ void Apply(User* u)
+ {
+ DefaultApply(u, "R", true);
+ }
+
+ void DisplayExpiry()
+ {
+ ServerInstance->SNO->WriteToSnoMask('x',"Removing expired R-Line %s (set by %s %ld seconds ago)",
+ this->matchtext.c_str(), this->source.c_str(), (long int)(ServerInstance->Time() - this->set_time));
+ }
+
+ const char* Displayable()
+ {
+ return matchtext.c_str();
+ }
+
+ std::string matchtext;