m_cycle.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "inspircd.h"
00015
00016
00017
00020 class CommandCycle : public Command
00021 {
00022 public:
00023 CommandCycle (InspIRCd* Instance) : Command(Instance,"CYCLE", 0, 1, false, 3)
00024 {
00025 this->source = "m_cycle.so";
00026 syntax = "<channel> :[reason]";
00027 TRANSLATE3(TR_TEXT, TR_TEXT, TR_END);
00028 }
00029
00030 CmdResult Handle (const std::vector<std::string> ¶meters, User *user)
00031 {
00032 Channel* channel = ServerInstance->FindChan(parameters[0]);
00033 std::string reason = ConvToStr("Cycling");
00034
00035 if (parameters.size() > 1)
00036 {
00037
00038 reason = reason + ": " + parameters[1];
00039 }
00040
00041 if (!channel)
00042 {
00043 user->WriteNumeric(403, "%s %s :No such channel", user->nick.c_str(), parameters[0].c_str());
00044 return CMD_FAILURE;
00045 }
00046
00047 if (channel->HasUser(user))
00048 {
00049
00050
00051
00052 if (IS_LOCAL(user))
00053 {
00054 if (channel->GetStatus(user) < STATUS_VOICE && channel->IsBanned(user))
00055 {
00056
00057 user->WriteServ("NOTICE "+std::string(user->nick)+" :*** You may not cycle, as you are banned on channel " + channel->name);
00058 return CMD_FAILURE;
00059 }
00060
00061
00062 if (!channel->PartUser(user, reason))
00063 delete channel;
00064
00065 Channel::JoinUser(ServerInstance, user, parameters[0].c_str(), true, "", false, ServerInstance->Time());
00066 }
00067
00068 return CMD_LOCALONLY;
00069 }
00070 else
00071 {
00072 user->WriteNumeric(442, "%s %s :You're not on that channel", user->nick.c_str(), channel->name.c_str());
00073 }
00074
00075 return CMD_FAILURE;
00076 }
00077 };
00078
00079
00080 class ModuleCycle : public Module
00081 {
00082 CommandCycle* mycommand;
00083 public:
00084 ModuleCycle(InspIRCd* Me)
00085 : Module(Me)
00086 {
00087
00088 mycommand = new CommandCycle(ServerInstance);
00089 ServerInstance->AddCommand(mycommand);
00090
00091 }
00092
00093 virtual ~ModuleCycle()
00094 {
00095 }
00096
00097 virtual Version GetVersion()
00098 {
00099 return Version("$Id: m_cycle.cpp 10291 2008-08-25 20:35:51Z w00t $", VF_VENDOR, API_VERSION);
00100 }
00101
00102 };
00103
00104 MODULE_INIT(ModuleCycle)