m_botmode.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 #include <stdio.h>
00016 #include <string>
00017 #include "users.h"
00018 #include "channels.h"
00019 #include "modules.h"
00020 #include "configreader.h"
00021
00022
00023
00026 class BotMode : public ModeHandler
00027 {
00028 public:
00029 BotMode(InspIRCd* Instance) : ModeHandler(Instance, 'B', 0, 0, false, MODETYPE_USER, false) { }
00030
00031 ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string ¶meter, bool adding)
00032 {
00033 if (adding)
00034 {
00035 if (!dest->IsModeSet('B'))
00036 {
00037 dest->SetMode('B',true);
00038 return MODEACTION_ALLOW;
00039 }
00040 }
00041 else
00042 {
00043 if (dest->IsModeSet('B'))
00044 {
00045 dest->SetMode('B',false);
00046 return MODEACTION_ALLOW;
00047 }
00048 }
00049
00050 return MODEACTION_DENY;
00051 }
00052 };
00053
00054 class ModuleBotMode : public Module
00055 {
00056
00057 BotMode* bm;
00058 public:
00059 ModuleBotMode(InspIRCd* Me)
00060 : Module(Me)
00061 {
00062
00063 bm = new BotMode(ServerInstance);
00064 if (!ServerInstance->AddMode(bm, 'B'))
00065 throw ModuleException("Could not add new modes!");
00066 }
00067
00068 void Implements(char* List)
00069 {
00070 List[I_OnWhois] = 1;
00071 }
00072
00073 virtual ~ModuleBotMode()
00074 {
00075 ServerInstance->Modes->DelMode(bm);
00076 DELETE(bm);
00077 }
00078
00079 virtual Version GetVersion()
00080 {
00081 return Version(1,1,0,0,VF_COMMON|VF_VENDOR,API_VERSION);
00082 }
00083
00084 virtual void OnWhois(userrec* src, userrec* dst)
00085 {
00086 if (dst->IsModeSet('B'))
00087 {
00088 ServerInstance->SendWhoisLine(src, dst, 335, std::string(src->nick)+" "+std::string(dst->nick)+" :is a bot on "+ServerInstance->Config->Network);
00089 }
00090 }
00091
00092 };
00093
00094
00095 MODULE_INIT(ModuleBotMode)