anope- supernets anope source code & configuration |
git clone git://git.acid.vegas/anope.git |
Log | Files | Refs | Archive | README |
os_chankill.cpp (3100B)
1 /* OperServ core functions 2 * 3 * (C) 2003-2022 Anope Team 4 * Contact us at team@anope.org 5 * 6 * Please read COPYING and README for further details. 7 * 8 * Based on the original code of Epona by Lara. 9 * Based on the original code of Services by Andy Church. 10 */ 11 12 #include "module.h" 13 14 static ServiceReference<XLineManager> akills("XLineManager", "xlinemanager/sgline"); 15 16 class CommandOSChanKill : public Command 17 { 18 public: 19 CommandOSChanKill(Module *creator) : Command(creator, "operserv/chankill", 2, 3) 20 { 21 this->SetDesc(_("AKILL all users on a specific channel")); 22 this->SetSyntax(_("[+\037expiry\037] \037channel\037 \037reason\037")); 23 } 24 25 void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override 26 { 27 if (!akills) 28 return; 29 30 Anope::string expiry, channel; 31 unsigned last_param = 1; 32 Channel *c; 33 34 channel = params[0]; 35 if (!channel.empty() && channel[0] == '+') 36 { 37 expiry = channel; 38 channel = params[1]; 39 last_param = 2; 40 } 41 42 time_t expires = !expiry.empty() ? Anope::DoTime(expiry) : Config->GetModule("operserv")->Get<time_t>("autokillexpiry", "30d"); 43 if (!expiry.empty() && isdigit(expiry[expiry.length() - 1])) 44 expires *= 86400; 45 if (expires && expires < 60) 46 { 47 source.Reply(BAD_EXPIRY_TIME); 48 return; 49 } 50 else if (expires > 0) 51 expires += Anope::CurTime; 52 53 if (params.size() <= last_param) 54 { 55 this->OnSyntaxError(source, ""); 56 return; 57 } 58 59 Anope::string reason = params[last_param]; 60 if (params.size() > last_param + 1) 61 reason += params[last_param + 1]; 62 if (!reason.empty()) 63 { 64 Anope::string realreason; 65 if (Config->GetModule("operserv")->Get<bool>("addakiller") && !source.GetNick().empty()) 66 realreason = "[" + source.GetNick() + "] " + reason; 67 else 68 realreason = reason; 69 70 if ((c = Channel::Find(channel))) 71 { 72 for (Channel::ChanUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; ++it) 73 { 74 ChanUserContainer *uc = it->second; 75 76 if (uc->user->server == Me || uc->user->HasMode("OPER")) 77 continue; 78 79 Anope::string akillmask = "*@" + uc->user->host; 80 if (akills->HasEntry(akillmask)) 81 continue; 82 83 XLine *x = new XLine(akillmask, source.GetNick(), expires, realreason, XLineManager::GenerateUID()); 84 akills->AddXLine(x); 85 akills->OnMatch(uc->user, x); 86 } 87 88 Log(LOG_ADMIN, source, this) << "on " << c->name << " (" << realreason << ")"; 89 } 90 else 91 source.Reply(CHAN_X_NOT_IN_USE, channel.c_str()); 92 } 93 return; 94 } 95 96 bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override 97 { 98 this->SendSyntax(source); 99 source.Reply(" "); 100 source.Reply(_("Puts an AKILL for every nick on the specified channel. It\n" 101 "uses the entire real ident@host for every nick, and\n" 102 "then enforces the AKILL.")); 103 return true; 104 } 105 }; 106 107 class OSChanKill : public Module 108 { 109 CommandOSChanKill commandoschankill; 110 111 public: 112 OSChanKill(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, VENDOR), 113 commandoschankill(this) 114 { 115 116 } 117 }; 118 119 MODULE_INIT(OSChanKill)