1
0
mirror of https://github.com/anope/anope.git synced 2026-07-06 10:53:14 +02:00

Moved the core pseudo clients out into their own modules

This commit is contained in:
Adam
2011-04-22 03:16:11 -04:00
parent 1782ce260c
commit c8c23158a4
226 changed files with 5187 additions and 4891 deletions
+1 -3
View File
@@ -222,7 +222,7 @@ option(USE_RUN_CC_PL "Use run-cc.pl for building" OFF)
# Use the following directories as includes
# Note that it is important the binary include directory comes before the
# source include directory so the precompiled headers work correctly.
include_directories(${Anope_BINARY_DIR}/include ${Anope_SOURCE_DIR}/include ${Anope_BINARY_DIR}/language)
include_directories(${Anope_BINARY_DIR}/include ${Anope_SOURCE_DIR}/include ${Anope_BINARY_DIR}/language ${Anope_SOURCE_DIR}/modules/core)
# If using Windows, always add the _WIN32 define
if(WIN32)
@@ -337,8 +337,6 @@ check_include_file(sys/eventfd.h HAVE_SYS_EVENTFD_H)
check_function_exists(setgrent HAVE_SETGRENT)
check_function_exists(strcasecmp HAVE_STRCASECMP)
check_function_exists(stricmp HAVE_STRICMP)
check_function_exists(strlcat HAVE_STRLCAT)
check_function_exists(strlcpy HAVE_STRLCPY)
check_function_exists(umask HAVE_UMASK)
check_function_exists(backtrace HAVE_BACKTRACE)
check_function_exists(eventfd HAVE_EVENTFD)
+208 -65
View File
@@ -470,35 +470,6 @@ options
*/
#hidestatso = yes
/*
* If set, Services will send global messages on starting up and shutting
* down/restarting.
*
* This directive is optional.
*/
#globaloncycle = yes
/*
* This is the global message that will be sent when Services are being
* shutdown/restarted. This directive is only required if you enable
* globaloncycle above.
*/
globaloncycledown = "Services are restarting, they will be back shortly - please be good while we're gone"
/*
* This is the global message that will be sent when Services (re)join the
* network. This directive is only required if you enable globaloncycle above.
*/
globaloncycleup = "Services are now back online - have a nice day"
/*
* If set, Services will hide the IRC operator's nick in a global
* message/notice.
*
* This directive is optional.
*/
#anonymousglobal = yes
/*
* Prevents users from registering their nick if they are not connected
* for at least the given number of seconds.
@@ -590,8 +561,8 @@ log
/*
* Target(s) to log to, which may be one of the following:
* - a channel name
* - a filename
* - globops
* - filename
*/
target = "services.log"
/* Log to both services.log and the channel #services */
@@ -668,7 +639,7 @@ log
log
{
target = "globops"
admin = "operserv/global operserv/mode operserv/kick opeserv/akill operserv/s*line operserv/noop operserv/jupe */forbid nickserv/getpass */drop"
admin = "global/* operserv/mode operserv/kick opeserv/akill operserv/s*line operserv/noop operserv/jupe */forbid nickserv/getpass */drop"
}
/*
@@ -690,6 +661,7 @@ log
* chanserv/set - Can modify the settings of any channel (incl. changing of the owner and password!)
* memoserv/info - Can see any information with /memoserv info
* memoserv/set-limit - Can set the limit of max stored memos on any user and channel
* memoserv/no-limit - Can send memos through limits and throttles
* nickserv/auspex - Can see any information with /nickserv info
* nickserv/confirm - Can confirm other users nicknames
* nickserv/drop - Can drop other users nicks
@@ -703,8 +675,8 @@ log
* chanserv/mode
*
* chanserv/saset/bantype chanserv/saset/description chanserv/saset/email chanserv/saset/entrymsg
* chanserv/saset/founder chanserv/saset/keeptopic chanserv/saset/opnotice
* chanserv/saset/peace chanserv/saset/persist chanserv/saset/private chanserv/saset/restricted
* chanserv/saset/founder chanserv/saset/keeptopic chanserv/saset/opnotice chanserv/saset/restricted
* chanserv/saset/peace chanserv/saset/persist chanserv/saset/private
* chanserv/saset/secure chanserv/saset/securefounder chanserv/saset/secureops
* chanserv/saset/signkick chanserv/saset/successor chanserv/saset/topiclock
* chanserv/saset/url chanserv/saset/xop
@@ -720,10 +692,12 @@ log
*
* hostserv/set hostserv/del
*
* operserv/global operserv/news operserv/stats operserv/kick
* global/global
*
* operserv/news operserv/stats operserv/kick
* operserv/mode operserv/session operserv/modlist operserv/ignore
* operserv/chankill operserv/akill operserv/sqline operserv/snline
* operserv/szline operserv/staff operserv/defcon operserv/config
* operserv/szline operserv/staff operserv/config
* operserv/modload operserv/jupe operserv/set operserv/noop
* operserv/quit operserv/update operserv/reload operserv/restart
* operserv/shutdown operserv/svsnick operserv/oline
@@ -767,7 +741,7 @@ opertype
inherits = "Services Operator"
commands = "chanserv/access/list chanserv/drop chanserv/forbid chanserv/getkey chanserv/set/noexpire memoserv/sendall nickserv/saset/* nickserv/getemail operserv/global operserv/news operserv/jupe operserv/svsnick operserv/stats operserv/oline operserv/defcon operserv/noop"
commands = "chanserv/access/list chanserv/drop chanserv/forbid chanserv/getkey chanserv/set/noexpire memoserv/sendall nickserv/saset/* nickserv/getemail operserv/news operserv/jupe operserv/svsnick operserv/stats operserv/oline operserv/noop global/*"
privs = "*"
}
@@ -910,6 +884,13 @@ dns
timeout = 5
}
/*
* [RECOMMENDED] NickServ
*
* Comment the following line to disable NickServ.
*/
module { name = "ns_main" }
/*
* [REQUIRED] NickServ Config
*
@@ -1133,6 +1114,13 @@ nickserv
ajoinmax = 10
}
/*
* [RECOMMENDED] ChanServ
*
* Comment the following line to disable ChanServ.
*/
module { name = "cs_main" }
/*
* [RECOMMENDED] ChanServ Config
*
@@ -1158,7 +1146,7 @@ chanserv
*
* This directive is optional, but highly recommended.
*/
modules = "cs_help cs_register cs_set cs_saset cs_saset_noexpire cs_set_bantype cs_set_description cs_set_entrymsg cs_set_founder cs_set_keeptopic cs_set_opnotice cs_set_peace cs_set_persist cs_set_private cs_set_restricted cs_set_secure cs_set_securefounder cs_set_secureops cs_set_signkick cs_set_successor cs_set_topiclock cs_set_xop cs_xop cs_access cs_akick cs_drop cs_ban cs_clearusers cs_modes cs_getkey cs_invite cs_kick cs_list cs_topic cs_info cs_forbid cs_suspend cs_status cs_unban cs_clone cs_mode"
modules = "cs_help cs_register cs_set cs_saset cs_saset_noexpire cs_set_bantype cs_set_description cs_set_founder cs_set_keeptopic cs_set_opnotice cs_set_peace cs_set_persist cs_set_private cs_set_restricted cs_set_secure cs_set_securefounder cs_set_secureops cs_set_signkick cs_set_successor cs_set_topiclock cs_set_xop cs_xop cs_access cs_akick cs_drop cs_ban cs_clearusers cs_modes cs_getkey cs_invite cs_kick cs_list cs_topic cs_info cs_forbid cs_suspend cs_status cs_unban cs_clone cs_mode"
/*
* The default options for newly registered channels. Note that changing these options
@@ -1276,10 +1264,16 @@ chanserv
}
/*
* [OPTIONAL] MemoServ Config
* [OPTIONAL] MemoServ
*
* This section is used to set up the Memo Service pseudo-client. Unless specified otherwise,
* all directives are required if you wish to use MemoServ.
* Comment the following line to disable MemoServ.
*/
module { name = "ms_main" }
/* [OPTIONAL] MemoServ configuration
*
* This section is used to set up the Memo Service pseudo-client. This is only required if ms_main
* is being loaded.
*/
memoserv
{
@@ -1322,15 +1316,6 @@ memoserv
*/
senddelay = 3s
/*
* Should we notify all appropriate users of a new memo? This applies in cases where a memo is
* sent to a nick which is in the group of another nick. Note that, unlike before, it is currently
* more efficient to enable this.
*
* This directive is optional.
*/
notifyall = yes
/*
* Allow the use of memo receipts for the following groups:
*
@@ -1343,11 +1328,16 @@ memoserv
}
/*
* [OPTIONAL] BotServ Config
* [OPTIONAL] BotServ
*
* This section is used to set up the Bot Service pseudo-client. The block is optional and can be
* removed if you do not wish to have BotServ on your network. Unless specified otherwise,
* all directives are required if you do wish to use BotServ.
* Comment the following line to disable BotServ.
*/
module { name = "bs_main" }
/* [OPTIONAL] BotServ configuration
*
* This section is used to set up the Bot Service pseudo-client. This is only required if ms_main
* is being loaded.
*/
botserv
{
@@ -1442,13 +1432,18 @@ botserv
#fantasycharacter = "!"
}
/*
* [OPTIONAL] HostServ
*
* Comment the following line to disable HostServ.
*/
module { name = "hs_main" }
/*
* [OPTIONAL] HostServ Config
*
* This section is used to set up the vHost Service pseudo-client.
*
* The block is optional and can be removed if you do not wish to have HostServ on your network.
*
* Unless specified otherwise, all directives are required if you do wish to use HostServ.
*/
hostserv
@@ -1473,6 +1468,13 @@ hostserv
modules = "hs_help hs_on hs_off hs_group hs_list hs_set hs_setall hs_del hs_delall"
}
/*
* [RECOMMENDED] OperServ
*
* Comment the following line to disable OperServ.
*/
module { name = "os_main" }
/*
* [RECOMMENDED] OperServ Config
*
@@ -1498,7 +1500,7 @@ operserv
*
* This directive is optional, but highly recommended.
*/
modules = "os_help os_global os_stats os_staff os_mode os_kick os_akill os_snline os_sqline os_szline os_chanlist os_userlist os_news os_session os_noop os_jupe os_ignore os_set os_reload os_update os_restart os_quit os_shutdown os_defcon os_chankill os_svsnick os_oline os_modload os_modunload os_modreload os_modlist os_modinfo os_config os_login"
modules = "os_help os_stats os_staff os_mode os_kick os_akill os_snline os_sqline os_szline os_chanlist os_userlist os_news os_session os_noop os_jupe os_ignore os_set os_reload os_update os_restart os_quit os_shutdown os_chankill os_svsnick os_oline os_modload os_modunload os_modreload os_modlist os_modinfo os_config os_login"
/*
* If set, Services Admins will be able to use SUPERADMIN [ON|OFF] which will temporarily grant
@@ -1650,6 +1652,13 @@ operserv
opersonly = yes
}
/*
* [RECOMMENDED] Global
*
* Comment the following line to disable Global.
*/
module { name = "gl_main" }
/*
* [RECOMMENDED] Global Config
*
@@ -1671,6 +1680,43 @@ global
* (real name) of the client.
*/
description = "Global Noticer"
/*
* The core modules to load for OperServ. This is a space separated list that corresponds
* to the base names of the modules for OperServ.
*
* This directive is optional, but highly recommended.
*/
modules = "gl_help gl_global"
/*
* If set, Services will send global messages on starting up and shutting
* down/restarting.
*
* This directive is optional.
*/
#globaloncycle = yes
/*
* This is the global message that will be sent when Services are being
* shutdown/restarted. This directive is only required if you enable
* globaloncycle above.
*/
globaloncycledown = "Services are restarting, they will be back shortly - please be good while we're gone"
/*
* This is the global message that will be sent when Services (re)join the
* network. This directive is only required if you enable globaloncycle above.
*/
globaloncycleup = "Services are now back online - have a nice day"
/*
* If set, Services will hide the IRC operator's nick in a global
* message/notice.
*
* This directive is optional.
*/
#anonymousglobal = yes
}
/*
@@ -1750,18 +1796,10 @@ defcon
#globalondefcon = yes
/*
* If set, Services will send the global message defined in the message directive on DefCon level
* changes.
* Defines a message that will be sent on DefCon level changes.
*
* This directive is optional.
*/
#globalondefconmore = yes
/*
* Defines the message that will be sent on DefCon level changes when globalondefconmore is set.
*
* This directive is required only when globalondefconmore is set.
*/
#message = "Put your message to send your users here. Dont forget to uncomment globalondefconmore"
/*
@@ -2208,3 +2246,108 @@ ns_set_misc
desc = "Associate an ICQ number with the nick"
}
/*
* os_defcon
*
* Allows you to set services in defcon mode, which can be used to restrict services access
* during bot attacks.
*/
#module { "os_defcon" }
os_defcon
{
/*
* Default DefCon level (1-5) to use when starting Services up. Level 5 constitutes normal operation
* while level 1 constitutes the most restrictive operation. If this setting is left out or set to
* 0, DefCon will be disabled and the rest of this block will be ignored.
*/
#defaultlevel = 5
/*
* The following 4 directives define what operations will take place when DefCon is set to levels
* 1 through 4. Each level is a list that must be separated by spaces.
*
* The following operations can be defined at each level:
* - nonewchannels: Disables registering new channels
* - nonewnicks: Disables registering new nicks
* - nomlockchanges: Disables changing MLOCK on registered channels
* - forcechanmodes: Forces all channels to have the modes given in the later chanmodes directive
* - reducedsessions: Reduces the session limit to the value given in the later sessionlimit directive
* - nonewclients: KILL any new clients trying to connect
* - operonly: Services will ignore all non-IRCops
* - silentoperonly: Services will silently ignore all non-IRCops
* - akillnewclients: AKILL any new clients trying to connect
* - nonewmemos: No new memos will be sent to block MemoServ attacks
*/
level4 = "nonewchannels nonewnicks nomlockchanges reducedsessions"
level3 = "nonewchannels nonewnicks nomlockchanges forcechanmodes reducedsessions"
level2 = "nonewchannels nonewnicks nomlockchanges forcechanmodes reducedsessions silentoperonly"
level1 = "nonewchannels nonewnicks nomlockchanges forcechanmodes reducedsessions silentoperonly akillnewclients"
/*
* New session limit to use when a DefCon level is using "reduced" session limiting.
*/
#sessionlimit = 2
/*
* Length of time to add an AKILL for when DefCon is preventing new clients from connecting to the
* network.
*/
#akillexpire = 5m
/*
* The channel modes to set on all channels when the DefCon channel mode system is in use.
*
* Note 1: Choose these modes carefully, because when DefCon switches to a level which does NOT have
* the mode setting selected, Services will set the reverse on all channels, e.g. if this setting
* is +RN when DefCon is used, all channels will be set to +RN, when DefCon is removed, all
* channels will be set to -RN. You don't want to set this to +k for example, because when DefCon
* is removed all channels with -k.
*
* Note 2: MLOCKed modes will not be lost.
*/
#chanmodes = "+R"
/*
* This value can be used to automatically return the network to DefCon level 5 after the specified
* time period, just in case any IRC Operator forgets to remove a DefCon setting.
*
* This directive is optional.
*/
#timeout = 15m
/*
* If set, Services will send a global message on DefCon level changes.
*
* This directive is optional.
*/
#globalondefcon = yes
/*
* If set, Services will send the global message defined in the message directive on DefCon level
* changes.
*
* This directive is optional.
*/
#globalondefconmore = yes
/*
* Defines the message that will be sent on DefCon level changes when globalondefconmore is set.
*
* This directive is required only when globalondefconmore is set.
*/
#message = "Put your message to send your users here. Dont forget to uncomment globalondefconmore"
/*
* Defines the message that will be sent when DefCon is returned to level 5. This directive is optional,
* and will also override globalondefcon and globalondefconmore when set.
*/
#offmessage = "Services are now back to normal, sorry for any inconvenience"
/*
* Defines the reason to use when clients are KILLed or AKILLed from the network while the proper
* DefCon operation is in effect.
*/
#akillreason = "This network is currently not accepting connections, please try again later"
}
+17
View File
@@ -1,5 +1,22 @@
Anope Version 1.9.5
-------------------
** ADDED CONFIGURATION DIRECTIVES **
global:modules
global:globaloncycle
global:globaloncycledown
global:globaloncycleup
global:anonymousglobal
** MODIFIED CONFIGURATION DIRECTIVES **
opertype:permissions added memoserv/no-limit
operserv:modules removed os_global
** DELETED CONFIGURATION DIRECTIVES **
memoserv:notifyall
options:globaloncycle
options:globaloncycledown
options:globaloncycleup
options:anonymousglobal
Anope Version 1.9.4
-------------------
-31
View File
@@ -116,37 +116,6 @@ Table of Contents
* Christopher N. <saka@epiknet.org> (fr.l)
* Yusuf Kurekci <ysfm.20@gmail.com> (tr.l)
Anope uses the strlcat() and strlcpy() functions from OpenSSH 2.5.1p2.
These functions are copyrighted by Todd C. Miller:
Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the author may not be used to endorse or promote
products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED `AS IS'' AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
2) Presentation
Anope is a set of Services for IRC networks that allows users to manage
+15 -11
View File
@@ -468,7 +468,21 @@ class dynamic_reference : public dynamic_reference_base
this->invalid = false;
this->ref = NULL;
}
return this->ref;
return this->ref != NULL;
}
virtual inline operator T*()
{
if (this->operator bool())
return this->ref;
return NULL;
}
virtual inline T *operator->()
{
if (this->operator bool())
return this->ref;
return NULL;
}
virtual inline void operator=(T *newref)
@@ -484,16 +498,6 @@ class dynamic_reference : public dynamic_reference_base
if (this->ref)
this->ref->AddReference(this);
}
virtual inline T *operator->()
{
return this->ref;
}
virtual inline T *operator*()
{
return this->ref;
}
};
#endif // ANOPE_H
+6
View File
@@ -90,6 +90,12 @@ class CoreExport BotInfo : public User, public Flags<BotFlag, BI_END>
* @param reason The reason we're parting
*/
void Part(Channel *c, const Anope::string &reason = "");
/** Called when a user messages this bot
* @param u The user
* @param message The users' message
*/
virtual void OnMessage(User *u, const Anope::string &message);
};
#endif // BOTS_H
+1 -32
View File
@@ -12,38 +12,9 @@
typedef Anope::insensitive_map<Channel *> channel_map;
extern CoreExport channel_map ChannelList;
struct UserData
{
UserData()
{
Clear();
}
virtual ~UserData() { }
void Clear()
{
last_use = last_start = Anope::CurTime;
lines = times = 0;
lastline.clear();
}
/* Data validity */
time_t last_use;
/* for flood kicker */
int16 lines;
time_t last_start;
/* for repeat kicker */
Anope::string lastline;
int16 times;
};
struct UserContainer
struct UserContainer : public Extensible
{
User *user;
UserData ud;
ChannelStatus *Status;
UserContainer(User *u) : user(u) { }
@@ -93,8 +64,6 @@ class CoreExport Channel : public Extensible, public Flags<ChannelFlag, 3>
Anope::string topic_setter; /* Who set the topic */
time_t topic_time; /* When the topic was set*/
std::list<BanData *> bd;
time_t server_modetime; /* Time of last server MODE */
time_t chanserv_modetime; /* Time of last check_modes() */
int16 server_modecount; /* Number of server MODEs this second */
+18 -38
View File
@@ -167,7 +167,7 @@ template<> class ValueContainer<char **> : public ValueContainerBase
return;
}
*val = new char[s];
strlcpy(*val, newval, s);
memcpy(*val, newval, s);
}
};
@@ -264,7 +264,6 @@ bool ValidateHostServ(ServerConfig *config, const Anope::string &tag, const Anop
bool ValidateLimitSessions(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data);
bool ValidateOperServ(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data);
bool ValidateGlobal(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data);
bool ValidateDefCon(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data);
bool ValidateNickLen(ServerConfig *, const Anope::string &, const Anope::string &, ValueItem &data);
bool ValidateMail(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data);
bool ValidateGlobalOnCycle(ServerConfig *config, const Anope::string &tag, const Anope::string &value, ValueItem &data);
@@ -435,7 +434,7 @@ class CoreExport ServerConfig
/* OperServ name */
Anope::string s_OperServ;
/* Global name */
Anope::string s_GlobalNoticer;
Anope::string s_Global;
/* NickServs realname */
Anope::string desc_NickServ;
/* ChanServ realname */
@@ -447,18 +446,26 @@ class CoreExport ServerConfig
/* OperServ realname */
Anope::string desc_OperServ;
/* Global realname */
Anope::string desc_GlobalNoticer;
Anope::string desc_Global;
/* HostServ Name */
Anope::string s_HostServ;
/* HostServ realname */
Anope::string desc_HostServ;
/* Core HostServ modules */
Anope::string HostCoreModules;
/* Filename for the PID file */
Anope::string PIDFilename;
/* MOTD filename */
Anope::string MOTDFilename;
/* Core MemoServ Modules */
Anope::string MemoCoreModules;
/* Core OperServ Modules */
Anope::string OperCoreModules;
/* Core Global Modules */
Anope::string GlobalCoreModules;
/* True if its ok to not be able to save backs */
bool NoBackupOkay;
/* Do password checking when new people register */
@@ -578,6 +585,8 @@ class CoreExport ServerConfig
bool NSStrictPrivileges;
/* Use email to verify new users registering */
bool NSEmailReg;
/* Core NickServ modules */
Anope::string NickCoreModules;
/* Set the proper channel modes on users when they identify */
bool NSModeOnID;
/* Add the users hostnask their access list when they register */
@@ -585,6 +594,8 @@ class CoreExport ServerConfig
/* Maximum number of channels on AJoin */
unsigned AJoinMax;
/* Core ChanServ modules */
Anope::string ChanCoreModules;
/* Default flags for newly registered channels */
Flags<ChannelInfoFlag, CI_END> CSDefFlags;
/* Max number of channels a user can own */
@@ -621,7 +632,9 @@ class CoreExport ServerConfig
/* Who can use memos reciepts */
unsigned MSMemoReceipt;
/* Defai;t BotServ flags */
/* Core BotServ modules */
Anope::string BotCoreModules;
/* Default BotServ flags */
Flags<BotServFlag> BSDefFlags;
/* How long before botserv forgets a user. This is used for flood kickers etc */
time_t BSKeepData;
@@ -710,39 +723,6 @@ class CoreExport ServerConfig
std::list<Anope::string> EncModuleList;
/* Database modules */
std::list<Anope::string> DBModuleList;
/* HostServ Core Modules */
std::list<Anope::string> HostServCoreModules;
/* MemoServ Core Modules */
std::list<Anope::string> MemoServCoreModules;
/* BotServ Core Modules */
std::list<Anope::string> BotServCoreModules;
/* OperServ Core Modules */
std::list<Anope::string> OperServCoreModules;
/* NickServ Core Modules */
std::list<Anope::string> NickServCoreModules;
/* ChanServ Core Modules */
std::list<Anope::string> ChanServCoreModules;
/* Default defcon level */
int DefConLevel;
/* Timeout before defcon is reset */
time_t DefConTimeOut;
/* Session limiit to use when using defcon */
unsigned DefConSessionLimit;
/* How long to add akills for defcon */
time_t DefConAKILL;
/* Chan modes for defcon */
Anope::string DefConChanModes;
/* Should we global on defcon */
bool GlobalOnDefcon;
/* Should we send DefconMessage aswell? */
bool GlobalOnDefconMore;
/* Message to send when defcon is off */
Anope::string DefConOffMessage;
/* Message to send when defcon is on*/
Anope::string DefconMessage;
/* Reason to akill clients for defcon */
Anope::string DefConAkillReason;
/* The socket engine in use */
Anope::string SocketEngine;
+1 -88
View File
@@ -31,35 +31,15 @@ E void kill_user(const Anope::string &source, User *user, const Anope::string &r
E bool bad_password(User *u);
E void common_unban(ChannelInfo *ci, User *u, bool full = false);
E BotInfo *BotServ;
E BotInfo *ChanServ;
E BotInfo *Global;
E BotInfo *HostServ;
E BotInfo *MemoServ;
E BotInfo *NickServ;
E BotInfo *OperServ;
/**** botserv.c ****/
E void get_botserv_stats(long *nrec, long *memuse);
E void bs_init();
E void botchanmsgs(User *u, ChannelInfo *ci, const Anope::string &buf);
E BotInfo *findbot(const Anope::string &nick);
/** Finds a pseudoclient, given a UID. Useful for TS6 protocol modules.
* @param uid The UID to search for
* @return The pseudoclient structure, or NULL if one could not be found
*/
E Anope::string normalizeBuffer(const Anope::string &);
E void check_ban(ChannelInfo *ci, User *u, int ttbtype);
E void bot_kick(ChannelInfo *ci, User *u, const char *message, ...);
E void bot_raw_ban(User *requester, ChannelInfo *ci, const Anope::string &nick, const Anope::string &reason);
E void bot_raw_kick(User *requester, ChannelInfo *ci, const Anope::string &nick, const Anope::string &reason);
/**** channels.c ****/
E void get_channel_stats(long *nrec, long *memuse);
E Channel *findchan(const Anope::string &chan);
@@ -75,27 +55,14 @@ E void MassChannelModes(BotInfo *bi, const Anope::string &modes);
E void chan_set_correct_modes(User *user, Channel *c, int give_modes);
inline BotInfo *whosends(ChannelInfo *ci)
{
if (!ci || !ci->bi || !ci->c || !ci->botflags.HasFlag(BS_SYMBIOSIS) || !ci->c->FindUser(ci->bi))
return ChanServ ? ChanServ : NickServ;
return ci->bi;
}
/**** chanserv.c ****/
E LevelInfo levelinfo[];
E void get_chanserv_stats(long *nrec, long *memuse);
E void reset_levels(ChannelInfo *ci);
E void cs_init();
E void expire_chans();
E void cs_remove_nick(NickCore *nc);
E void check_modes(Channel *c);
E int check_valid_admin(User *user, Channel *chan, int servermode);
E int check_valid_op(User *user, Channel *chan, int servermode);
E ChannelInfo *cs_findchan(const Anope::string &chan);
E int check_access(User *user, ChannelInfo *ci, int what);
@@ -111,17 +78,11 @@ E Anope::string get_mlock_modes(ChannelInfo *ci, int complete);
E ConfigurationFile services_conf;
E ServerConfig *Config;
/* hostserv.c */
E void do_on_id(User *u);
E void HostServSyncVhosts(NickAlias *na);
/**** encrypt.c ****/
E int enc_encrypt(const Anope::string &src, Anope::string &dest);
E int enc_decrypt(const Anope::string &src, Anope::string &dest);
/**** hostserv.c ****/
E void get_hostserv_stats(long *nrec, long *memuse);
E void hostserv_init();
/**** init.c ****/
@@ -146,9 +107,6 @@ E void PopLanguage();
E const char *anope_gettext(const char *string);
E void SyntaxError(CommandSource &source, const Anope::string &command, const Anope::string &message);
/*** logger.cpp ***/
E void InitLogChannels(ServerConfig *);
/**** main.c ****/
E Anope::string services_dir;
@@ -169,7 +127,6 @@ E time_t start_time;
E ConnectionSocket *UplinkSock;
E void save_databases();
E void expire_all();
E void sighandler(int signum);
E void do_restart_services();
@@ -184,14 +141,6 @@ class CoreExport UplinkSocket : public ConnectionSocket
bool Read(const Anope::string &buf);
};
/**** memoserv.c ****/
E void ms_init();
E void rsend_notify(CommandSource &source, Memo *m, const Anope::string &chan);
E void check_memos(User *u);
E MemoInfo *getmemoinfo(const Anope::string &name, bool &ischan, bool &isforbid);
E void memo_send(CommandSource &source, const Anope::string &name, const Anope::string &text, int z);
/**** messages.cpp ****/
E void init_core_messages();
@@ -225,12 +174,6 @@ E bool OnError(const Anope::string &, const std::vector<Anope::string> &);
E bool IsFile(const Anope::string &filename);
E int toupper(char);
E int tolower(char);
#ifndef HAVE_STRLCPY
E size_t strlcpy(char *, const char *, size_t);
#endif
#ifndef HAVE_STRLCAT
E size_t strlcat(char *, const char *, size_t);
#endif
E time_t dotime(const Anope::string &s);
E Anope::string duration(time_t seconds);
@@ -260,6 +203,7 @@ E std::vector<Anope::string> BuildStringVector(const Anope::string &, char = ' '
E bool str_is_wildcard(const Anope::string &str);
E bool str_is_pure_wildcard(const Anope::string &str);
E Anope::string normalizeBuffer(const Anope::string &);
/**** modes.cpp ****/
/* Number of generic modes we support */
@@ -269,15 +213,9 @@ E void SetDefaultMLock(ServerConfig *config);
/**** nickserv.c ****/
E void get_aliases_stats(long &count, long &mem);
E void get_core_stats(long &count, long &mem);
E void change_core_display(NickCore *nc);
E void change_core_display(NickCore *nc, const Anope::string &newdisplay);
E int do_setmodes(User *u);
E void ns_init();
E int validate_user(User *u);
E void expire_nicks();
E NickAlias *findnick(const Anope::string &nick);
E NickCore *findcore(const Anope::string &nick);
E bool is_on_access(const User *u, const NickCore *nc);
@@ -292,24 +230,6 @@ E void send_cmd(const Anope::string &source, const char *fmt, ...) FORMAT(printf
E void notice_server(const Anope::string &source, const Server *s, const char *fmt, ...) FORMAT(printf, 3, 4);
/**** sessions.c ****/
E std::vector<Exception *> exceptions;
E void get_session_stats(long &count, long &mem);
E void get_exception_stats(long &count, long &mem);
E void add_session(User *u);
E void del_session(User *u);
E void expire_exceptions();
E Session *findsession(const Anope::string &host);
E Exception *find_host_exception(const Anope::string &host);
E Exception *find_hostip_exception(const Anope::string &host, const Anope::string &hostip);
E int exception_add(User *u, const Anope::string &mask, unsigned limit, const Anope::string &reason, const Anope::string &who, time_t expires);
/**** sockets.cpp ****/
E SocketEngineBase *SocketEngine;
@@ -323,8 +243,6 @@ E int32 opcnt;
E uint32 maxusercnt, usercnt;
E time_t maxusertime;
E void get_user_stats(long &count, long &mem);
E User *finduser(const Anope::string &nick);
E User *do_nick(const Anope::string &source, const Anope::string &nick, const Anope::string &username, const Anope::string &host, const Anope::string &server, const Anope::string &realname, time_t ts, const Anope::string &ip, const Anope::string &vhost, const Anope::string &uid, const Anope::string &modes);
@@ -342,9 +260,4 @@ E Anope::string create_mask(User *u);
E void b64_encode(const Anope::string &src, Anope::string &target);
E void b64_decode(const Anope::string &src, Anope::string &target);
#ifdef _WIN32
E Anope::string GetWindowsVersion();
E bool SupportedWindowsVersion();
#endif
#endif /* EXTERN_H */
+1 -1
View File
@@ -39,7 +39,7 @@ class CoreExport Log
std::stringstream buf;
Log(LogType type = LOG_NORMAL, const Anope::string &category = "", BotInfo *bi = Global);
Log(LogType type = LOG_NORMAL, const Anope::string &category = "", BotInfo *bi = NULL);
/* LOG_COMMAND/OVERRIDE/ADMIN */
Log(LogType type, User *u, Command *c, ChannelInfo *ci = NULL);
+25 -50
View File
@@ -314,9 +314,8 @@ class CoreExport Module : public Extensible
virtual void OnUserKicked(Channel *c, User *target, const Anope::string &source, const Anope::string &kickmsg) { }
/** Called when Services' configuration has been loaded.
* @param startup True if Services is starting for the first time, false otherwise.
*/
virtual void OnReload(bool startup) {}
virtual void OnReload() { }
/** Called before a bot is assigned to a channel.
* @param sender The user assigning the bot
@@ -333,20 +332,11 @@ class CoreExport Module : public Extensible
*/
virtual EventReturn OnBotUnAssign(User *sender, ChannelInfo *ci) { return EVENT_CONTINUE; }
/** Called after a user has been introduced, but before any type
* of checking has been done (akills, defcon, s*lines, etc)
* return EVENT_STOP here to allow the user to get by untouched,
* or kill them then return EVENT_STOP to tell Anope the user no
* longer exists
* @param u The user
* @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to stop processing
*/
virtual EventReturn OnPreUserConnect(User *u) { return EVENT_CONTINUE; }
/** Called when a new user connects to the network.
* @param u The connecting user.
* @param exempt set to true/is true if the user should be excepted from bans etc
*/
virtual void OnUserConnect(User *u) { }
virtual void OnUserConnect(dynamic_reference<User> &u, bool &exempt) { }
/** Called when a new server connects to the network.
* @param s The server that has connected to the network
@@ -523,16 +513,6 @@ class CoreExport Module : public Extensible
*/
virtual void OnServerDisconnect() { }
/** Called before the database expire routines are called
* Note: Code that is in seperate expiry routines should just be done
* when we save the DB, theres no need to have both
*/
virtual void OnPreDatabaseExpire() { }
/** Called when the database expire routines are called
*/
virtual void OnDatabaseExpire() { }
/** Called when the flatfile dbs are being written
* @param Write A callback to the function used to insert a line into the database
*/
@@ -639,11 +619,10 @@ class CoreExport Module : public Extensible
virtual void OnDefconLevel(int level) { }
/** Called before an akill is added
* @param u The user adding the akill
* @param ak The akill
* @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to halt the command and not process it
*/
virtual EventReturn OnAddAkill(User *u, XLine *ak) { return EVENT_CONTINUE; }
virtual EventReturn OnAddAkill(XLine *ak) { return EVENT_CONTINUE; }
/** Called before an akill is deleted
* @param u The user removing the akill
@@ -652,11 +631,10 @@ class CoreExport Module : public Extensible
virtual void OnDelAkill(User *u, XLine *ak) { }
/** Called after an exception has been added
* @param u The user who added it
* @param ex The exception
* @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to halt the command and not process it
*/
virtual EventReturn OnExceptionAdd(User *u, Exception *ex) { return EVENT_CONTINUE; }
virtual EventReturn OnExceptionAdd(Exception *ex) { return EVENT_CONTINUE; }
/** Called before an exception is deleted
* @param u The user who is deleting it
@@ -665,12 +643,11 @@ class CoreExport Module : public Extensible
virtual void OnExceptionDel(User *u, Exception *ex) { }
/** Called before a XLine is added
* @param u The user adding the XLine
* @param sx The XLine
* @param Type The type of XLine this is
* @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to halt the command and not process it
*/
virtual EventReturn OnAddXLine(User *u, XLine *x, XLineType Type) { return EVENT_CONTINUE; }
virtual EventReturn OnAddXLine(XLine *x, XLineType Type) { return EVENT_CONTINUE; }
/** Called before a XLine is deleted
* @param u The user deleting the XLine
@@ -932,12 +909,22 @@ class CoreExport Module : public Extensible
*/
virtual EventReturn OnCheckAuthentication(User *u, Command *c, const std::vector<Anope::string> &params, const Anope::string &account, const Anope::string &password) { return EVENT_CONTINUE; }
/** Called when a user does /ns update
* @param u The user
*/
virtual void OnNickUpdate(User *u) { }
/** Called when we get informed about a users SSL fingerprint
* when we call this, the fingerprint should already be stored in the user struct
* @param u pointer to the user
*/
virtual void OnFingerprint(User *u) { }
/** Called when a user becomes (un)away
* @param message The message, is .empty() if unaway
*/
virtual void OnUserAway(User *u, const Anope::string &message) { }
/** Called when a vhost is deleted
* @param na The nickalias of the vhost
*/
@@ -949,18 +936,12 @@ class CoreExport Module : public Extensible
virtual void OnSetVhost(NickAlias *na) { }
/** Called when a memo is sent
* @param u The user sending the memo
* @param nc The nickcore of who the memo was sent to
* @param source The source of the memo
* @param target The target of the memo
* @param mi Memo info for target
* @param m The memo
*/
virtual void OnMemoSend(User *u, NickCore *nc, Memo *m) { }
/** Called when a memo is sent
* @param u The user sending the memo
* @param ci The channel the memo was sent to
* @param m The memo
*/
virtual void OnMemoSend(User *u, ChannelInfo *ci, Memo *m) { }
virtual void OnMemoSend(const Anope::string &source, const Anope::string &target, MemoInfo *mi, Memo *m) { }
/** Called when a memo is deleted
* @param nc The nickcore of the memo being deleted
@@ -1064,10 +1045,8 @@ class CoreExport Module : public Extensible
* @param u The source of the message
* @param ci The channel
* @param msg The message
* @param Allow set to false to make the flood kickers halt
* @return MOD_STOP to stop processing completely
*/
virtual EventReturn OnPrivmsg(User *u, ChannelInfo *ci, Anope::string &msg, bool &Allow) { return EVENT_CONTINUE; }
virtual void OnPrivmsg(User *u, ChannelInfo *ci, Anope::string &msg) { }
/** Called when any object is destroyed
* @param b The object
@@ -1087,6 +1066,7 @@ enum Implementation
I_OnNickClearAccess, I_OnNickAddAccess, I_OnNickEraseAccess,
I_OnNickClearCert, I_OnNickAddCert, I_OnNickEraseCert,
I_OnNickInfo, I_OnFindNick, I_OnFindCore, I_OnCheckAuthentication,
I_OnNickUpdate,
/* ChanServ */
I_OnChanForbidden, I_OnChanSuspend, I_OnChanDrop, I_OnPreChanExpire, I_OnChanExpire, I_OnAccessAdd, I_OnAccessChange,
@@ -1105,8 +1085,8 @@ enum Implementation
I_OnMemoSend, I_OnMemoDel,
/* Users */
I_OnPreUserConnect, I_OnUserConnect, I_OnUserNickChange, I_OnUserQuit, I_OnUserLogoff, I_OnPreJoinChannel,
I_OnJoinChannel, I_OnPrePartChannel, I_OnPartChannel, I_OnFingerprint,
I_OnUserConnect, I_OnUserNickChange, I_OnUserQuit, I_OnUserLogoff, I_OnPreJoinChannel,
I_OnJoinChannel, I_OnPrePartChannel, I_OnPartChannel, I_OnFingerprint, I_OnUserAway,
/* OperServ */
I_OnDefconLevel, I_OnAddAkill, I_OnDelAkill, I_OnExceptionAdd, I_OnExceptionDel,
@@ -1114,7 +1094,6 @@ enum Implementation
/* Database */
I_OnPostLoadDatabases, I_OnSaveDatabase, I_OnLoadDatabase,
I_OnDatabaseExpire,
I_OnDatabaseWrite, I_OnDatabaseRead, I_OnDatabaseReadMetadata, I_OnDatabaseWriteMetadata,
/* Modules */
@@ -1122,7 +1101,7 @@ enum Implementation
/* Other */
I_OnReload, I_OnPreServerConnect, I_OnNewServer, I_OnServerConnect, I_OnPreUplinkSync, I_OnServerDisconnect, I_OnPreCommandRun,
I_OnPreCommand, I_OnPostCommand, I_OnPreDatabaseExpire, I_OnPreRestart, I_OnRestart, I_OnPreShutdown, I_OnShutdown, I_OnSignal,
I_OnPreCommand, I_OnPostCommand, I_OnPreRestart, I_OnRestart, I_OnPreShutdown, I_OnShutdown, I_OnSignal,
I_OnServerQuit, I_OnTopicUpdated,
I_OnEncrypt, I_OnDecrypt,
I_OnChannelModeSet, I_OnChannelModeUnset, I_OnUserModeSet, I_OnUserModeUnset, I_OnChannelModeAdd, I_OnUserModeAdd,
@@ -1293,10 +1272,6 @@ class service_reference : public dynamic_reference<T>
{
}
virtual ~service_reference()
{
}
operator bool()
{
if (this->invalid)
+9 -28
View File
@@ -6,15 +6,10 @@
* Please read COPYING and README for further details.
*/
#ifndef OPERSERV_H
#define OPERSERV_H
#ifndef OPER_H
#define OPER_H
extern CoreExport std::vector<NewsItem *> News;
extern CoreExport std::vector<std::bitset<32> > DefCon;
extern CoreExport bool DefConModesSet;
extern CoreExport Flags<ChannelModeName, CMODE_END * 2> DefConModesOn;
extern CoreExport Flags<ChannelModeName, CMODE_END * 2> DefConModesOff;
extern CoreExport std::map<ChannelModeName, Anope::string> DefConModesOnParams;
class XLineManager;
extern CoreExport XLineManager *SGLine;
@@ -22,19 +17,6 @@ extern CoreExport XLineManager *SZLine;
extern CoreExport XLineManager *SQLine;
extern CoreExport XLineManager *SNLine;
extern CoreExport bool SetDefConParam(ChannelModeName, const Anope::string &);
extern CoreExport bool GetDefConParam(ChannelModeName, Anope::string &);
extern CoreExport void UnsetDefConParam(ChannelModeName);
extern CoreExport bool CheckDefCon(DefconLevel Level);
extern CoreExport bool CheckDefCon(int level, DefconLevel Level);
extern CoreExport void AddDefCon(int level, DefconLevel Level);
extern CoreExport void DelDefCon(int level, DefconLevel Level);
extern CoreExport void os_init();
extern CoreExport void oper_global(const Anope::string &nick, const char *fmt, ...);
extern CoreExport void server_global(const Server *s, const Anope::string &message);
enum XLineType
{
X_SNLINE,
@@ -129,14 +111,13 @@ class CoreExport XLineManager
void Clear();
/** Add an entry to this XLine Manager
* @param bi The bot error replies should be sent from
* @param u The user adding the XLine
* @param mask The mask of the XLine
* @param creator The creator of the XLine
* @param expires When this should expire
* @param reaosn The reason
* @return A pointer to the XLine
*/
virtual XLine *Add(BotInfo *bi, User *u, const Anope::string &mask, time_t expires, const Anope::string &reason);
virtual XLine *Add(const Anope::string &mask, const Anope::string &creator, time_t expires, const Anope::string &reason);
private:
/** Delete an XLine, eg, remove it from the IRCd.
@@ -190,7 +171,7 @@ class CoreExport XLineManager
class SGLineManager : public XLineManager
{
public:
XLine *Add(BotInfo *bi, User *u, const Anope::string &mask, time_t expires, const Anope::string &reason);
XLine *Add(const Anope::string &mask, const Anope::string &creator, time_t expires, const Anope::string &reason);
void Del(XLine *x);
@@ -204,7 +185,7 @@ class SGLineManager : public XLineManager
class SNLineManager : public XLineManager
{
public:
XLine *Add(BotInfo *bi, User *u, const Anope::string &mask, time_t expires, const Anope::string &reason);
XLine *Add(const Anope::string &mask, const Anope::string &creator, time_t expires, const Anope::string &reason);
void Del(XLine *x);
@@ -220,7 +201,7 @@ class SNLineManager : public XLineManager
class SQLineManager : public XLineManager
{
public:
XLine *Add(BotInfo *bi, User *u, const Anope::string &mask, time_t expires, const Anope::string &reason);
XLine *Add(const Anope::string &mask, const Anope::string &creator, time_t expires, const Anope::string &reason);
void Del(XLine *x);
@@ -236,7 +217,7 @@ class SQLineManager : public XLineManager
class SZLineManager : public XLineManager
{
public:
XLine *Add(BotInfo *bi, User *u, const Anope::string &mask, time_t expires, const Anope::string &reason);
XLine *Add(const Anope::string &mask, const Anope::string &creator, time_t expires, const Anope::string &reason);
void Del(XLine *x);
@@ -247,4 +228,4 @@ class SZLineManager : public XLineManager
void Send(User *u, XLine *x);
};
#endif // OPERSERV_H
#endif // OPER_H
+5
View File
@@ -175,6 +175,11 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag,
int16 floodlines, floodsecs; /* For FLOOD kicker */
int16 repeattimes; /* For REPEAT kicker */
/** Find which bot should send mode/topic/etc changes for this channel
* @return The bot
*/
BotInfo *WhoSends();
/** Add an entry to the channel access list
*
* @param mask The mask of the access entry
+21 -49
View File
@@ -272,6 +272,7 @@ template<typename T, size_t Size = 32> class Flags
const Anope::string *Flag_Strings;
public:
Flags() : Flag_Strings(NULL) { }
Flags(const Anope::string *flag_strings) : Flag_Strings(flag_strings) { }
/** Add a flag to this item
@@ -409,7 +410,6 @@ class ChannelInfo;
class Channel;
class Server;
class Entry;
struct Session;
#include "threadengine.h"
#include "opertype.h"
@@ -454,13 +454,11 @@ enum MemoFlag
/* Memo is unread */
MF_UNREAD,
/* Sender requests a receipt */
MF_RECEIPT,
/* Memo is a notification of receipt */
MF_NOTIFYS
MF_RECEIPT
};
const Anope::string MemoFlagStrings[] = {
"MF_UNREAD", "MF_RECEIPT", "MF_NOTIFYS", ""
"MF_UNREAD", "MF_RECEIPT", ""
};
/* Memo info structures. Since both nicknames and channels can have memos,
@@ -486,6 +484,23 @@ struct CoreExport MemoInfo
bool HasIgnore(User *u);
};
struct Session
{
Anope::string host; /* Host of the session */
unsigned count; /* Number of clients with this host */
unsigned hits; /* Number of subsequent kills for a host */
};
struct Exception
{
Anope::string mask; /* Hosts to which this exception applies */
unsigned limit; /* Session limit for exception */
Anope::string who; /* Nick of person who added the exception */
Anope::string reason; /* Reason for exception's addition */
time_t time; /* When this exception was added */
time_t expires; /* Time when it expires. 0 == no expiry */
};
/*************************************************************************/
class CoreExport HostInfo
@@ -703,13 +718,6 @@ enum
#include "account.h"
#include "bots.h"
struct BanData
{
Anope::string mask; /* Since a nick is unsure and a User structure is unsafe */
time_t last_use; /* Since time is the only way to check whether it's still useful */
int16 ttb[TTB_SIZE];
};
struct LevelInfo
{
int what;
@@ -801,43 +809,7 @@ struct MailInfo
/*************************************************************************/
struct Exception
{
Anope::string mask; /* Hosts to which this exception applies */
unsigned limit; /* Session limit for exception */
Anope::string who; /* Nick of person who added the exception */
Anope::string reason; /* Reason for exception's addition */
time_t time; /* When this exception was added */
time_t expires; /* Time when it expires. 0 == no expiry */
};
/*************************************************************************/
extern CoreExport Anope::map<Session *> SessionList;
struct Session
{
Anope::string host;
unsigned count; /* Number of clients with this host */
unsigned hits; /* Number of subsequent kills for a host */
};
/*************************************************************************/
/* Defcon */
enum DefconLevel
{
DEFCON_NO_NEW_CHANNELS,
DEFCON_NO_NEW_NICKS,
DEFCON_NO_MLOCK_CHANGE,
DEFCON_FORCE_CHAN_MODES,
DEFCON_REDUCE_SESSION,
DEFCON_NO_NEW_CLIENTS,
DEFCON_OPER_ONLY,
DEFCON_SILENT_OPER_ONLY,
DEFCON_AKILL_NEW_CLIENTS,
DEFCON_NO_NEW_MEMOS
};
/*************************************************************************/
@@ -863,7 +835,7 @@ class ConfigurationFile;
#include "extern.h"
#include "language.h"
#include "operserv.h"
#include "oper.h"
#include "mail.h"
#include "servers.h"
#include "logger.h"
-2
View File
@@ -12,8 +12,6 @@
#cmakedefine HAVE_STRCASECMP 1
#cmakedefine HAVE_STRICMP 1
#cmakedefine HAVE_STRINGS_H 1
#cmakedefine HAVE_STRLCAT 1
#cmakedefine HAVE_STRLCPY 1
#cmakedefine HAVE_UMASK 1
#cmakedefine HAVE_EVENTFD 1
#cmakedefine GETTEXT_FOUND 1
+65
View File
@@ -0,0 +1,65 @@
#ifndef BOTSERV_H
#define BOTSERV_H
struct UserData
{
UserData()
{
this->Clear();
}
void Clear()
{
last_use = last_start = Anope::CurTime;
lines = times = 0;
lastline.clear();
}
/* Data validity */
time_t last_use;
/* for flood kicker */
int16 lines;
time_t last_start;
/* for repeat kicker */
Anope::string lastline;
Anope::string lasttarget;
int16 times;
};
struct BanData
{
Anope::string mask;
time_t last_use;
int16 ttb[TTB_SIZE];
BanData()
{
this->Clear();
}
void Clear()
{
last_use = 0;
for (int i = 0; i < TTB_SIZE; ++i)
this->ttb[i] = 0;
}
};
class BotServService : public Service
{
public:
BotServService(Module *m) : Service(m, "BotServ") { }
virtual BotInfo *Bot() = 0;
virtual UserData *GetUserData(User *u, Channel *c) = 0;
virtual BanData *GetBanData(User *u, Channel *c) = 0;
};
static service_reference<BotServService> botserv("BotServ");
#endif // BOTSERV_H
+6 -2
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "botserv.h"
class CommandBSAct : public Command
{
@@ -35,7 +36,7 @@ class CommandBSAct : public Command
if (!ci->bi)
{
source.Reply(_(BOT_NOT_ASSIGNED), Config->UseStrictPrivMsgString.c_str(), BotServ->nick.c_str());
source.Reply(_(BOT_NOT_ASSIGNED), Config->UseStrictPrivMsgString.c_str(), Config->s_BotServ.c_str());
return MOD_CONT;
}
@@ -83,7 +84,10 @@ class BSAct : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(BotServ, &commandbsact);
if (!botserv)
throw ModuleException("BotServ is not loaded!");
this->AddCommand(botserv->Bot(), &commandbsact);
}
};
+5 -1
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "botserv.h"
class CommandBSAssign : public Command
{
@@ -93,7 +94,10 @@ class BSAssign : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(BotServ, &commandbsassign);
if (!botserv)
throw ModuleException("BotServ is not loaded!");
this->AddCommand(botserv->Bot(), &commandbsassign);
}
};
+6 -2
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "botserv.h"
class BadwordsListCallback : public NumberList
{
@@ -291,7 +292,7 @@ class CommandBSBadwords : public Command
"will be done if a user says a word that ends with\n"
"\037word\037. If you don't specify anything, a kick will\n"
"be issued every time \037word\037 is said by a user.\n"
" \n"), Config->UseStrictPrivMsgString.c_str(), BotServ->nick.c_str());
" \n"), Config->UseStrictPrivMsgString.c_str(), Config->s_BotServ.c_str());
source.Reply(_("The \002BADWORDS DEL\002 command removes the given word from the\n"
"bad words list. If a list of entry numbers is given, those\n"
"entries are deleted. (See the example for LIST below.)\n"
@@ -325,7 +326,10 @@ class BSBadwords : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(BotServ, &commandbsbadwords);
if (!botserv)
throw ModuleException("BotServ is not loaded!");
this->AddCommand(botserv->Bot(), &commandbsbadwords);
}
};
+5 -1
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "botserv.h"
class CommandBSBot : public Command
{
@@ -423,7 +424,10 @@ class BSBot : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(BotServ, &commandbsbot);
if (!botserv)
throw ModuleException("BotServ is not loaded!");
this->AddCommand(botserv->Bot(), &commandbsbot);
}
};
+5 -1
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "botserv.h"
class CommandBSBotList : public Command
{
@@ -83,7 +84,10 @@ class BSBotList : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(BotServ, &commandbsbotlist);
if (!botserv)
throw ModuleException("BotServ is not loaded!");
this->AddCommand(botserv->Bot(), &commandbsbotlist);
}
};
+9 -5
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "botserv.h"
class CommandBSHelp : public Command
{
@@ -25,7 +26,7 @@ class CommandBSHelp : public Command
CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> &params)
{
mod_help_cmd(BotServ, source.u, NULL, params[0]);
mod_help_cmd(botserv->Bot(), source.u, NULL, params[0]);
return MOD_CONT;
}
@@ -40,9 +41,9 @@ class CommandBSHelp : public Command
"below; to use them, type \002%s%s \037command\037\002. For\n"
"more information on a specific command, type\n"
"\002%s%s HELP \037command\037\002."),
BotServ->nick.c_str(), Config->UseStrictPrivMsgString.c_str(), BotServ->nick.c_str(),
Config->UseStrictPrivMsgString.c_str(), BotServ->nick.c_str());
for (CommandMap::const_iterator it = BotServ->Commands.begin(), it_end = BotServ->Commands.end(); it != it_end; ++it)
Config->s_BotServ.c_str(), Config->UseStrictPrivMsgString.c_str(), Config->s_BotServ.c_str(),
Config->UseStrictPrivMsgString.c_str(), Config->s_BotServ.c_str());
for (CommandMap::const_iterator it = botserv->Bot()->Commands.begin(), it_end = botserv->Bot()->Commands.end(); it != it_end; ++it)
if (!Config->HidePrivilegedCommands || it->second->permission.empty() || u->HasCommand(it->second->permission))
it->second->OnServHelp(source);
source.Reply(_("Bot will join a channel whenever there is at least\n"
@@ -62,7 +63,10 @@ class BSHelp : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(BotServ, &commandbshelp);
if (!botserv)
throw ModuleException("BotServ is not loaded!");
this->AddCommand(botserv->Bot(), &commandbshelp);
}
};
+6 -2
View File
@@ -13,6 +13,7 @@
/*************************************************************************/
#include "module.h"
#include "botserv.h"
class CommandBSInfo : public Command
{
@@ -227,7 +228,7 @@ class CommandBSInfo : public Command
"If the parameter is a channel, then you'll get information\n"
"such as enabled kickers. If the parameter is a nick,\n"
"you'll get information about a bot, such as creation\n"
"time or number of channels it is on."), NickServ->nick.c_str());
"time or number of channels it is on."), Config->s_NickServ.c_str());
return true;
}
@@ -247,7 +248,10 @@ class BSInfo : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(BotServ, &commandbsinfo);
if (!botserv)
throw ModuleException("BotServ is not loaded!");
this->AddCommand(botserv->Bot(), &commandbsinfo);
}
};
+279 -24
View File
@@ -13,6 +13,7 @@
/*************************************************************************/
#include "module.h"
#include "botserv.h"
class CommandBSKick : public Command
{
@@ -41,7 +42,7 @@ class CommandBSKick : public Command
else if (!check_access(u, ci, CA_SET) && !u->HasPriv("botserv/administration"))
source.Reply(_(ACCESS_DENIED));
else if (!ci->bi)
source.Reply(_(BOT_NOT_ASSIGNED), Config->UseStrictPrivMsgString.c_str(), BotServ->nick.c_str());
source.Reply(_(BOT_NOT_ASSIGNED), Config->UseStrictPrivMsgString.c_str(), Config->s_BotServ.c_str());
else
{
bool override = !check_access(u, ci, CA_SET);
@@ -479,7 +480,7 @@ class CommandBSKick : public Command
"on a specific option.\n"
" \n"
"Note: access to this command is controlled by the\n"
"level SET."), Config->UseStrictPrivMsgString.c_str(), BotServ->nick.c_str());
"level SET."), Config->UseStrictPrivMsgString.c_str(), Config->s_BotServ.c_str());
else if (subcommand.equals_ci("BADWORDS"))
source.Reply(_("Syntax: \002KICK \037#channel\037 BADWORDS {\037ON|OFF\037} [\037ttb\037]\002\n"
"Sets the bad words kicker on or off. When enabled, this\n"
@@ -490,7 +491,7 @@ class CommandBSKick : public Command
"more information.\n"
"ttb is the number of times a user can be kicked\n"
"before it get banned. Don't give ttb to disable\n"
"the ban system once activated."), Config->UseStrictPrivMsgString.c_str(), BotServ->nick.c_str());
"the ban system once activated."), Config->UseStrictPrivMsgString.c_str(), Config->s_BotServ.c_str());
else if (subcommand.equals_ci("BOLDS"))
source.Reply(_("Syntax: \002KICK \037channel\037 BOLDS {\037ON|OFF\037} [\037ttb\037]\002\n"
"Sets the bolds kicker on or off. When enabled, this\n"
@@ -581,47 +582,301 @@ class BSKick : public Module
{
CommandBSKick commandbskick;
void check_ban(ChannelInfo *ci, User *u, int ttbtype)
{
/* Don't ban ulines */
if (u->server->IsULined())
return;
BanData *bd = botserv->GetBanData(u, ci->c);
++bd->ttb[ttbtype];
if (ci->ttb[ttbtype] && bd->ttb[ttbtype] >= ci->ttb[ttbtype])
{
/* Should not use == here because bd->ttb[ttbtype] could possibly be > ci->ttb[ttbtype]
* if the TTB was changed after it was not set (0) before and the user had already been
* kicked a few times. Bug #1056 - Adam */
Anope::string mask;
bd->ttb[ttbtype] = 0;
get_idealban(ci, u, mask);
if (ci->c)
ci->c->SetMode(NULL, CMODE_BAN, mask);
FOREACH_MOD(I_OnBotBan, OnBotBan(u, ci, mask));
}
}
void bot_kick(ChannelInfo *ci, User *u, const char *message, ...)
{
va_list args;
char buf[1024];
if (!ci || !ci->bi || !ci->c || !u || u->server->IsULined())
return;
Anope::string fmt = GetString(u->Account(), message);
va_start(args, message);
if (fmt.empty())
return;
vsnprintf(buf, sizeof(buf), fmt.c_str(), args);
va_end(args);
ci->c->Kick(ci->bi, u, "%s", buf);
}
public:
BSKick(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator)
{
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(BotServ, &commandbskick);
if (!botserv)
throw ModuleException("BotServ is not loaded!");
this->AddCommand(botserv->Bot(), &commandbskick);
ModuleManager::Attach(I_OnPrivmsg, this);
}
EventReturn OnPrivmsg(User *u, ChannelInfo *ci, Anope::string &msg, bool &Allow)
void OnPrivmsg(User *u, ChannelInfo *ci, Anope::string &msg)
{
Anope::string m, ch;
time_t time;
/* Now we can make kicker stuff. We try to order the checks
* from the fastest one to the slowest one, since there's
* no need to process other kickers if a user is kicked before
* the last kicker check.
*
* But FIRST we check whether the user is protected in any
* way.
*/
if (u->GetExtRegular("bs_kick_lastmsg", m) && u->GetExtRegular("bs_kick_lasttime", time) && u->GetExtRegular("bs_kick_lastchan", ch))
bool Allow = true;
if (check_access(u, ci, CA_NOKICK))
Allow = false;
else if (ci->botflags.HasFlag(BS_DONTKICKOPS) && (ci->c->HasUserStatus(u, CMODE_HALFOP) || ci->c->HasUserStatus(u, CMODE_OP) || ci->c->HasUserStatus(u, CMODE_PROTECT) || ci->c->HasUserStatus(u, CMODE_OWNER)))
Allow = false;
else if (ci->botflags.HasFlag(BS_DONTKICKVOICES) && ci->c->HasUserStatus(u, CMODE_VOICE))
Allow = false;
if (Allow)
{
if (time == Anope::CurTime && m == msg && ch != ci->name)
{
for (UChannelList::iterator it = u->chans.begin(); it != u->chans.end();)
{
Channel *c = (*it)->chan;
++it;
Anope::string realbuf = msg;
if (c->ci != NULL && c->ci->botflags.HasFlag(BS_KICK_AMSGS))
/* Bolds kicker */
if (ci->botflags.HasFlag(BS_KICK_BOLDS) && realbuf.find(2) != Anope::string::npos)
{
check_ban(ci, u, TTB_BOLDS);
bot_kick(ci, u, _("Don't use bolds on this channel!"));
return;
}
/* Color kicker */
if (ci->botflags.HasFlag(BS_KICK_COLORS) && realbuf.find(3) != Anope::string::npos)
{
check_ban(ci, u, TTB_COLORS);
bot_kick(ci, u, _("Don't use colors on this channel!"));
return;
}
/* Reverses kicker */
if (ci->botflags.HasFlag(BS_KICK_REVERSES) && realbuf.find(22) != Anope::string::npos)
{
check_ban(ci, u, TTB_REVERSES);
bot_kick(ci, u, _("Don't use reverses on this channel!"));
return;
}
/* Italics kicker */
if (ci->botflags.HasFlag(BS_KICK_ITALICS) && realbuf.find(29) != Anope::string::npos)
{
check_ban(ci, u, TTB_ITALICS);
bot_kick(ci, u, _("Don't use italics on this channel!"));
return;
}
/* Underlines kicker */
if (ci->botflags.HasFlag(BS_KICK_UNDERLINES) && realbuf.find(31) != Anope::string::npos)
{
check_ban(ci, u, TTB_UNDERLINES);
bot_kick(ci, u, _("Don't use underlines on this channel!"));
return;
}
/* Caps kicker */
if (ci->botflags.HasFlag(BS_KICK_CAPS) && realbuf.length() >= ci->capsmin)
{
int i = 0, l = 0;
for (unsigned j = 0, end = realbuf.length(); j < end; ++j)
{
if (isupper(realbuf[j]))
++i;
else if (islower(realbuf[j]))
++l;
}
/* i counts uppercase chars, l counts lowercase chars. Only
* alphabetic chars (so islower || isupper) qualify for the
* percentage of caps to kick for; the rest is ignored. -GD
*/
if ((i || l) && i >= ci->capsmin && i * 100 / (i + l) >= ci->capspercent)
{
check_ban(ci, u, TTB_CAPS);
bot_kick(ci, u, _("Turn caps lock OFF!"));
return;
}
}
/* Bad words kicker */
if (ci->botflags.HasFlag(BS_KICK_BADWORDS))
{
bool mustkick = false;
/* Normalize the buffer */
Anope::string nbuf = normalizeBuffer(realbuf);
for (unsigned i = 0, end = ci->GetBadWordCount(); i < end; ++i)
{
BadWord *bw = ci->GetBadWord(i);
if (bw->type == BW_ANY && ((Config->BSCaseSensitive && nbuf.find(bw->word) != Anope::string::npos) || (!Config->BSCaseSensitive && nbuf.find_ci(bw->word) != Anope::string::npos)))
mustkick = true;
else if (bw->type == BW_SINGLE)
{
check_ban(c->ci, u, TTB_AMSGS);
bot_kick(c->ci, u, _("Don't use AMSGs!"));
size_t len = bw->word.length();
if ((Config->BSCaseSensitive && bw->word.equals_cs(nbuf)) || (!Config->BSCaseSensitive && bw->word.equals_ci(nbuf)))
mustkick = true;
else if (nbuf.find(' ') == len && ((Config->BSCaseSensitive && bw->word.equals_cs(nbuf)) || (!Config->BSCaseSensitive && bw->word.equals_ci(nbuf))))
mustkick = true;
else
{
if (nbuf.rfind(' ') == nbuf.length() - len - 1 && ((Config->BSCaseSensitive && nbuf.find(bw->word) == nbuf.length() - len) || (!Config->BSCaseSensitive && nbuf.find_ci(bw->word) == nbuf.length() - len)))
mustkick = true;
else
{
Anope::string wordbuf = " " + bw->word + " ";
if ((Config->BSCaseSensitive && nbuf.find(wordbuf) != Anope::string::npos) || (!Config->BSCaseSensitive && nbuf.find_ci(wordbuf) != Anope::string::npos))
mustkick = true;
}
}
}
else if (bw->type == BW_START)
{
size_t len = bw->word.length();
if ((Config->BSCaseSensitive && nbuf.substr(0, len).equals_cs(bw->word)) || (!Config->BSCaseSensitive && nbuf.substr(0, len).equals_ci(bw->word)))
mustkick = true;
else
{
Anope::string wordbuf = " " + bw->word;
if ((Config->BSCaseSensitive && nbuf.find(wordbuf) != Anope::string::npos) || (!Config->BSCaseSensitive && nbuf.find_ci(wordbuf) != Anope::string::npos))
mustkick = true;
}
}
else if (bw->type == BW_END)
{
size_t len = bw->word.length();
if ((Config->BSCaseSensitive && nbuf.substr(nbuf.length() - len).equals_cs(bw->word)) || (!Config->BSCaseSensitive && nbuf.substr(nbuf.length() - len).equals_ci(bw->word)))
mustkick = true;
else
{
Anope::string wordbuf = bw->word + " ";
if ((Config->BSCaseSensitive && nbuf.find(wordbuf) != Anope::string::npos) || (!Config->BSCaseSensitive && nbuf.find_ci(wordbuf) != Anope::string::npos))
mustkick = true;
}
}
if (mustkick)
{
check_ban(ci, u, TTB_BADWORDS);
if (Config->BSGentleBWReason)
bot_kick(ci, u, _("Watch your language!"));
else
bot_kick(ci, u, _("Don't use the word \"%s\" on this channel!"), bw->word.c_str());
return;
}
}
return EVENT_CONTINUE;
UserData *ud = NULL;
/* Flood kicker */
if (ci->botflags.HasFlag(BS_KICK_FLOOD))
{
ud = botserv->GetUserData(u, ci->c);
if (ud)
{
if (Anope::CurTime - ud->last_start > ci->floodsecs)
{
ud->last_start = Anope::CurTime;
ud->lines = 0;
}
++ud->lines;
if (ud->lines >= ci->floodlines)
{
check_ban(ci, u, TTB_FLOOD);
bot_kick(ci, u, _("Stop flooding!"));
return;
}
}
}
/* Repeat kicker */
if (ci->botflags.HasFlag(BS_KICK_REPEAT))
{
if (!ud)
ud = botserv->GetUserData(u, ci->c);
if (ud)
{
if (!ud->lastline.empty() && !ud->lastline.equals_ci(realbuf))
{
ud->lastline = realbuf;
ud->times = 0;
}
else
{
if (ud->lastline.empty())
ud->lastline = realbuf;
++ud->times;
}
if (ud->times >= ci->repeattimes)
{
check_ban(ci, u, TTB_REPEAT);
bot_kick(ci, u, _("Stop repeating yourself!"));
return;
}
}
}
if (ud && ud->lastline.equals_ci(realbuf) && !ud->lasttarget.empty() && !ud->lasttarget.equals_ci(ci->name))
{
for (UChannelList::iterator it = u->chans.begin(); it != u->chans.end();)
{
Channel *c = (*it)->chan;
++it;
if (c->ci != NULL && c->ci->botflags.HasFlag(BS_KICK_AMSGS) && !check_access(u, c->ci, CA_NOKICK))
{
check_ban(c->ci, u, TTB_AMSGS);
bot_kick(c->ci, u, _("Don't use AMSGs!"));
}
}
}
if (ud)
ud->lasttarget = ci->name;
}
}
u->Extend("bs_kick_lastmsg", new ExtensibleItemRegular<Anope::string>(msg));
u->Extend("bs_kick_lasttime", new ExtensibleItemRegular<time_t>(Anope::CurTime));
u->Extend("bs_kick_lastchan", new ExtensibleItemRegular<Anope::string>(ci->name));
return EVENT_CONTINUE;
}
};
+265
View File
@@ -0,0 +1,265 @@
/* BotServ core functions
*
* (C) 2003-2011 Anope Team
* Contact us at team@anope.org
*
* Please read COPYING and README for further details.
*
* Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church.
*/
/*************************************************************************/
#include "module.h"
#include "botserv.h"
#include "chanserv.h"
static BotInfo *BotServ = NULL;
class BotServBotInfo : public BotInfo
{
public:
BotServBotInfo(const Anope::string &bnick, const Anope::string &user = "", const Anope::string &bhost = "", const Anope::string &real = "") : BotInfo(bnick, user, bhost, real) { }
void OnMessage(User *u, const Anope::string &message)
{
PushLanguage("anope", u->Account() ? u->Account()->language : "");
spacesepstream sep(message);
Anope::string command, param;
if (sep.GetToken(command) && sep.GetToken(param))
{
Command *c = FindCommand(this, command);
if (c)
{
if (ircdproto->IsChannelValid(param))
{
ChannelInfo *ci = cs_findchan(param);
if (ci)
{
if (ci->HasFlag(CI_FORBIDDEN) && !c->HasFlag(CFLAG_ALLOW_FORBIDDEN))
{
u->SendMessage(this, _(_(CHAN_X_FORBIDDEN)), ci->name.c_str());
Log(LOG_COMMAND, "denied", this) << "Access denied for user " << u->GetMask() << " with command " << command << " because of FORBIDDEN channel " << ci->name;
PopLanguage();
return;
}
else if (ci->HasFlag(CI_SUSPENDED) && !c->HasFlag(CFLAG_ALLOW_SUSPENDED))
{
u->SendMessage(this, _(_(CHAN_X_FORBIDDEN)), ci->name.c_str());
Log(LOG_COMMAND, "denied", this) << "Access denied for user " << u->GetMask() << " with command " << command << " because of SUSPENDED channel " << ci->name;
PopLanguage();
return;
}
}
else if (!c->HasFlag(CFLAG_ALLOW_UNREGISTEREDCHANNEL))
{
u->SendMessage(this, _(_(CHAN_X_NOT_REGISTERED)), param.c_str());
PopLanguage();
return;
}
}
/* A user not giving a channel name for a param that should be a channel */
else
{
u->SendMessage(this, _(CHAN_X_INVALID), param.c_str());
PopLanguage();
return;
}
}
}
PopLanguage();
BotInfo::OnMessage(u, message);
}
};
class MyBotServService : public BotServService
{
public:
MyBotServService(Module *m) : BotServService(m) { }
BotInfo *Bot()
{
return BotServ;
}
UserData *GetUserData(User *u, Channel *c)
{
UserData *ud = NULL;
UserContainer *uc = c->FindUser(u);
if (uc != NULL)
{
if (!uc->GetExtPointer("bs_main_userdata", ud))
{
ud = new UserData();
uc->Extend("bs_main_userdata", new ExtensibleItemPointer<UserData>(ud));
}
}
return ud;
}
BanData *GetBanData(User *u, Channel *c)
{
std::map<Anope::string, BanData> bandatamap;
if (!c->GetExtRegular("bs_main_bandata", bandatamap));
c->Extend("bs_main_bandata", new ExtensibleItemRegular<std::map<Anope::string, BanData> >(bandatamap));
c->GetExtRegular("bs_main_bandata", bandatamap);
BanData *bd = &bandatamap[u->GetMask()];
if (bd->last_use && Anope::CurTime - bd->last_use > Config->BSKeepData)
bd->Clear();
bd->last_use = Anope::CurTime;
return bd;
}
};
class BanDataPurger : public CallBack
{
public:
BanDataPurger(Module *owner) : CallBack(owner, 300, Anope::CurTime, true) { }
void Tick(time_t)
{
Log(LOG_DEBUG) << "bs_main: Running bandata purger";
for (channel_map::iterator it = ChannelList.begin(), it_end = ChannelList.end(); it != it_end; ++it)
{
Channel *c = it->second;
std::map<Anope::string, BanData> bandata;
if (c->GetExtRegular("bs_main_bandata", bandata))
{
for (std::map<Anope::string, BanData>::iterator it2 = bandata.begin(), it2_end = bandata.end(); it2 != it2_end; ++it2)
{
BanData *bd = &it2->second;
if (Anope::CurTime - bd->last_use > Config->BSKeepData)
{
bandata.erase(it2);
continue;
}
}
if (bandata.empty())
c->Shrink("bs_main_bandata");
}
}
}
};
class BotServCore : public Module
{
MyBotServService mybotserv;
BanDataPurger bdpurger;
public:
BotServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator), mybotserv(this), bdpurger(this)
{
this->SetAuthor("Anope");
this->SetType(CORE);
ModuleManager::RegisterService(&this->mybotserv);
BotServ = new BotServBotInfo(Config->s_BotServ, Config->ServiceUser, Config->ServiceHost, Config->desc_BotServ);
BotServ->SetFlag(BI_CORE);
Implementation i[] = { I_OnPrivmsg };
ModuleManager::Attach(i, this, 1);
spacesepstream coreModules(Config->BotCoreModules);
Anope::string module;
while (coreModules.GetToken(module))
ModuleManager::LoadModule(module, NULL);
}
~BotServCore()
{
spacesepstream coreModules(Config->BotCoreModules);
Anope::string module;
while (coreModules.GetToken(module))
{
Module *m = FindModule(module);
if (m != NULL)
ModuleManager::UnloadModule(m, NULL);
}
delete BotServ;
}
void OnPrivmsg(User *u, ChannelInfo *ci, Anope::string &msg)
{
if (!u || !ci || !ci->c || !ci->bi || msg.empty())
return;
/* Answer to ping if needed */
if (msg.substr(0, 6).equals_ci("\1PING ") && msg[msg.length() - 1] == '\1')
{
Anope::string ctcp = msg;
ctcp.erase(ctcp.begin());
ctcp.erase(ctcp.length() - 1);
ircdproto->SendCTCP(ci->bi, u->nick, "%s", ctcp.c_str());
}
bool was_action = false;
Anope::string realbuf = msg;
/* If it's a /me, cut the CTCP part because the ACTION will cause
* problems with the caps or badwords kicker
*/
if (realbuf.substr(0, 8).equals_ci("\1ACTION ") && realbuf[realbuf.length() - 1] == '\1')
{
realbuf.erase(0, 8);
realbuf.erase(realbuf.length() - 1);
was_action = true;
}
if (realbuf.empty())
return;
/* Fantaisist commands */
if (ci->botflags.HasFlag(BS_FANTASY) && realbuf[0] == Config->BSFantasyCharacter[0] && !was_action && chanserv)
{
/* Strip off the fantasy character */
realbuf.erase(realbuf.begin());
size_t space = realbuf.find(' ');
Anope::string command, rest;
if (space == Anope::string::npos)
command = realbuf;
else
{
command = realbuf.substr(0, space);
rest = realbuf.substr(space + 1);
}
if (check_access(u, ci, CA_FANTASIA))
{
Command *cmd = FindCommand(chanserv->Bot(), command);
/* Command exists and can be called by fantasy */
if (cmd && !cmd->HasFlag(CFLAG_DISABLE_FANTASY))
{
Anope::string params = rest;
/* Some commands don't need the channel name added.. eg !help */
if (!cmd->HasFlag(CFLAG_STRIP_CHANNEL))
params = ci->name + " " + params;
params = command + " " + params;
mod_run_cmd(chanserv->Bot(), u, ci, params);
}
FOREACH_MOD(I_OnBotFantasy, OnBotFantasy(command, u, ci, rest));
}
else
{
FOREACH_MOD(I_OnBotNoFantasyAccess, OnBotNoFantasyAccess(command, u, ci, rest));
}
}
}
};
MODULE_INIT(BotServCore)
+6 -2
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "botserv.h"
class CommandBSSay : public Command
{
@@ -36,7 +37,7 @@ class CommandBSSay : public Command
if (!ci->bi)
{
source.Reply(_(BOT_NOT_ASSIGNED), Config->UseStrictPrivMsgString.c_str(), BotServ->nick.c_str());
source.Reply(_(BOT_NOT_ASSIGNED), Config->UseStrictPrivMsgString.c_str(), Config->s_BotServ.c_str());
return MOD_CONT;
}
@@ -85,7 +86,10 @@ class BSSay : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(BotServ, &commandbssay);
if (!botserv)
throw ModuleException("BotServ is not loaded!");
this->AddCommand(botserv->Bot(), &commandbssay);
}
};
+6 -2
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "botserv.h"
class CommandBSSet : public Command
{
@@ -216,7 +217,7 @@ class CommandBSSet : public Command
"Type \002%s%s HELP SET \037option\037\002 for more information\n"
"on a specific option.\n"
"Note: access to this command is controlled by the\n"
"level SET."), Config->UseStrictPrivMsgString.c_str(), BotServ->nick.c_str());
"level SET."), Config->UseStrictPrivMsgString.c_str(), Config->s_BotServ.c_str());
User *u = source.u;
if (u->IsServicesOper())
source.Reply(_("These options are reserved to Services Operators:\n"
@@ -308,7 +309,10 @@ class BSSet : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(BotServ, &commandbsset);
if (!botserv)
throw ModuleException("BotServ is not loaded!");
this->AddCommand(botserv->Bot(), &commandbsset);
}
};
+6 -2
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "botserv.h"
class CommandBSUnassign : public Command
{
@@ -33,7 +34,7 @@ class CommandBSUnassign : public Command
else if (!u->HasPriv("botserv/administration") && !check_access(u, ci, CA_ASSIGN))
source.Reply(_(ACCESS_DENIED));
else if (!ci->bi)
source.Reply(_(BOT_NOT_ASSIGNED), Config->UseStrictPrivMsgString.c_str(), BotServ->nick.c_str());
source.Reply(_(BOT_NOT_ASSIGNED), Config->UseStrictPrivMsgString.c_str(), Config->s_BotServ.c_str());
else if (ci->HasFlag(CI_PERSIST) && !cm)
source.Reply(_("You can not unassign bots while persist is set on the channel."));
else
@@ -75,7 +76,10 @@ class BSUnassign : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(BotServ, &commandbsunassign);
if (!botserv)
throw ModuleException("BotServ is not loaded!");
this->AddCommand(botserv->Bot(), &commandbsunassign);
}
};
+15
View File
@@ -0,0 +1,15 @@
#ifndef CHANSERV_H
#define CHANSERV_H
class ChanServService : public Service
{
public:
ChanServService(Module *m) : Service(m, "ChanServ") { }
virtual BotInfo *Bot() = 0;
};
static service_reference<ChanServService> chanserv("ChanServ");
#endif // CHANSERV_H
+9 -5
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "chanserv.h"
class AccessListCallback : public NumberList
{
@@ -504,7 +505,7 @@ class CommandCSAccess : public Command
" \n"
"The \002ACCESS CLEAR\002 command clears all entries of the\n"
"access list."),
ChanServ->nick.c_str(), Config->UseStrictPrivMsgString.c_str(), ChanServ->nick.c_str());
Config->s_ChanServ.c_str(), Config->UseStrictPrivMsgString.c_str(), Config->s_ChanServ.c_str());
source.Reply(_("\002User access levels\002\n"
" \n"
"By default, the following access levels are defined:\n"
@@ -523,7 +524,7 @@ class CommandCSAccess : public Command
" \n"
"These levels may be changed, or new ones added, using the\n"
"\002LEVELS\002 command; type \002%s%s HELP LEVELS\002 for\n"
"information."), ChanServ->nick.c_str(), Config->UseStrictPrivMsgString.c_str(), ChanServ->nick.c_str());
"information."), Config->s_ChanServ.c_str(), Config->UseStrictPrivMsgString.c_str(), Config->s_ChanServ.c_str());
return true;
}
@@ -746,7 +747,7 @@ class CommandCSLevels : public Command
"\002HELP ACCESS LEVELS\002).\n"
" \n"
"For a list of the features and functions whose levels can be\n"
"set, see \002HELP LEVELS DESC\002."), ChanServ->nick.c_str());
"set, see \002HELP LEVELS DESC\002."), Config->s_ChanServ.c_str());
return true;
}
@@ -767,8 +768,11 @@ class CSAccess : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(ChanServ, &commandcsaccess);
this->AddCommand(ChanServ, &commandcslevels);
if (!chanserv)
throw ModuleException("ChanServ is not loaded!");
this->AddCommand(chanserv->Bot(), &commandcsaccess);
this->AddCommand(chanserv->Bot(), &commandcslevels);
}
};
+7 -3
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "chanserv.h"
/* Split a usermask up into its constitutent parts. Returned strings are
* malloc()'d, and should be free()'d when done with. Returns "*" for
@@ -532,7 +533,7 @@ class CommandCSAKick : public Command
"When akicking a \037registered nick\037 the nickserv account\n"
"will be added to the akick list instead of the mask.\n"
"All users within that nickgroup will then be akicked.\n"),
ChanServ->nick.c_str());
Config->s_ChanServ.c_str());
source.Reply(_(
" \n"
"The \002AKICK DEL\002 command removes the given nick or mask\n"
@@ -552,7 +553,7 @@ class CommandCSAKick : public Command
"AKICK mask.\n"
" \n"
"The \002AKICK CLEAR\002 command clears all entries of the\n"
"akick list."), ChanServ->nick.c_str());
"akick list."), Config->s_ChanServ.c_str());
return true;
}
@@ -572,7 +573,10 @@ class CSAKick : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(ChanServ, &commandcsakick);
if (!chanserv)
throw ModuleException("ChanServ is not loaded!");
this->AddCommand(chanserv->Bot(), &commandcsakick);
}
};
+7 -3
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "chanserv.h"
class CommandCSBan : public Command
{
@@ -67,9 +68,9 @@ class CommandCSBan : public Command
return MOD_CONT;
if (ci->HasFlag(CI_SIGNKICK) || (ci->HasFlag(CI_SIGNKICK_LEVEL) && !check_access(u, ci, CA_SIGNKICK)))
c->Kick(whosends(ci), u2, "%s (%s)", reason.c_str(), u->nick.c_str());
c->Kick(ci->WhoSends(), u2, "%s (%s)", reason.c_str(), u->nick.c_str());
else
c->Kick(whosends(ci), u2, "%s", reason.c_str());
c->Kick(ci->WhoSends(), u2, "%s", reason.c_str());
}
return MOD_CONT;
@@ -102,7 +103,10 @@ class CSBan : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(ChanServ, &commandcsban);
if (!chanserv)
throw ModuleException("ChanServ is not loaded!");
this->AddCommand(chanserv->Bot(), &commandcsban);
}
};
+7 -3
View File
@@ -12,13 +12,14 @@
/*************************************************************************/
#include "module.h"
#include "chanserv.h"
class CommandCSClearUsers : public Command
{
public:
CommandCSClearUsers() : Command("CLEARUSERS", 1, 1)
{
this->SetDesc(_("Tells ChanServ to clear (kick) all users on a channel"));
this->SetDesc(Anope::printf(_("Tells %s to kick all users on a channel"), Config->s_ChanServ.c_str()));
}
CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> &params)
@@ -57,7 +58,7 @@ class CommandCSClearUsers : public Command
"Tells %s to clear (kick) all users certain settings on a channel."
" \n"
"By default, limited to those with founder access on the\n"
"channel."), ChanServ->nick.c_str());
"channel."), Config->s_ChanServ.c_str());
return true;
}
@@ -77,7 +78,10 @@ class CSClearUsers : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(ChanServ, &commandcsclearusers);
if (!chanserv)
throw ModuleException("ChanServ is not loaded!");
this->AddCommand(chanserv->Bot(), &commandcsclearusers);
}
};
+5 -1
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "chanserv.h"
class CommandCSClone : public Command
{
@@ -177,7 +178,10 @@ class CSClone : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(ChanServ, &commandcsclone);
if (!chanserv)
throw ModuleException("ChanServ is not loaded!");
this->AddCommand(chanserv->Bot(), &commandcsclone);
}
};
+5 -3
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "chanserv.h"
class CommandCSDrop : public Command
{
@@ -67,8 +68,6 @@ class CommandCSDrop : public Command
bool override = (ci->HasFlag(CI_SECUREFOUNDER) ? !IsFounder(u, ci) : !check_access(u, ci, CA_FOUNDER));
Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "founder: " << (ci->founder ? ci->founder->display : "none");
if (override)
ircdproto->SendGlobops(ChanServ, "\2%s\2 used DROP on channel \2%s\2", u->nick.c_str(), ci->name.c_str());
delete ci;
@@ -112,7 +111,10 @@ class CSDrop : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(ChanServ, &commandcsdrop);
if (!chanserv)
throw ModuleException("ChanServ is not loaded!");
this->AddCommand(chanserv->Bot(), &commandcsdrop);
}
};
+6 -2
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "chanserv.h"
class CommandCSForbid : public Command
{
@@ -75,7 +76,7 @@ class CommandCSForbid : public Command
if (uc->user->HasMode(UMODE_OPER))
continue;
c->Kick(ChanServ, uc->user, "%s", !reason.empty() ? reason.c_str() : GetString(uc->user->Account(), "This channel has been forbidden.").c_str());
c->Kick(chanserv->Bot(), uc->user, "%s", !reason.empty() ? reason.c_str() : GetString(uc->user->Account(), "This channel has been forbidden.").c_str());
}
}
@@ -121,7 +122,10 @@ class CSForbid : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(ChanServ, &commandcsforbid);
if (!chanserv)
throw ModuleException("ChanServ is not loaded!");
this->AddCommand(chanserv->Bot(), &commandcsforbid);
}
};
+5 -1
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "chanserv.h"
class CommandCSGetKey : public Command
{
@@ -72,7 +73,10 @@ class CSGetKey : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(ChanServ, &commandcsgetkey);
if (!chanserv)
throw ModuleException("ChanServ is not loaded!");
this->AddCommand(chanserv->Bot(), &commandcsgetkey);
}
};
+8 -5
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "chanserv.h"
class CommandCSHelp : public Command
{
@@ -25,7 +26,7 @@ class CommandCSHelp : public Command
CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> &params)
{
mod_help_cmd(ChanServ, source.u, NULL, params[0]);
mod_help_cmd(chanserv->Bot(), source.u, NULL, params[0]);
return MOD_CONT;
}
@@ -40,9 +41,8 @@ class CommandCSHelp : public Command
"commands are listed below; to use them, type\n"
"\002%s%s \037command\037\002. For more information on a\n"
"specific command, type \002%s%s HELP \037command\037\002."),
ChanServ->nick.c_str(), ChanServ->nick.c_str(), Config->UseStrictPrivMsgString.c_str(), ChanServ->nick.c_str(), Config->UseStrictPrivMsgString.c_str(), ChanServ->nick.c_str(),
ChanServ->nick.c_str());
for (CommandMap::const_iterator it = ChanServ->Commands.begin(); it != ChanServ->Commands.end(); ++it)
Config->s_ChanServ.c_str(), Config->s_ChanServ.c_str(), Config->UseStrictPrivMsgString.c_str(), Config->s_ChanServ.c_str(), Config->UseStrictPrivMsgString.c_str(), Config->s_ChanServ.c_str(), Config->s_ChanServ.c_str());
for (CommandMap::const_iterator it = chanserv->Bot()->Commands.begin(); it != chanserv->Bot()->Commands.end(); ++it)
if (!Config->HidePrivilegedCommands || it->second->permission.empty() || u->HasCommand(it->second->permission))
it->second->OnServHelp(source);
if (Config->CSExpire >= 86400)
@@ -67,7 +67,10 @@ class CSHelp : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(ChanServ, &commandcshelp);
if (!chanserv)
throw ModuleException("ChanServ is not loaded!");
this->AddCommand(chanserv->Bot(), &commandcshelp);
}
};
+5 -1
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "chanserv.h"
class CommandCSInfo : public Command
{
@@ -140,7 +141,10 @@ class CSInfo : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(ChanServ, &commandcsinfo);
if (!chanserv)
throw ModuleException("ChanServ is not loaded!");
this->AddCommand(chanserv->Bot(), &commandcsinfo);
}
};
+9 -5
View File
@@ -12,13 +12,14 @@
/*************************************************************************/
#include "module.h"
#include "chanserv.h"
class CommandCSInvite : public Command
{
public:
CommandCSInvite() : Command("INVITE", 1, 3)
{
this->SetDesc(_("Tells ChanServ to invite you into a channel"));
this->SetDesc(Anope::printf(_("Tells %s to invite you into a channel"), Config->s_ChanServ.c_str()));
}
CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> &params)
@@ -62,9 +63,9 @@ class CommandCSInvite : public Command
source.Reply(_("You are already in \002%s\002! "), c->name.c_str());
else
{
ircdproto->SendInvite(whosends(ci), chan, u2->nick);
ircdproto->SendInvite(ci->WhoSends(), chan, u2->nick);
source.Reply(_("\002%s\002 has been invited to \002%s\002."), u2->nick.c_str(), c->name.c_str());
u2->SendMessage(whosends(ci), _("You have been invited to \002%s\002."), c->name.c_str());
u2->SendMessage(ci->WhoSends(), _("You have been invited to \002%s\002."), c->name.c_str());
}
return MOD_CONT;
}
@@ -76,7 +77,7 @@ class CommandCSInvite : public Command
"Tells %s to invite you into the given channel.\n"
" \n"
"By default, limited to AOPs or those with level 5 and above\n"
"on the channel."), ChanServ->nick.c_str());
"on the channel."), Config->s_ChanServ.c_str());
return true;
}
@@ -96,7 +97,10 @@ class CSInvite : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(ChanServ, &commandcsinvite);
if (!chanserv)
throw ModuleException("ChanServ is not loaded!");
this->AddCommand(chanserv->Bot(), &commandcsinvite);
}
};
+7 -3
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "chanserv.h"
class CommandCSKick : public Command
{
@@ -54,9 +55,9 @@ class CommandCSKick : public Command
Log(LOG_COMMAND, u, this, ci) << "for " << u2->nick;
if (ci->HasFlag(CI_SIGNKICK) || (ci->HasFlag(CI_SIGNKICK_LEVEL) && !check_access(u, ci, CA_SIGNKICK)))
ci->c->Kick(whosends(ci), u2, "%s (%s)", reason.c_str(), u->nick.c_str());
ci->c->Kick(ci->WhoSends(), u2, "%s (%s)", reason.c_str(), u->nick.c_str());
else
ci->c->Kick(whosends(ci), u2, "%s", reason.c_str());
ci->c->Kick(ci->WhoSends(), u2, "%s", reason.c_str());
}
return MOD_CONT;
}
@@ -88,7 +89,10 @@ class CSKick : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(ChanServ, &commandcskick);
if (!chanserv)
throw ModuleException("ChanServ is not loaded!");
this->AddCommand(chanserv->Bot(), &commandcskick);
}
};
+5 -2
View File
@@ -12,7 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "hashcomp.h"
#include "chanserv.h"
class CommandCSList : public Command
{
@@ -147,7 +147,10 @@ class CSList : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(ChanServ, &commandcslist);
if (!chanserv)
throw ModuleException("ChanServ is not loaded!");
this->AddCommand(chanserv->Bot(), &commandcslist);
}
};
+256
View File
@@ -0,0 +1,256 @@
/* ChanServ core functions
*
* (C) 2003-2011 Anope Team
* Contact us at team@anope.org
*
* Please read COPYING and README for further details.
*
* Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church.
*/
/*************************************************************************/
#include "module.h"
#include "chanserv.h"
static BotInfo *ChanServ = NULL;
class ChanServBotInfo : public BotInfo
{
public:
ChanServBotInfo(const Anope::string &bnick, const Anope::string &user = "", const Anope::string &bhost = "", const Anope::string &real = "") : BotInfo(bnick, user, bhost, real) { }
void OnMessage(User *u, const Anope::string &message)
{
PushLanguage("anope", u->Account() ? u->Account()->language : "");
if (!u->HasMode(UMODE_OPER) && Config->CSOpersOnly)
{
u->SendMessage(ChanServ, _(ACCESS_DENIED));
PopLanguage();
return;
}
spacesepstream sep(message);
Anope::string command, param;
if (sep.GetToken(command) && sep.GetToken(param))
{
Command *c = FindCommand(this, command);
if (c)
{
if (ircdproto->IsChannelValid(param))
{
ChannelInfo *ci = cs_findchan(param);
if (ci)
{
if (ci->HasFlag(CI_FORBIDDEN) && !c->HasFlag(CFLAG_ALLOW_FORBIDDEN))
{
u->SendMessage(this, _(_(CHAN_X_FORBIDDEN)), ci->name.c_str());
Log(LOG_COMMAND, "denied", this) << "Access denied for user " << u->GetMask() << " with command " << command << " because of FORBIDDEN channel " << ci->name;
PopLanguage();
return;
}
else if (ci->HasFlag(CI_SUSPENDED) && !c->HasFlag(CFLAG_ALLOW_SUSPENDED))
{
u->SendMessage(this, _(_(CHAN_X_FORBIDDEN)), ci->name.c_str());
Log(LOG_COMMAND, "denied", this) << "Access denied for user " << u->GetMask() << " with command " << command << " because of SUSPENDED channel " << ci->name;
PopLanguage();
return;
}
}
else if (!c->HasFlag(CFLAG_ALLOW_UNREGISTEREDCHANNEL))
{
u->SendMessage(this, _(_(CHAN_X_NOT_REGISTERED)), param.c_str());
PopLanguage();
return;
}
}
/* A user not giving a channel name for a param that should be a channel */
else
{
u->SendMessage(this, _(CHAN_X_INVALID), param.c_str());
PopLanguage();
return;
}
}
}
PopLanguage();
BotInfo::OnMessage(u, message);
}
};
class MyChanServService : public ChanServService
{
public:
MyChanServService(Module *m) : ChanServService(m) { }
BotInfo *Bot()
{
return ChanServ;
}
};
class ExpireCallback : public CallBack
{
public:
ExpireCallback(Module *owner) : CallBack(owner, Config->ExpireTimeout, Anope::CurTime, true) { }
void Tick(time_t)
{
if (!Config->CSExpire || noexpire || readonly)
return;
for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(), it_end = RegisteredChannelList.end(); it != it_end; )
{
ChannelInfo *ci = it->second;
++it;
bool expire = false;
if (ci->HasFlag(CI_SUSPENDED))
{
if (Config->CSSuspendExpire && Anope::CurTime - ci->last_used >= Config->CSSuspendExpire)
expire = true;
}
else if (ci->HasFlag(CI_FORBIDDEN))
{
if (Config->CSForbidExpire && Anope::CurTime - ci->last_used >= Config->CSForbidExpire)
expire = true;
}
else if (!ci->c && Anope::CurTime - ci->last_used >= Config->CSExpire)
expire = true;
if (ci->HasFlag(CI_NO_EXPIRE))
expire = false;
if (expire)
{
EventReturn MOD_RESULT;
FOREACH_RESULT(I_OnPreChanExpire, OnPreChanExpire(ci));
if (MOD_RESULT == EVENT_STOP)
continue;
Anope::string extra;
if (ci->HasFlag(CI_FORBIDDEN))
extra = "forbidden ";
else if (ci->HasFlag(CI_SUSPENDED))
extra = "suspended ";
Log(LOG_NORMAL, "chanserv/expire", ChanServ) << "Expiring " << extra << "channel " << ci->name << " (founder: " << (ci->founder ? ci->founder->display : "(none)") << ")";
FOREACH_MOD(I_OnChanExpire, OnChanExpire(ci));
delete ci;
}
}
}
};
class ChanServCore : public Module
{
MyChanServService mychanserv;
ExpireCallback expires;
public:
ChanServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator), mychanserv(this), expires(this)
{
this->SetAuthor("Anope");
this->SetType(CORE);
ModuleManager::RegisterService(&this->mychanserv);
ChanServ = new ChanServBotInfo(Config->s_ChanServ, Config->ServiceUser, Config->ServiceHost, Config->desc_ChanServ);
ChanServ->SetFlag(BI_CORE);
Implementation i[] = { I_OnDelCore, I_OnDelChan };
ModuleManager::Attach(i, this, 2);
spacesepstream coreModules(Config->ChanCoreModules);
Anope::string module;
while (coreModules.GetToken(module))
ModuleManager::LoadModule(module, NULL);
}
~ChanServCore()
{
spacesepstream coreModules(Config->ChanCoreModules);
Anope::string module;
while (coreModules.GetToken(module))
{
Module *m = FindModule(module);
if (m != NULL)
ModuleManager::UnloadModule(m, NULL);
}
delete ChanServ;
}
void OnDelCore(NickCore *nc)
{
// XXX this is slightly inefficient
for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(), it_end = RegisteredChannelList.end(); it != it_end;)
{
ChannelInfo *ci = it->second;
++it;
if (ci->founder == nc)
{
NickCore *newowner = NULL;
if (ci->successor && (ci->successor->IsServicesOper() || !Config->CSMaxReg || ci->successor->channelcount < Config->CSMaxReg))
newowner = ci->successor;
else
{
ChanAccess *highest = NULL;
for (unsigned j = 0; j < ci->GetAccessCount(); ++j)
{
ChanAccess *ca = ci->GetAccess(j);
if (!ca->nc || (!ca->nc->IsServicesOper() && Config->CSMaxReg && ca->nc->channelcount >= Config->CSMaxReg) || (ca->nc == nc))
continue;
if (!highest || ca->level > highest->level)
highest = ca;
}
if (highest)
newowner = highest->nc;
}
if (newowner)
{
Log(LOG_NORMAL, "chanserv/expire") << "Transferring foundership of " << ci->name << " from deleted nick " << nc->display << " to " << newowner->display;
ci->founder = newowner;
ci->successor = NULL;
++newowner->channelcount;
}
else
{
Log(LOG_NORMAL, "chanserv/expire") << "Deleting channel " << ci->name << " owned by deleted nick " << nc->display;
delete ci;
continue;
}
}
if (ci->successor == nc)
ci->successor = NULL;
ChanAccess *access = ci->GetAccess(nc);
if (access)
ci->EraseAccess(access);
for (unsigned j = ci->GetAkickCount(); j > 0; --j)
{
AutoKick *akick = ci->GetAkick(j - 1);
if (akick->HasFlag(AK_ISNICK) && akick->nc == nc)
ci->EraseAkick(j - 1);
}
}
}
void OnDelChan(ChannelInfo *ci)
{
if (ci->c && ci->c->HasMode(CMODE_REGISTERED))
ci->c->RemoveMode(NULL, CMODE_REGISTERED, "", false);
}
};
MODULE_INIT(ChanServCore)
+5 -1
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "chanserv.h"
class CommandCSMode : public Command
{
@@ -366,7 +367,10 @@ class CSMode : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(ChanServ, &commandcsmode);
if (!chanserv)
throw ModuleException("ChanServ is not loaded!");
this->AddCommand(chanserv->Bot(), &commandcsmode);
}
};
+21 -18
View File
@@ -12,7 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "chanserv.h"
class CommandModeBase : public Command
{
@@ -76,7 +76,7 @@ class CommandModeBase : public Command
Log(LOG_COMMAND, u, com, ci) << "for " << u2->nick;
if (notice && ci->HasFlag(notice))
ircdproto->SendMessage(whosends(ci), c->name, "%s command used for %s by %s", com->name.c_str(), u2->nick.c_str(), u->nick.c_str());
ircdproto->SendMessage(ci->WhoSends(), c->name, "%s command used for %s by %s", com->name.c_str(), u2->nick.c_str(), u->nick.c_str());
}
}
@@ -462,10 +462,13 @@ class CSModes : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(ChanServ, &commandcsop);
this->AddCommand(ChanServ, &commandcsdeop);
this->AddCommand(ChanServ, &commandcsvoice);
this->AddCommand(ChanServ, &commandcsdevoice);
if (!chanserv)
throw ModuleException("ChanServ is not loaded!");
this->AddCommand(chanserv->Bot(), &commandcsop);
this->AddCommand(chanserv->Bot(), &commandcsdeop);
this->AddCommand(chanserv->Bot(), &commandcsvoice);
this->AddCommand(chanserv->Bot(), &commandcsdevoice);
if (Me && Me->IsSynced())
OnUplinkSync(NULL);
@@ -478,31 +481,31 @@ class CSModes : public Module
{
if (ModeManager::FindChannelModeByName(CMODE_OWNER))
{
this->AddCommand(ChanServ, &commandcsowner);
this->AddCommand(ChanServ, &commandcsdeowner);
this->AddCommand(chanserv->Bot(), &commandcsowner);
this->AddCommand(chanserv->Bot(), &commandcsdeowner);
}
if (ModeManager::FindChannelModeByName(CMODE_PROTECT))
{
this->AddCommand(ChanServ, &commandcsprotect);
this->AddCommand(ChanServ, &commandcsdeprotect);
this->AddCommand(chanserv->Bot(), &commandcsprotect);
this->AddCommand(chanserv->Bot(), &commandcsdeprotect);
}
if (ModeManager::FindChannelModeByName(CMODE_HALFOP))
{
this->AddCommand(ChanServ, &commandcshalfop);
this->AddCommand(ChanServ, &commandcsdehalfop);
this->AddCommand(chanserv->Bot(), &commandcshalfop);
this->AddCommand(chanserv->Bot(), &commandcsdehalfop);
}
}
void OnServerDisconnect()
{
this->DelCommand(ChanServ, &commandcsowner);
this->DelCommand(ChanServ, &commandcsdeowner);
this->DelCommand(ChanServ, &commandcsprotect);
this->DelCommand(ChanServ, &commandcsdeprotect);
this->DelCommand(ChanServ, &commandcshalfop);
this->DelCommand(ChanServ, &commandcsdehalfop);
this->DelCommand(chanserv->Bot(), &commandcsowner);
this->DelCommand(chanserv->Bot(), &commandcsdeowner);
this->DelCommand(chanserv->Bot(), &commandcsprotect);
this->DelCommand(chanserv->Bot(), &commandcsdeprotect);
this->DelCommand(chanserv->Bot(), &commandcshalfop);
this->DelCommand(chanserv->Bot(), &commandcsdehalfop);
}
};
+6 -2
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "chanserv.h"
class CommandCSRegister : public Command
{
@@ -117,7 +118,7 @@ class CommandCSRegister : public Command
"NOTICE: In order to register a channel, you must have\n"
"first registered your nickname. If you haven't,\n"
"\002%s%s HELP\002 for information on how to do so."),
ChanServ->nick.c_str(), ChanServ->nick.c_str(), Config->UseStrictPrivMsgString.c_str(), ChanServ->nick.c_str(), Config->UseStrictPrivMsgString.c_str(), ChanServ->nick.c_str());
Config->s_ChanServ.c_str(), Config->s_ChanServ.c_str(), Config->UseStrictPrivMsgString.c_str(), Config->s_ChanServ.c_str(), Config->UseStrictPrivMsgString.c_str(), Config->s_ChanServ.c_str());
return true;
}
@@ -137,7 +138,10 @@ class CSRegister : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(ChanServ, &commandcsregister);
if (!chanserv)
throw ModuleException("ChanServ is not loaded!");
this->AddCommand(chanserv->Bot(), &commandcsregister);
}
};
+7 -3
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "chanserv.h"
class CommandCSSASet : public Command
{
@@ -55,7 +56,7 @@ class CommandCSSASet : public Command
for (std::vector<Anope::string>::const_iterator it = params.begin() + 2, it_end = params.end(); it != it_end; ++it)
cmdparams += " " + *it;
Log(LOG_ADMIN, u, this, ci) << params[1] << " " << cmdparams;
mod_run_cmd(ChanServ, u, NULL, c, params[1], cmdparams);
mod_run_cmd(chanserv->Bot(), u, NULL, c, params[1], cmdparams);
}
else
{
@@ -79,7 +80,7 @@ class CommandCSSASet : public Command
for (subcommand_map::iterator it = this->subcommands.begin(), it_end = this->subcommands.end(); it != it_end; ++it)
it->second->OnServHelp(source);
source.Reply(_("Type \002%s%s HELP SASET \037option\037\002 for more information on a\n"
"particular option."), Config->UseStrictPrivMsgString.c_str(), ChanServ->nick.c_str());
"particular option."), Config->UseStrictPrivMsgString.c_str(), Config->s_ChanServ.c_str());
return true;
}
else
@@ -131,7 +132,10 @@ class CSSASet : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(ChanServ, &commandcssaset);
if (!chanserv)
throw ModuleException("ChanServ is not loaded!");
this->AddCommand(chanserv->Bot(), &commandcssaset);
}
};
+6 -2
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "chanserv.h"
class CommandCSSASetNoexpire : public Command
{
@@ -68,14 +69,17 @@ class CSSetNoexpire : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
Command *c = FindCommand(ChanServ, "SASET");
if (!chanserv)
throw ModuleException("ChanServ is not loaded!");
Command *c = FindCommand(chanserv->Bot(), "SASET");
if (c)
c->AddSubcommand(this, &commandcssasetnoexpire);
}
~CSSetNoexpire()
{
Command *c = FindCommand(ChanServ, "SASET");
Command *c = FindCommand(chanserv->Bot(), "SASET");
if (c)
c->DelSubcommand(&commandcssasetnoexpire);
}
+7 -3
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "chanserv.h"
class CommandCSSet : public Command
{
@@ -59,7 +60,7 @@ class CommandCSSet : public Command
Anope::string cmdparams = ci->name;
for (std::vector<Anope::string>::const_iterator it = params.begin() + 2, it_end = params.end(); it != it_end; ++it)
cmdparams += " " + *it;
mod_run_cmd(ChanServ, u, NULL, c, params[1], cmdparams);
mod_run_cmd(chanserv->Bot(), u, NULL, c, params[1], cmdparams);
}
else
{
@@ -83,7 +84,7 @@ class CommandCSSet : public Command
for (subcommand_map::iterator it = this->subcommands.begin(), it_end = this->subcommands.end(); it != it_end; ++it)
it->second->OnServHelp(source);
source.Reply(_("Type \002%s%s HELP SET \037option\037\002 for more information on a\n"
"particular option."), Config->UseStrictPrivMsgString.c_str(), ChanServ->nick.c_str());
"particular option."), Config->UseStrictPrivMsgString.c_str(), Config->s_ChanServ.c_str());
return true;
}
else
@@ -135,7 +136,10 @@ class CSSet : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(ChanServ, &commandcsset);
if (!chanserv)
throw ModuleException("ChanServ is not loaded!");
this->AddCommand(chanserv->Bot(), &commandcsset);
}
};
+8 -4
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "chanserv.h"
class CommandCSSetBanType : public Command
{
@@ -88,22 +89,25 @@ class CSSetBanType : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
Command *c = FindCommand(ChanServ, "SET");
if (!chanserv)
throw ModuleException("ChanServ is not loaded!");
Command *c = FindCommand(chanserv->Bot(), "SET");
if (c)
c->AddSubcommand(this, &commandcssetbantype);
c = FindCommand(ChanServ, "SASET");
c = FindCommand(chanserv->Bot(), "SASET");
if (c)
c->AddSubcommand(this, &commandcssasetbantype);
}
~CSSetBanType()
{
Command *c = FindCommand(ChanServ, "SET");
Command *c = FindCommand(chanserv->Bot(), "SET");
if (c)
c->DelSubcommand(&commandcssetbantype);
c = FindCommand(ChanServ, "SASET");
c = FindCommand(chanserv->Bot(), "SASET");
if (c)
c->DelSubcommand(&commandcssasetbantype);
}
+8 -4
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "chanserv.h"
class CommandCSSetDescription : public Command
{
@@ -75,22 +76,25 @@ class CSSetDescription : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
Command *c = FindCommand(ChanServ, "SET");
if (!chanserv)
throw ModuleException("ChanServ is not loaded!");
Command *c = FindCommand(chanserv->Bot(), "SET");
if (c)
c->AddSubcommand(this, &commandcssetdescription);
c = FindCommand(ChanServ, "SASET");
c = FindCommand(chanserv->Bot(), "SASET");
if (c)
c->AddSubcommand(this, &commandcssasetdescription);
}
~CSSetDescription()
{
Command *c = FindCommand(ChanServ, "SET");
Command *c = FindCommand(chanserv->Bot(), "SET");
if (c)
c->DelSubcommand(&commandcssetdescription);
c = FindCommand(ChanServ, "SASET");
c = FindCommand(chanserv->Bot(), "SASET");
if (c)
c->DelSubcommand(&commandcssasetdescription);
}
+8 -4
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "chanserv.h"
class CommandCSSetFounder : public Command
{
@@ -111,22 +112,25 @@ class CSSetFounder : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
Command *c = FindCommand(ChanServ, "SET");
if (!chanserv)
throw ModuleException("ChanServ is not loaded!");
Command *c = FindCommand(chanserv->Bot(), "SET");
if (c)
c->AddSubcommand(this, &commandcssetfounder);
c = FindCommand(ChanServ, "SASET");
c = FindCommand(chanserv->Bot(), "SASET");
if (c)
c->AddSubcommand(this, &commandcssasetfounder);
}
~CSSetFounder()
{
Command *c = FindCommand(ChanServ, "SET");
Command *c = FindCommand(chanserv->Bot(), "SET");
if (c)
c->DelSubcommand(&commandcssetfounder);
c = FindCommand(ChanServ, "SASET");
c = FindCommand(chanserv->Bot(), "SASET");
if (c)
c->DelSubcommand(&commandcssasetfounder);
}
+9 -5
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "chanserv.h"
class CommandCSSetKeepTopic : public Command
{
@@ -51,7 +52,7 @@ class CommandCSSetKeepTopic : public Command
"channel. When \002topic retention\002 is set, the topic for the\n"
"channel will be remembered by %s even after the\n"
"last user leaves the channel, and will be restored the\n"
"next time the channel is created."), this->name.c_str(), ChanServ->nick.c_str());
"next time the channel is created."), this->name.c_str(), Config->s_ChanServ.c_str());
return true;
}
@@ -85,22 +86,25 @@ class CSSetKeepTopic : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
Command *c = FindCommand(ChanServ, "SET");
if (!chanserv)
throw ModuleException("ChanServ is not loaded!");
Command *c = FindCommand(chanserv->Bot(), "SET");
if (c)
c->AddSubcommand(this, &commandcssetkeeptopic);
c = FindCommand(ChanServ, "SASET");
c = FindCommand(chanserv->Bot(), "SASET");
if (c)
c->AddSubcommand(this, &commandcssasetkeeptopic);
}
~CSSetKeepTopic()
{
Command *c = FindCommand(ChanServ, "SET");
Command *c = FindCommand(chanserv->Bot(), "SET");
if (c)
c->DelSubcommand(&commandcssetkeeptopic);
c = FindCommand(ChanServ, "SASET");
c = FindCommand(chanserv->Bot(), "SASET");
if (c)
c->DelSubcommand(&commandcssasetkeeptopic);
}
+9 -5
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "chanserv.h"
class CommandCSSetOpNotice : public Command
{
@@ -50,7 +51,7 @@ class CommandCSSetOpNotice : public Command
"Enables or disables the \002op-notice\002 option for a channel.\n"
"When \002op-notice\002 is set, %s will send a notice to the\n"
"channel whenever the \002OP\002 or \002DEOP\002 commands are used for a user\n"
"in the channel."), this->name.c_str(), ChanServ->nick.c_str());
"in the channel."), this->name.c_str(), Config->s_ChanServ.c_str());
return true;
}
@@ -84,22 +85,25 @@ class CSSetOpNotice : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
Command *c = FindCommand(ChanServ, "SET");
if (!chanserv)
throw ModuleException("ChanServ is not loaded!");
Command *c = FindCommand(chanserv->Bot(), "SET");
if (c)
c->AddSubcommand(this, &commandcssetopnotice);
c = FindCommand(ChanServ, "SASET");
c = FindCommand(chanserv->Bot(), "SASET");
if (c)
c->AddSubcommand(this, &commandcssasetopnotice);
}
~CSSetOpNotice()
{
Command *c = FindCommand(ChanServ, "SET");
Command *c = FindCommand(chanserv->Bot(), "SET");
if (c)
c->DelSubcommand(&commandcssetopnotice);
c = FindCommand(ChanServ, "SASET");
c = FindCommand(chanserv->Bot(), "SASET");
if (c)
c->DelSubcommand(&commandcssasetopnotice);
}
+9 -5
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "chanserv.h"
class CommandCSSetPeace : public Command
{
@@ -50,7 +51,7 @@ class CommandCSSetPeace : public Command
"Enables or disables the \002peace\002 option for a channel.\n"
"When \002peace\002 is set, a user won't be able to kick,\n"
"ban or remove a channel status of a user that has\n"
"a level superior or equal to his via %s commands."), this->name.c_str(), ChanServ->nick.c_str());
"a level superior or equal to his via %s commands."), this->name.c_str(), Config->s_ChanServ.c_str());
return true;
}
@@ -84,22 +85,25 @@ class CSSetPeace : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
Command *c = FindCommand(ChanServ, "SET");
if (!chanserv)
throw ModuleException("ChanServ is not loaded!");
Command *c = FindCommand(chanserv->Bot(), "SET");
if (c)
c->AddSubcommand(this, &commandcssetpeace);
c = FindCommand(ChanServ, "SASET");
c = FindCommand(chanserv->Bot(), "SASET");
if (c)
c->AddSubcommand(this, &commandcssasetpeace);
}
~CSSetPeace()
{
Command *c = FindCommand(ChanServ, "SET");
Command *c = FindCommand(chanserv->Bot(), "SET");
if (c)
c->DelSubcommand(&commandcssetpeace);
c = FindCommand(ChanServ, "SASET");
c = FindCommand(chanserv->Bot(), "SASET");
if (c)
c->DelSubcommand(&commandcssasetpeace);
}
+12 -8
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "chanserv.h"
class CommandCSSetPersist : public Command
{
@@ -51,9 +52,9 @@ class CommandCSSetPersist : public Command
*/
if (!ci->bi && !cm)
{
ChanServ->Assign(NULL, ci);
if (!ci->c->FindUser(ChanServ))
ChanServ->Join(ci->c);
chanserv->Bot()->Assign(NULL, ci);
if (!ci->c->FindUser(chanserv->Bot()))
chanserv->Bot()->Join(ci->c);
}
/* Set the perm mode */
@@ -90,7 +91,7 @@ class CommandCSSetPersist : public Command
*/
if (!cm && Config->s_BotServ.empty() && ci->bi)
/* Unassign bot */
ChanServ->UnAssign(NULL, ci);
chanserv->Bot()->UnAssign(NULL, ci);
}
source.Reply(_("Channel \002%s\002 is no longer persistant."), ci->name.c_str());
@@ -156,22 +157,25 @@ class CSSetPersist : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
Command *c = FindCommand(ChanServ, "SET");
if (!chanserv)
throw ModuleException("ChanServ is not loaded!");
Command *c = FindCommand(chanserv->Bot(), "SET");
if (c)
c->AddSubcommand(this, &commandcssetpeace);
c = FindCommand(ChanServ, "SASET");
c = FindCommand(chanserv->Bot(), "SASET");
if (c)
c->AddSubcommand(this, &commandcssasetpeace);
}
~CSSetPersist()
{
Command *c = FindCommand(ChanServ, "SET");
Command *c = FindCommand(chanserv->Bot(), "SET");
if (c)
c->DelSubcommand(&commandcssetpeace);
c = FindCommand(ChanServ, "SASET");
c = FindCommand(chanserv->Bot(), "SASET");
if (c)
c->DelSubcommand(&commandcssasetpeace);
}
+9 -5
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "chanserv.h"
class CommandCSSetPrivate : public Command
{
@@ -49,7 +50,7 @@ class CommandCSSetPrivate : public Command
" \n"
"Enables or disables the \002private\002 option for a channel.\n"
"When \002private\002 is set, a \002%s%s LIST\002 will not\n"
"include the channel in any lists."), this->name.c_str(), Config->UseStrictPrivMsgString.c_str(), ChanServ->nick.c_str());
"include the channel in any lists."), this->name.c_str(), Config->UseStrictPrivMsgString.c_str(), Config->s_ChanServ.c_str());
return true;
}
@@ -83,22 +84,25 @@ class CSSetPrivate : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
Command *c = FindCommand(ChanServ, "SET");
if (!chanserv)
throw ModuleException("ChanServ is not loaded!");
Command *c = FindCommand(chanserv->Bot(), "SET");
if (c)
c->AddSubcommand(this, &commandcssetprivate);
c = FindCommand(ChanServ, "SASET");
c = FindCommand(chanserv->Bot(), "SASET");
if (c)
c->AddSubcommand(this, &commandcssasetprivate);
}
~CSSetPrivate()
{
Command *c = FindCommand(ChanServ, "SET");
Command *c = FindCommand(chanserv->Bot(), "SET");
if (c)
c->DelSubcommand(&commandcssetprivate);
c = FindCommand(ChanServ, "SASET");
c = FindCommand(chanserv->Bot(), "SASET");
if (c)
c->DelSubcommand(&commandcssasetprivate);
}
+8 -4
View File
@@ -11,6 +11,7 @@
/*************************************************************************/
#include "module.h"
#include "chanserv.h"
class CommandCSSetRestricted : public Command
{
@@ -86,22 +87,25 @@ class CSSetRestricted : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
Command *c = FindCommand(ChanServ, "SET");
if (!chanserv)
throw ModuleException("ChanServ is not loaded!");
Command *c = FindCommand(chanserv->Bot(), "SET");
if (c)
c->AddSubcommand(this, &commandcssetrestricted);
c = FindCommand(ChanServ, "SASET");
c = FindCommand(chanserv->Bot(), "SASET");
if (c)
c->AddSubcommand(this, &commandcssasetrestricted);
}
~CSSetRestricted()
{
Command *c = FindCommand(ChanServ, "SET");
Command *c = FindCommand(chanserv->Bot(), "SET");
if (c)
c->DelSubcommand(&commandcssetrestricted);
c = FindCommand(ChanServ, "SASET");
c = FindCommand(chanserv->Bot(), "SASET");
if (c)
c->DelSubcommand(&commandcssasetrestricted);
}
+10 -6
View File
@@ -12,13 +12,14 @@
/*************************************************************************/
#include "module.h"
#include "chanserv.h"
class CommandCSSetSecure : public Command
{
public:
CommandCSSetSecure(const Anope::string &cpermission = "") : Command("SECURE", 2, 2, cpermission)
{
this->SetDesc(Anope::printf(_("Activate %s's security features"), ChanServ->nick.c_str()));
this->SetDesc(Anope::printf(_("Activate %s's security features"), Config->s_ChanServ.c_str()));
}
CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> &params)
@@ -51,7 +52,7 @@ class CommandCSSetSecure : public Command
"channel. When \002SECURE\002 is set, only users who have\n"
"registered their nicknames with %s and IDENTIFY'd\n"
"with their password will be given access to the channel\n"
"as controlled by the access list."), this->name.c_str(), NickServ->nick.c_str(), NickServ->nick.c_str());
"as controlled by the access list."), this->name.c_str(), Config->s_NickServ.c_str(), Config->s_NickServ.c_str());
return true;
}
@@ -85,22 +86,25 @@ class CSSetSecure : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
Command *c = FindCommand(ChanServ, "SET");
if (!chanserv)
throw ModuleException("ChanServ is not loaded!");
Command *c = FindCommand(chanserv->Bot(), "SET");
if (c)
c->AddSubcommand(this, &commandcssetsecure);
c = FindCommand(ChanServ, "SASET");
c = FindCommand(chanserv->Bot(), "SASET");
if (c)
c->AddSubcommand(this, &commandcssasetsecure);
}
~CSSetSecure()
{
Command *c = FindCommand(ChanServ, "SET");
Command *c = FindCommand(chanserv->Bot(), "SET");
if (c)
c->DelSubcommand(&commandcssetsecure);
c = FindCommand(ChanServ, "SASET");
c = FindCommand(chanserv->Bot(), "SASET");
if (c)
c->DelSubcommand(&commandcssasetsecure);
}
+8 -4
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "chanserv.h"
class CommandCSSetSecureFounder : public Command
{
@@ -92,22 +93,25 @@ class CSSetSecureFounder : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
Command *c = FindCommand(ChanServ, "SET");
if (!chanserv)
throw ModuleException("ChanServ is not loaded!");
Command *c = FindCommand(chanserv->Bot(), "SET");
if (c)
c->AddSubcommand(this, &commandcssetsecurefounder);
c = FindCommand(ChanServ, "SASET");
c = FindCommand(chanserv->Bot(), "SASET");
if (c)
c->AddSubcommand(this, &commandcssasetsecurefounder);
}
~CSSetSecureFounder()
{
Command *c = FindCommand(ChanServ, "SET");
Command *c = FindCommand(chanserv->Bot(), "SET");
if (c)
c->DelSubcommand(&commandcssetsecurefounder);
c = FindCommand(ChanServ, "SASET");
c = FindCommand(chanserv->Bot(), "SASET");
if (c)
c->DelSubcommand(&commandcssasetsecurefounder);
}
+8 -4
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "chanserv.h"
class CommandCSSetSecureOps : public Command
{
@@ -83,22 +84,25 @@ class CSSetSecureOps : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
Command *c = FindCommand(ChanServ, "SET");
if (!chanserv)
throw ModuleException("ChanServ is not loaded!");
Command *c = FindCommand(chanserv->Bot(), "SET");
if (c)
c->AddSubcommand(this, &commandcssetsecureops);
c = FindCommand(ChanServ, "SASET");
c = FindCommand(chanserv->Bot(), "SASET");
if (c)
c->AddSubcommand(this, &commandcssasetsecureops);
}
~CSSetSecureOps()
{
Command *c = FindCommand(ChanServ, "SET");
Command *c = FindCommand(chanserv->Bot(), "SET");
if (c)
c->DelSubcommand(&commandcssetsecureops);
c = FindCommand(ChanServ, "SASET");
c = FindCommand(chanserv->Bot(), "SASET");
if (c)
c->DelSubcommand(&commandcssasetsecureops);
}
+9 -5
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "chanserv.h"
class CommandCSSetSignKick : public Command
{
@@ -64,7 +65,7 @@ class CommandCSSetSignKick : public Command
"If you use \002LEVEL\002, those who have a level that is superior \n"
"or equal to the SIGNKICK level on the channel won't have their \n"
"kicks signed. See \002%s%s HELP LEVELS\002 for more information."), this->name.c_str(),
ChanServ->nick.c_str(), Config->UseStrictPrivMsgString.c_str(), ChanServ->nick.c_str());
Config->s_ChanServ.c_str(), Config->UseStrictPrivMsgString.c_str(), Config->s_ChanServ.c_str());
return true;
}
@@ -98,22 +99,25 @@ class CSSetSignKick : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
Command *c = FindCommand(ChanServ, "SET");
if (!chanserv)
throw ModuleException("ChanServ is not loaded!");
Command *c = FindCommand(chanserv->Bot(), "SET");
if (c)
c->AddSubcommand(this, &commandcssetsignkick);
c = FindCommand(ChanServ, "SASET");
c = FindCommand(chanserv->Bot(), "SASET");
if (c)
c->AddSubcommand(this, &commandcssasetsignkick);
}
~CSSetSignKick()
{
Command *c = FindCommand(ChanServ, "SET");
Command *c = FindCommand(chanserv->Bot(), "SET");
if (c)
c->DelSubcommand(&commandcssetsignkick);
c = FindCommand(ChanServ, "SASET");
c = FindCommand(chanserv->Bot(), "SASET");
if (c)
c->DelSubcommand(&commandcssasetsignkick);
}
+8 -4
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "chanserv.h"
class CommandCSSetSuccessor : public Command
{
@@ -118,22 +119,25 @@ class CSSetSuccessor : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
Command *c = FindCommand(ChanServ, "SET");
if (!chanserv)
throw ModuleException("ChanServ is not loaded!");
Command *c = FindCommand(chanserv->Bot(), "SET");
if (c)
c->AddSubcommand(this, &commandcssetsuccessor);
c = FindCommand(ChanServ, "SASET");
c = FindCommand(chanserv->Bot(), "SASET");
if (c)
c->AddSubcommand(this, &commandcssasetsuccessor);
}
~CSSetSuccessor()
{
Command *c = FindCommand(ChanServ, "SET");
Command *c = FindCommand(chanserv->Bot(), "SET");
if (c)
c->DelSubcommand(&commandcssetsuccessor);
c = FindCommand(ChanServ, "SASET");
c = FindCommand(chanserv->Bot(), "SASET");
if (c)
c->DelSubcommand(&commandcssasetsuccessor);
}
+9 -5
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "chanserv.h"
class CommandCSSetTopicLock : public Command
{
@@ -50,7 +51,7 @@ class CommandCSSetTopicLock : public Command
"Enables or disables the \002topic lock\002 option for a channel.\n"
"When \002topic lock\002 is set, %s will not allow the\n"
"channel topic to be changed except via the \002TOPIC\002\n"
"command."), this->name.c_str(), ChanServ->nick.c_str());
"command."), this->name.c_str(), Config->s_ChanServ.c_str());
return true;
}
@@ -84,22 +85,25 @@ class CSSetTopicLock : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
Command *c = FindCommand(ChanServ, "SET");
if (!chanserv)
throw ModuleException("ChanServ is not loaded!");
Command *c = FindCommand(chanserv->Bot(), "SET");
if (c)
c->AddSubcommand(this, &commandcssettopiclock);
c = FindCommand(ChanServ, "SASET");
c = FindCommand(chanserv->Bot(), "SASET");
if (c)
c->AddSubcommand(this, &commandcssasettopiclock);
}
~CSSetTopicLock()
{
Command *c = FindCommand(ChanServ, "SET");
Command *c = FindCommand(chanserv->Bot(), "SET");
if (c)
c->DelSubcommand(&commandcssettopiclock);
c = FindCommand(ChanServ, "SASET");
c = FindCommand(chanserv->Bot(), "SASET");
if (c)
c->DelSubcommand(&commandcssasettopiclock);
}
+8 -4
View File
@@ -11,6 +11,7 @@
/*************************************************************************/
#include "module.h"
#include "chanserv.h"
#define CHECKLEV(lev) (ci->levels[(lev)] != ACCESS_INVALID && access->level >= ci->levels[(lev)])
@@ -138,22 +139,25 @@ class CSSetXOP : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
Command *c = FindCommand(ChanServ, "SET");
if (!chanserv)
throw ModuleException("ChanServ is not loaded!");
Command *c = FindCommand(chanserv->Bot(), "SET");
if (c)
c->AddSubcommand(this, &commandcssetxop);
c = FindCommand(ChanServ, "SASET");
c = FindCommand(chanserv->Bot(), "SASET");
if (c)
c->AddSubcommand(this, &commandcssasetxop);
}
~CSSetXOP()
{
Command *c = FindCommand(ChanServ, "SET");
Command *c = FindCommand(chanserv->Bot(), "SET");
if (c)
c->DelSubcommand(&commandcssetxop);
c = FindCommand(ChanServ, "SASET");
c = FindCommand(chanserv->Bot(), "SASET");
if (c)
c->DelSubcommand(&commandcssasetxop);
}
+2 -1
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "chanserv.h"
class CommandCSStatus : public Command
{
@@ -66,7 +67,7 @@ class CSStatus : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(ChanServ, &commandcsstatus);
this->AddCommand(chanserv->Bot(), &commandcsstatus);
}
};
+3 -2
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "chanserv.h"
class CommandCSSuspend : public Command
{
@@ -153,8 +154,8 @@ class CSSuspend : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(ChanServ, &commandcssuspend);
this->AddCommand(ChanServ, &commandcsunsuspend);
this->AddCommand(chanserv->Bot(), &commandcssuspend);
this->AddCommand(chanserv->Bot(), &commandcsunsuspend);
}
};
+3 -2
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "chanserv.h"
class CommandCSTopic : public Command
{
@@ -58,7 +59,7 @@ class CommandCSTopic : public Command
"for more information.\n"
" \n"
"By default, limited to those with founder access on the\n"
"channel."), ChanServ->nick.c_str(), Config->UseStrictPrivMsgString.c_str(), ChanServ->nick.c_str());
"channel."), Config->s_ChanServ.c_str(), Config->UseStrictPrivMsgString.c_str(), Config->s_ChanServ.c_str());
return true;
}
@@ -78,7 +79,7 @@ class CSTopic : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(ChanServ, &commandcstopic);
this->AddCommand(chanserv->Bot(), &commandcstopic);
}
};
+3 -2
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "chanserv.h"
class CommandCSUnban : public Command
{
@@ -66,7 +67,7 @@ class CommandCSUnban : public Command
"user from entering the given channel. \n"
" \n"
"By default, limited to AOPs or those with level 5 and above\n"
"on the channel."), ChanServ->nick.c_str());
"on the channel."), Config->s_ChanServ.c_str());
return true;
}
@@ -86,7 +87,7 @@ class CSUnban : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(ChanServ, &commandcsunban);
this->AddCommand(chanserv->Bot(), &commandcsunban);
}
};
+18 -17
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "chanserv.h"
enum
{
@@ -449,8 +450,8 @@ class CommandCSQOP : public XOPBase
"\002%s%s HELP ACCESS\002 for information about the access list,\n"
"and \002%s%s HELP SET XOP\002 to know how to toggle between \n"
"the access list and xOP list systems."),
Config->UseStrictPrivMsgString.c_str(), ChanServ->nick.c_str(),
Config->UseStrictPrivMsgString.c_str(), ChanServ->nick.c_str());
Config->UseStrictPrivMsgString.c_str(), Config->s_ChanServ.c_str(),
Config->UseStrictPrivMsgString.c_str(), Config->s_ChanServ.c_str());
return true;
}
@@ -513,8 +514,8 @@ class CommandCSAOP : public XOPBase
"\002%s%s HELP ACCESS\002 for information about the access list,\n"
"and \002%s%s HELP SET XOP\002 to know how to toggle between \n"
"the access list and xOP list systems."),
Config->UseStrictPrivMsgString.c_str(), ChanServ->nick.c_str(),
Config->UseStrictPrivMsgString.c_str(), ChanServ->nick.c_str());
Config->UseStrictPrivMsgString.c_str(), Config->s_ChanServ.c_str(),
Config->UseStrictPrivMsgString.c_str(), Config->s_ChanServ.c_str());
return true;
}
@@ -575,8 +576,8 @@ class CommandCSHOP : public XOPBase
"\002%s%s HELP ACCESS\002 for information about the access list,\n"
"and \002%s%s HELP SET XOP\002 to know how to toggle between \n"
"the access list and xOP list systems."),
Config->UseStrictPrivMsgString.c_str(), ChanServ->nick.c_str(),
Config->UseStrictPrivMsgString.c_str(), ChanServ->nick.c_str());
Config->UseStrictPrivMsgString.c_str(), Config->s_ChanServ.c_str(),
Config->UseStrictPrivMsgString.c_str(), Config->s_ChanServ.c_str());
return true;
}
@@ -639,8 +640,8 @@ class CommandCSSOP : public XOPBase
"\002%s%s HELP ACCESS\002 for information about the access list,\n"
"and \002%s%s HELP SET XOP\002 to know how to toggle between \n"
"the access list and xOP list systems."),
Config->UseStrictPrivMsgString.c_str(), ChanServ->nick.c_str(),
Config->UseStrictPrivMsgString.c_str(), ChanServ->nick.c_str());
Config->UseStrictPrivMsgString.c_str(), Config->s_ChanServ.c_str(),
Config->UseStrictPrivMsgString.c_str(), Config->s_ChanServ.c_str());
return true;
}
@@ -702,8 +703,8 @@ class CommandCSVOP : public XOPBase
"\002%s%s HELP ACCESS\002 for information about the access list,\n"
"and \002%s%s HELP SET XOP\002 to know how to toggle between \n"
"the access list and xOP list systems."),
Config->UseStrictPrivMsgString.c_str(), ChanServ->nick.c_str(),
Config->UseStrictPrivMsgString.c_str(), ChanServ->nick.c_str());
Config->UseStrictPrivMsgString.c_str(), Config->s_ChanServ.c_str(),
Config->UseStrictPrivMsgString.c_str(), Config->s_ChanServ.c_str());
return true;
}
@@ -727,9 +728,9 @@ class CSXOP : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(ChanServ, &commandcssop);
this->AddCommand(ChanServ, &commandcsaop);
this->AddCommand(ChanServ, &commandcsvop);
this->AddCommand(chanserv->Bot(), &commandcssop);
this->AddCommand(chanserv->Bot(), &commandcsaop);
this->AddCommand(chanserv->Bot(), &commandcsvop);
if (Me && Me->IsSynced())
OnUplinkSync(NULL);
@@ -741,15 +742,15 @@ class CSXOP : public Module
void OnUplinkSync(Server *)
{
if (ModeManager::FindChannelModeByName(CMODE_OWNER))
this->AddCommand(ChanServ, &commandcsqop);
this->AddCommand(chanserv->Bot(), &commandcsqop);
if (ModeManager::FindChannelModeByName(CMODE_HALFOP))
this->AddCommand(ChanServ, &commandcshop);
this->AddCommand(chanserv->Bot(), &commandcshop);
}
void OnServerDisconnect()
{
this->DelCommand(ChanServ, &commandcsqop);
this->DelCommand(ChanServ, &commandcshop);
this->DelCommand(chanserv->Bot(), &commandcsqop);
this->DelCommand(chanserv->Bot(), &commandcshop);
}
};
+15 -25
View File
@@ -11,9 +11,12 @@
/*************************************************************************/
#include "module.h"
#include "operserv.h"
#include "os_session.h"
Anope::string DatabaseFile;
std::stringstream db_buffer;
service_reference<SessionService> SessionInterface("session");
/** Enum used for what METADATA type we are reading
*/
@@ -317,16 +320,13 @@ static void LoadOperInfo(const std::vector<Anope::string> &params)
XLine *x = NULL;
if (params[0].equals_ci("SNLINE") && SNLine)
x = SNLine->Add(NULL, NULL, mask, expires, reason);
x = SNLine->Add(mask, by, expires, reason);
else if (params[0].equals_ci("SQLINE") && SQLine)
x = SQLine->Add(NULL, NULL, mask, expires, reason);
x = SQLine->Add(mask, by, expires, reason);
else if (params[0].equals_ci("SZLINE") && SZLine)
x = SZLine->Add(NULL, NULL, mask, expires, reason);
x = SZLine->Add(mask, by, expires, reason);
if (x)
{
x->By = by;
x->Created = seton;
}
}
else if (params[0].equals_ci("AKILL") && SGLine)
{
@@ -337,12 +337,9 @@ static void LoadOperInfo(const std::vector<Anope::string> &params)
time_t expires = params[5].is_pos_number_only() ? convertTo<time_t>(params[5]) : 0;
Anope::string reason = params[6];
XLine *x = SGLine->Add(NULL, NULL, user + "@" + host, expires, reason);
XLine *x = SGLine->Add(user + "@" + host, by, expires, reason);
if (x)
{
x->By = by;
x->Created = seton;
}
}
else if (params[0].equals_ci("EXCEPTION"))
{
@@ -353,7 +350,7 @@ static void LoadOperInfo(const std::vector<Anope::string> &params)
exception->time = params[4].is_pos_number_only() ? convertTo<time_t>(params[4]) : 0;
exception->expires = params[5].is_pos_number_only() ? convertTo<time_t>(params[5]) : 0;
exception->reason = params[6];
exceptions.push_back(exception);
SessionInterface->AddException(exception);
}
}
@@ -382,7 +379,7 @@ class DBPlain : public Module
Implementation i[] = { I_OnReload, I_OnDatabaseRead, I_OnLoadDatabase, I_OnDatabaseReadMetadata, I_OnSaveDatabase, I_OnModuleLoad };
ModuleManager::Attach(i, this, 6);
OnReload(true);
OnReload();
LastDay = 0;
}
@@ -412,7 +409,8 @@ class DBPlain : public Module
Log(LOG_DEBUG) << "db_plain: Attemping to rename " << DatabaseFile << " to " << newname;
if (rename(DatabaseFile.c_str(), newname.c_str()))
{
ircdproto->SendGlobops(OperServ, "Unable to backup database!");
if (operserv)
ircdproto->SendGlobops(operserv->Bot(), "Unable to backup database!");
Log() << "Unable to back up database!";
if (!Config->NoBackupOkay)
@@ -432,7 +430,7 @@ class DBPlain : public Module
}
}
void OnReload(bool)
void OnReload()
{
ConfigReader config;
DatabaseFile = config.ReadValue("db_plain", "database", "anope.db", 0);
@@ -494,14 +492,12 @@ class DBPlain : public Module
Memo *m = new Memo;
m->time = params[0].is_pos_number_only() ? convertTo<time_t>(params[0]) : 0;
m->sender = params[1];
for (unsigned j = 2; params[j].equals_ci("UNREAD") || params[j].equals_ci("RECEIPT") || params[j].equals_ci("NOTIFYS"); ++j)
for (unsigned j = 2; params[j].equals_ci("UNREAD") || params[j].equals_ci("RECEIPT"); ++j)
{
if (params[j].equals_ci("UNREAD"))
m->SetFlag(MF_UNREAD);
else if (params[j].equals_ci("RECEIPT"))
m->SetFlag(MF_RECEIPT);
else if (params[j].equals_ci("NOTIFYS"))
m->SetFlag(MF_NOTIFYS);
}
m->text = params[params.size() - 1];
nc->memos.memos.push_back(m);
@@ -633,14 +629,12 @@ class DBPlain : public Module
Memo *m = new Memo;
m->time = params[0].is_pos_number_only() ? convertTo<time_t>(params[0]) : 0;
m->sender = params[1];
for (unsigned j = 2; params[j].equals_ci("UNREAD") || params[j].equals_ci("RECEIPT") || params[j].equals_ci("NOTIFYS"); ++j)
for (unsigned j = 2; params[j].equals_ci("UNREAD") || params[j].equals_ci("RECEIPT"); ++j)
{
if (params[j].equals_ci("UNREAD"))
m->SetFlag(MF_UNREAD);
else if (params[j].equals_ci("RECEIPT"))
m->SetFlag(MF_RECEIPT);
else if (params[j].equals_ci("NOTIFYS"))
m->SetFlag(MF_NOTIFYS);
}
m->text = params[params.size() - 1];
ci->memos.memos.push_back(m);
@@ -754,8 +748,6 @@ class DBPlain : public Module
db_buffer << " UNREAD";
if (mi->memos[k]->HasFlag(MF_RECEIPT))
db_buffer << " RECEIPT";
if (mi->memos[k]->HasFlag(MF_NOTIFYS))
db_buffer << " NOTIFYS";
db_buffer << " :" << mi->memos[k]->text << endl;
}
for (unsigned k = 0, end = mi->ignores.size(); k < end; ++k)
@@ -848,8 +840,6 @@ class DBPlain : public Module
db_buffer << " UNREAD";
if (memos->memos[k]->HasFlag(MF_RECEIPT))
db_buffer << " RECEIPT";
if (memos->memos[k]->HasFlag(MF_NOTIFYS))
db_buffer << " NOTIFYS";
db_buffer << " :" << memos->memos[k]->text << endl;
}
for (unsigned k = 0, end = memos->ignores.size(); k < end; ++k)
@@ -906,7 +896,7 @@ class DBPlain : public Module
db_buffer << "OS SZLINE " << x->Mask << " " << x->By << " " << x->Created << " " << x->Expires << " :" << x->Reason << endl;
}
for (std::vector<Exception *>::iterator it = exceptions.begin(), it_end = exceptions.end(); it != it_end; ++it)
for (SessionService::ExceptionVector::iterator it = SessionInterface->GetExceptions().begin(); it != SessionInterface->GetExceptions().end(); ++it)
{
Exception *e = *it;
db_buffer << "OS EXCEPTION " << e->mask << " " << e->limit << " " << e->who << " " << e->time << " " << e->expires << " " << e->reason << endl;
@@ -1,4 +1,4 @@
/* OperServ core functions
/* Global core functions
*
* (C) 2003-2011 Anope Team
* Contact us at team@anope.org
@@ -12,11 +12,12 @@
/*************************************************************************/
#include "module.h"
#include "global.h"
class CommandOSGlobal : public Command
class CommandGLGlobal : public Command
{
public:
CommandOSGlobal() : Command("GLOBAL", 1, 1, "operserv/global")
CommandGLGlobal() : Command("GLOBAL", 1, 1, "global/global")
{
this->SetDesc(_("Send a message to all users"));
}
@@ -27,7 +28,7 @@ class CommandOSGlobal : public Command
const Anope::string &msg = params[0];
Log(LOG_ADMIN, u, this);
oper_global(u->nick, "%s", msg.c_str());
global->SendGlobal(global->Bot(), u->nick, msg);
return MOD_CONT;
}
@@ -36,7 +37,7 @@ class CommandOSGlobal : public Command
source.Reply(_("Syntax: \002GLOBAL \037message\037\002\n"
" \n"
"Allows Administrators to send messages to all users on the \n"
"network. The message will be sent from the nick \002%s\002."), Config->s_GlobalNoticer.c_str());
"network. The message will be sent from the nick \002%s\002."), Config->s_Global.c_str());
return true;
}
@@ -46,22 +47,21 @@ class CommandOSGlobal : public Command
}
};
class OSGlobal : public Module
class GLGlobal : public Module
{
CommandOSGlobal commandosglobal;
CommandGLGlobal commandglglobal;
public:
OSGlobal(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator)
GLGlobal(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator)
{
this->SetAuthor("Anope");
this->SetType(CORE);
if (Config->s_GlobalNoticer.empty())
if (Config->s_Global.empty())
throw ModuleException("Global is disabled");
// Maybe we should put this ON Global?
this->AddCommand(OperServ, &commandosglobal);
this->AddCommand(global->Bot(), &commandglglobal);
}
};
MODULE_INIT(OSGlobal)
MODULE_INIT(GLGlobal)
+58
View File
@@ -0,0 +1,58 @@
/* Global core functions
*
* (C) 2003-2011 Anope Team
* Contact us at team@anope.org
*
* Please read COPYING and README for further details.
*
* Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church.
*/
/*************************************************************************/
#include "module.h"
#include "global.h"
class CommandGLHelp : public Command
{
public:
CommandGLHelp() : Command("HELP", 1, 1)
{
this->SetDesc(_("Displays this list and give information about commands"));
}
CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> &params)
{
mod_help_cmd(global->Bot(), source.u, NULL, params[0]);
return MOD_CONT;
}
void OnSyntaxError(CommandSource &source, const Anope::string &subcommand)
{
User *u = source.u;
source.Reply(_("%s commands:"), Config->s_Global.c_str());
for (CommandMap::const_iterator it = global->Bot()->Commands.begin(), it_end = global->Bot()->Commands.end(); it != it_end; ++it)
if (!Config->HidePrivilegedCommands || it->second->permission.empty() || u->HasCommand(it->second->permission))
it->second->OnServHelp(source);
}
};
class GLHelp : public Module
{
CommandGLHelp commandoshelp;
public:
GLHelp(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator)
{
this->SetAuthor("Anope");
this->SetType(CORE);
if (!global)
throw ModuleException("Global is not loaded!");
this->AddCommand(global->Bot(), &commandoshelp);
}
};
MODULE_INIT(GLHelp)
+111
View File
@@ -0,0 +1,111 @@
/* Global core functions
*
* (C) 2003-2011 Anope Team
* Contact us at team@anope.org
*
* Please read COPYING and README for further details.
*
* Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church.
*/
/*************************************************************************/
#include "module.h"
#include "global.h"
static BotInfo *Global = NULL;
class MyGlobalService : public GlobalService
{
void ServerGlobal(Server *s, const Anope::string &message)
{
if (s != Me && !s->HasFlag(SERVER_JUPED))
notice_server(Config->s_Global, s, "%s", message.c_str());
for (unsigned i = 0, j = s->GetLinks().size(); i < j; ++i)
this->ServerGlobal(s->GetLinks()[i], message);
}
public:
MyGlobalService(Module *m) : GlobalService(m) { }
BotInfo *Bot()
{
return Global;
}
void SendGlobal(BotInfo *sender, const Anope::string &source, const Anope::string &message)
{
if (Me->GetLinks().empty())
return;
Anope::string rmessage;
if (!source.empty() && !Config->AnonymousGlobal)
rmessage = "[" + source + "] " + message;
else
rmessage = message;
this->ServerGlobal(Me->GetLinks().front(), rmessage);
}
};
class GlobalCore : public Module
{
MyGlobalService myglobal;
public:
GlobalCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator), myglobal(this)
{
this->SetAuthor("Anope");
this->SetType(CORE);
Implementation i[] = { I_OnPreRestart, I_OnPreShutdown, I_OnNewServer };
ModuleManager::Attach(i, this, 3);
ModuleManager::RegisterService(&this->myglobal);
Global = new BotInfo(Config->s_Global, Config->ServiceUser, Config->ServiceHost, Config->desc_Global);
Global->SetFlag(BI_CORE);
spacesepstream coreModules(Config->GlobalCoreModules);
Anope::string module;
while (coreModules.GetToken(module))
ModuleManager::LoadModule(module, NULL);
}
~GlobalCore()
{
spacesepstream coreModules(Config->GlobalCoreModules);
Anope::string module;
while (coreModules.GetToken(module))
{
Module *m = FindModule(module);
if (m != NULL)
ModuleManager::UnloadModule(m, NULL);
}
delete Global;
}
void OnPreRestart()
{
if (Config->GlobalOnCycle)
global->SendGlobal(global->Bot(), "", Config->GlobalOnCycleMessage);
}
void OnPreShutdown()
{
if (Config->GlobalOnCycle)
global->SendGlobal(global->Bot(), "", Config->GlobalOnCycleMessage);
}
void OnNewServer(Server *s)
{
if (Config->GlobalOnCycle && !Config->GlobalOnCycleUP.empty())
notice_server(Config->s_Global, s, "%s", Config->GlobalOnCycleUP.c_str());
}
};
MODULE_INIT(GlobalCore)
+22
View File
@@ -0,0 +1,22 @@
#ifndef GLOBAL_H
#define GLOBAL_H
class GlobalService : public Service
{
public:
GlobalService(Module *m) : Service(m, "Global") { }
virtual BotInfo *Bot() = 0;
/** Send out a global message to all users
* @param sender Our client which should send the global
* @param source The sender of the global
* @param message The message
*/
virtual void SendGlobal(BotInfo *sender, const Anope::string &source, const Anope::string &message) = 0;
};
static service_reference<GlobalService> global("Global");
#endif // GLOBAL_H
+17
View File
@@ -0,0 +1,17 @@
#ifndef HOSTSERV_H
#define HOSTSERV_H
class HostServService : public Service
{
public:
HostServService(Module *m) : Service(m, "HostServ") { }
virtual BotInfo *Bot() = 0;
virtual void Sync(NickAlias *na) = 0;
};
static service_reference<HostServService> hostserv("HostServ");
#endif // HOSTSERV_H
+5 -1
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "hostserv.h"
class CommandHSDel : public Command
{
@@ -68,7 +69,10 @@ class HSDel : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(HostServ, &commandhsdel);
if (!hostserv)
throw ModuleException("HostServ is not loaded!");
this->AddCommand(hostserv->Bot(), &commandhsdel);
}
};
+5 -1
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "hostserv.h"
class CommandHSDelAll : public Command
{
@@ -73,7 +74,10 @@ class HSDelAll : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(HostServ, &commandhsdelall);
if (!hostserv)
throw ModuleException("HostServ is not loaded!");
this->AddCommand(hostserv->Bot(), &commandhsdelall);
}
};
+6 -2
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "hostserv.h"
class CommandHSGroup : public Command
{
@@ -27,7 +28,7 @@ class CommandHSGroup : public Command
NickAlias *na = findnick(u->nick);
if (na && u->Account() == na->nc && na->hostinfo.HasVhost())
{
HostServSyncVhosts(na);
hostserv->Sync(na);
if (!na->hostinfo.GetIdent().empty())
source.Reply(_("All vhost's in the group \002%s\002 have been set to \002%s\002@\002%s\002"), u->Account()->display.c_str(), na->hostinfo.GetIdent().c_str(), na->hostinfo.GetHost().c_str());
else
@@ -60,7 +61,10 @@ class HSGroup : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(HostServ, &commandhsgroup);
if (!hostserv)
throw ModuleException("HostServ is not loaded!");
this->AddCommand(hostserv->Bot(), &commandhsgroup);
}
};
+7 -3
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "hostserv.h"
class CommandHSHelp : public Command
{
@@ -24,7 +25,7 @@ class CommandHSHelp : public Command
CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> &params)
{
mod_help_cmd(HostServ, source.u, NULL, params[0]);
mod_help_cmd(hostserv->Bot(), source.u, NULL, params[0]);
return MOD_CONT;
}
@@ -32,7 +33,7 @@ class CommandHSHelp : public Command
{
User *u = source.u;
source.Reply(_("%s commands:"), Config->s_HostServ.c_str());
for (CommandMap::const_iterator it = HostServ->Commands.begin(), it_end = HostServ->Commands.end(); it != it_end; ++it)
for (CommandMap::const_iterator it = hostserv->Bot()->Commands.begin(), it_end = hostserv->Bot()->Commands.end(); it != it_end; ++it)
if (!Config->HidePrivilegedCommands || it->second->permission.empty() || u->HasCommand(it->second->permission))
it->second->OnServHelp(source);
}
@@ -48,7 +49,10 @@ class HSHelp : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(HostServ, &commandhshelp);
if (!hostserv)
throw ModuleException("HostServ is not loaded!");
this->AddCommand(hostserv->Bot(), &commandhshelp);
}
};
+5 -1
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "hostserv.h"
class CommandHSList : public Command
{
@@ -128,7 +129,10 @@ class HSList : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(HostServ, &commandhslist);
if (!hostserv)
throw ModuleException("HostServ is not loaded!");
this->AddCommand(hostserv->Bot(), &commandhslist);
}
};
+123
View File
@@ -0,0 +1,123 @@
/* HostServ core functions
*
* (C) 2003-2011 Anope Team
* Contact us at team@anope.org
*
* Please read COPYING and README for further details.
*
* Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church.
*/
/*************************************************************************/
#include "module.h"
#include "hostserv.h"
static BotInfo *HostServ = NULL;
class MyHostServService : public HostServService
{
public:
MyHostServService(Module *m) : HostServService(m) { }
BotInfo *Bot()
{
return HostServ;
}
void Sync(NickAlias *na)
{
if (!na || !na->hostinfo.HasVhost())
return;
for (std::list<NickAlias *>::iterator it = na->nc->aliases.begin(), it_end = na->nc->aliases.end(); it != it_end; ++it)
{
NickAlias *nick = *it;
nick->hostinfo.SetVhost(na->hostinfo.GetIdent(), na->hostinfo.GetHost(), na->hostinfo.GetCreator());
}
}
};
class HostServCore : public Module
{
MyHostServService myhostserv;
public:
HostServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator), myhostserv(this)
{
this->SetAuthor("Anope");
this->SetType(CORE);
if (!ircd->vhost)
throw ModuleException("Your IRCd does not suppor vhosts");
ModuleManager::RegisterService(&this->myhostserv);
HostServ = new BotInfo(Config->s_HostServ, Config->ServiceUser, Config->ServiceHost, Config->desc_HostServ);
HostServ->SetFlag(BI_CORE);
Implementation i[] = { I_OnNickIdentify, I_OnNickUpdate };
ModuleManager::Attach(i, this, 2);
spacesepstream coreModules(Config->HostCoreModules);
Anope::string module;
while (coreModules.GetToken(module))
ModuleManager::LoadModule(module, NULL);
}
~HostServCore()
{
spacesepstream coreModules(Config->HostCoreModules);
Anope::string module;
while (coreModules.GetToken(module))
{
Module *m = FindModule(module);
if (m != NULL)
ModuleManager::UnloadModule(m, NULL);
}
delete HostServ;
}
void OnNickIdentify(User *u)
{
HostInfo *ho = NULL;
NickAlias *na = findnick(u->nick);
if (na && na->hostinfo.HasVhost())
ho = &na->hostinfo;
else
{
na = findnick(u->Account()->display);
if (na && na->hostinfo.HasVhost())
ho = &na->hostinfo;
}
if (ho == NULL)
return;
if (u->vhost.empty() || !u->vhost.equals_cs(na->hostinfo.GetHost()) || (!na->hostinfo.GetIdent().empty() && !u->GetVIdent().equals_cs(na->hostinfo.GetIdent())))
{
ircdproto->SendVhost(u, na->hostinfo.GetIdent(), na->hostinfo.GetHost());
if (ircd->vhost)
{
u->vhost = na->hostinfo.GetHost();
u->UpdateHost();
}
if (ircd->vident && !na->hostinfo.GetIdent().empty())
u->SetVIdent(na->hostinfo.GetIdent());
if (!na->hostinfo.GetIdent().empty())
u->SendMessage(HostServ, _("Your vhost of \002%s\002@\002%s\002 is now activated."), na->hostinfo.GetIdent().c_str(), na->hostinfo.GetHost().c_str());
else
u->SendMessage(HostServ, _("Your vhost of \002%s\002 is now activated."), na->hostinfo.GetHost().c_str());
}
}
void OnNickUpdate(User *u)
{
this->OnNickIdentify(u);
}
};
MODULE_INIT(HostServCore)
+5 -1
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "hostserv.h"
class CommandHSOff : public Command
{
@@ -58,7 +59,10 @@ class HSOff : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(HostServ, &commandhsoff);
if (!hostserv)
throw ModuleException("HostServ is not loaded!");
this->AddCommand(hostserv->Bot(), &commandhsoff);
}
};
+5 -1
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "hostserv.h"
class CommandHSOn : public Command
{
@@ -68,7 +69,10 @@ class HSOn : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(HostServ, &commandhson);
if (!hostserv)
throw ModuleException("HostServ is not loaded!");
this->AddCommand(hostserv->Bot(), &commandhson);
}
};
+5 -1
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "hostserv.h"
class CommandHSSet : public Command
{
@@ -122,7 +123,10 @@ class HSSet : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(HostServ, &commandhsset);
if (!hostserv)
throw ModuleException("HostServ is not loaded!");
this->AddCommand(hostserv->Bot(), &commandhsset);
}
};
+6 -2
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "hostserv.h"
class CommandHSSetAll : public Command
{
@@ -92,7 +93,7 @@ class CommandHSSetAll : public Command
Log(LOG_ADMIN, u, this) << "to set the vhost for all nicks in group " << na->nc->display << " to " << (!vIdent.empty() ? vIdent + "@" : "") << hostmask;
na->hostinfo.SetVhost(vIdent, hostmask, u->nick);
HostServSyncVhosts(na);
hostserv->Sync(na);
FOREACH_MOD(I_OnSetVhost, OnSetVhost(na));
if (!vIdent.empty())
source.Reply(_("vhost for group \002%s\002 set to \002%s\002@\002%s\002."), nick.c_str(), vIdent.c_str(), hostmask.c_str());
@@ -129,7 +130,10 @@ class HSSetAll : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(HostServ, &commandhssetall);
if (!hostserv)
throw ModuleException("HostServ is not loaded!");
this->AddCommand(hostserv->Bot(), &commandhssetall);
}
};
+44
View File
@@ -0,0 +1,44 @@
#ifndef MEMOSERV_H
#define MEMOSERV_H
class MemoServService : public Service
{
public:
enum MemoResult
{
MEMO_SUCCESS,
MEMO_INVALID_TARGET,
MEMO_TOO_FAST,
MEMO_TARGET_FULL
};
MemoServService(Module *m) : Service(m, "MemoServ") { }
virtual BotInfo *Bot() = 0;
/** Retrieve the memo info for a nick or channel
* @param target Target
* @param ischan Set to true if target is a channel
* @param isforbid Set to true if the target is forbidden
* @return A memoinfo structure or NULL
*/
virtual MemoInfo *GetMemoInfo(const Anope::string &target, bool &ischan, bool &isforbid) = 0;
/** Sends a memo.
* @param source The source of the memo, can be anythin.
* @param target The target of the memo, nick or channel.
* @param message Memo text
* @param force true to force the memo, restrictions/delays etc are not checked
*/
virtual MemoResult Send(const Anope::string &source, const Anope::string &target, const Anope::string &message, bool force = false) = 0;
/** Check for new memos and notify the user if there are any
* @param u The user
*/
virtual void Check(User *u) = 0;
};
static service_reference<MemoServService> memoserv("MemoServ");
#endif // MEMOSERV_H
+8 -6
View File
@@ -12,8 +12,7 @@
/*************************************************************************/
#include "module.h"
void myMemoServHelp(User *u);
#include "memoserv.h"
class CommandMSCancel : public Command
{
@@ -30,9 +29,9 @@ class CommandMSCancel : public Command
const Anope::string &nname = params[0];
bool ischan, isforbid;
MemoInfo *mi;
MemoInfo *mi = memoserv->GetMemoInfo(nname, ischan, isforbid);
if (!(mi = getmemoinfo(nname, ischan, isforbid)))
if (mi == NULL)
{
if (isforbid)
source.Reply(ischan ? _(CHAN_X_FORBIDDEN) : _(NICK_X_FORBIDDEN), nname.c_str());
@@ -42,7 +41,7 @@ class CommandMSCancel : public Command
else
{
for (int i = mi->memos.size() - 1; i >= 0; --i)
if (mi->memos[i]->HasFlag(MF_UNREAD) && u->Account()->display.equals_ci(mi->memos[i]->sender) && !mi->memos[i]->HasFlag(MF_NOTIFYS))
if (mi->memos[i]->HasFlag(MF_UNREAD) && u->Account()->display.equals_ci(mi->memos[i]->sender))
{
FOREACH_MOD(I_OnMemoDel, OnMemoDel(findnick(nname)->nc, mi, mi->memos[i]));
mi->Del(mi->memos[i]);
@@ -80,7 +79,10 @@ class MSCancel : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(MemoServ, &commandmscancel);
if (!memoserv)
throw ModuleException("MemoServ is not loaded!");
this->AddCommand(memoserv->Bot(), &commandmscancel);
}
};
+5 -1
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "memoserv.h"
class CommandMSCheck : public Command
{
@@ -92,7 +93,10 @@ class MSCheck : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(MemoServ, &commandmscheck);
if (!memoserv)
throw ModuleException("MemoServ is not loaded!");
this->AddCommand(memoserv->Bot(), &commandmscheck);
}
};
+5 -1
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "memoserv.h"
class MemoDelCallback : public NumberList
{
@@ -160,7 +161,10 @@ class MSDel : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(MemoServ, &commandmsdel);
if (!memoserv)
throw ModuleException("MemoServ is not loaded!");
this->AddCommand(memoserv->Bot(), &commandmsdel);
}
};
+9 -5
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "memoserv.h"
class CommandMSHelp : public Command
{
@@ -24,7 +25,7 @@ class CommandMSHelp : public Command
CommandReturn Execute(CommandSource &source, const std::vector<Anope::string> &params)
{
mod_help_cmd(MemoServ, source.u, NULL, params[0]);
mod_help_cmd(memoserv->Bot(), source.u, NULL, params[0]);
return MOD_CONT;
}
@@ -36,15 +37,15 @@ class CommandMSHelp : public Command
"the time or not, or to channels(*). Both the sender's\n"
"nickname and the target nickname or channel must be\n"
"registered in order to send a memo.\n"
"%s's commands include:"), MemoServ->nick.c_str(), MemoServ->nick.c_str());
for (CommandMap::const_iterator it = MemoServ->Commands.begin(), it_end = MemoServ->Commands.end(); it != it_end; ++it)
"%s's commands include:"), Config->s_MemoServ.c_str(), Config->s_MemoServ.c_str());
for (CommandMap::const_iterator it = memoserv->Bot()->Commands.begin(), it_end = memoserv->Bot()->Commands.end(); it != it_end; ++it)
if (!Config->HidePrivilegedCommands || it->second->permission.empty() || u->HasCommand(it->second->permission))
it->second->OnServHelp(source);
source.Reply(_("Type \002%s%s HELP \037command\037\002 for help on any of the\n"
"above commands.\n"
"(*) By default, any user with at least level 10 access on a\n"
" channel can read that channel's memos. This can be\n"
" changed with the %s \002LEVELS\002 command."), Config->UseStrictPrivMsgString.c_str(), MemoServ->nick.c_str(), Config->s_ChanServ.c_str());
" changed with the %s \002LEVELS\002 command."), Config->UseStrictPrivMsgString.c_str(), Config->s_MemoServ.c_str(), Config->s_ChanServ.c_str());
}
};
@@ -58,7 +59,10 @@ class MSHelp : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(MemoServ, &commandmshelp);
if (!memoserv)
throw ModuleException("MemoServ is not loaded!");
this->AddCommand(memoserv->Bot(), &commandmshelp);
}
};
+6 -2
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "memoserv.h"
class CommandMSIgnore : public Command
{
@@ -37,7 +38,7 @@ class CommandMSIgnore : public Command
}
bool ischan, isforbid;
MemoInfo *mi = getmemoinfo(channel, ischan, isforbid);
MemoInfo *mi = memoserv->GetMemoInfo(channel, ischan, isforbid);
if (!mi)
{
if (isforbid)
@@ -111,7 +112,10 @@ class MSIgnore : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(MemoServ, &commandmsignore);
if (!memoserv)
throw ModuleException("MemoServ is not loaded!");
this->AddCommand(memoserv->Bot(), &commandmsignore);
}
};
+5 -1
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "memoserv.h"
class CommandMSInfo : public Command
{
@@ -224,7 +225,10 @@ class MSInfo : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(MemoServ, &commandmsinfo);
if (!memoserv)
throw ModuleException("MemoServ is not loaded!");
this->AddCommand(memoserv->Bot(), &commandmsinfo);
}
};
+5 -1
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "memoserv.h"
class MemoListCallback : public NumberList
{
@@ -172,7 +173,10 @@ class MSList : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(MemoServ, &commandmslist);
if (!memoserv)
throw ModuleException("MemoServ is not loaded!");
this->AddCommand(memoserv->Bot(), &commandmslist);
}
};
+250
View File
@@ -0,0 +1,250 @@
/* MemoServ core functions
*
* (C) 2003-2011 Anope Team
* Contact us at team@anope.org
*
* Please read COPYING and README for further details.
*
* Based on the original code of Epona by Lara.
* Based on the original code of Services by Andy Church.
*/
/*************************************************************************/
#include "module.h"
#include "memoserv.h"
static BotInfo *MemoServ = NULL;
static bool SendMemoMail(NickCore *nc, MemoInfo *mi, Memo *m)
{
Anope::string message = Anope::printf(GetString(nc,
"Hi %s\n"
" \n"
"You've just received a new memo from %s. This is memo number %d.\n"
" \n"
"Memo text:\n"
" \n"
"%s").c_str(), nc->display.c_str(), m->sender.c_str(), mi->GetIndex(m), m->text.c_str());
return Mail(nc, GetString(nc, _("New memo")), message);
}
class MyMemoServService : public MemoServService
{
public:
MyMemoServService(Module *m) : MemoServService(m) { }
BotInfo *Bot()
{
return MemoServ;
}
MemoInfo *GetMemoInfo(const Anope::string &target, bool &ischan, bool &isforbid)
{
isforbid = false;
if (!target.empty() && target[0] == '#')
{
ischan = true;
ChannelInfo *ci = cs_findchan(target);
if (ci != NULL)
{
isforbid = ci->HasFlag(CI_FORBIDDEN);
return &ci->memos;
}
}
else
{
ischan = false;
NickAlias *na = findnick(target);
if (na != NULL)
{
isforbid = na->HasFlag(NS_FORBIDDEN);
return &na->nc->memos;
}
}
return NULL;
}
MemoResult Send(const Anope::string &source, const Anope::string &target, const Anope::string &message, bool force)
{
bool ischan, isforbid;
MemoInfo *mi = this->GetMemoInfo(target, ischan, isforbid);
if (mi == NULL || isforbid == true)
return MEMO_INVALID_TARGET;
User *sender = finduser(source);
if (sender != NULL && !sender->HasPriv("memoserv/no-limit") && !force)
{
if (Config->MSSendDelay > 0 && sender->lastmemosend + Config->MSSendDelay > Anope::CurTime)
return MEMO_TOO_FAST;
else if (!mi->memomax)
return MEMO_TARGET_FULL;
else if (mi->memomax > 0 && mi->memos.size() >= mi->memomax)
return MEMO_TARGET_FULL;
else if (mi->HasIgnore(sender))
return MEMO_SUCCESS;
}
if (sender != NULL)
sender->lastmemosend = Anope::CurTime;
Memo *m = new Memo();
mi->memos.push_back(m);
m->sender = source;
m->time = Anope::CurTime;
m->text = message;
m->SetFlag(MF_UNREAD);
FOREACH_MOD(I_OnMemoSend, OnMemoSend(source, target, mi, m));
if (ischan)
{
ChannelInfo *ci = cs_findchan(target);
if (ci->c)
{
for (CUserList::iterator it = ci->c->users.begin(), it_end = ci->c->users.end(); it != it_end; ++it)
{
UserContainer *cu = *it;
if (check_access(cu->user, ci, CA_MEMO))
{
if (cu->user->Account() && cu->user->Account()->HasFlag(NI_MEMO_RECEIVE))
cu->user->SendMessage(MemoServ, _(MEMO_NEW_X_MEMO_ARRIVED), ci->name.c_str(), Config->UseStrictPrivMsgString.c_str(), Config->s_MemoServ.c_str(), ci->name.c_str(), mi->memos.size());
}
}
}
}
else
{
NickCore *nc = findnick(target)->nc;
if (nc->HasFlag(NI_MEMO_RECEIVE))
{
for (std::list<NickAlias *>::iterator it = nc->aliases.begin(), it_end = nc->aliases.end(); it != it_end; ++it)
{
NickAlias *na = *it;
User *user = finduser(na->nick);
if (user && user->IsIdentified())
user->SendMessage(MemoServ, _(MEMO_NEW_MEMO_ARRIVED), source.c_str(), Config->UseStrictPrivMsgString.c_str(), Config->s_MemoServ.c_str(), mi->memos.size());
}
}
/* let's get out the mail if set in the nickcore - certus */
if (nc->HasFlag(NI_MEMO_MAIL))
SendMemoMail(nc, mi, m);
}
return MEMO_SUCCESS;
}
void Check(User *u)
{
NickCore *nc = u->Account();
if (!nc)
return;
unsigned i = 0, end = nc->memos.memos.size(), newcnt = 0;
for (; i < end; ++i)
{
if (nc->memos.memos[i]->HasFlag(MF_UNREAD))
++newcnt;
}
if (newcnt > 0)
{
u->SendMessage(MemoServ, newcnt == 1 ? _("You have 1 new memo.") : _("You have %d new memos."), newcnt);
if (newcnt == 1 && (nc->memos.memos[i - 1]->HasFlag(MF_UNREAD)))
u->SendMessage(MemoServ, _("Type \002%s%s READ LAST\002 to read it."), Config->UseStrictPrivMsgString.c_str(), Config->s_MemoServ.c_str());
else if (newcnt == 1)
{
for (i = 0; i < end; ++i)
{
if (nc->memos.memos[i]->HasFlag(MF_UNREAD))
break;
}
u->SendMessage(MemoServ, _("Type \002%s%s READ %d\002 to read it."), Config->UseStrictPrivMsgString.c_str(), Config->s_MemoServ.c_str(), i);
}
else
u->SendMessage(MemoServ, _("Type \002%s%s LIST NEW\002 to list them."), Config->UseStrictPrivMsgString.c_str(), Config->s_MemoServ.c_str());
}
if (nc->memos.memomax > 0 && nc->memos.memos.size() >= nc->memos.memomax)
{
if (nc->memos.memos.size() > nc->memos.memomax)
u->SendMessage(MemoServ, _("You are over your maximum number of memos (%d). You will be unable to receive any new memos until you delete some of your current ones."), nc->memos.memomax);
else
u->SendMessage(MemoServ, _("You have reached your maximum number of memos (%d). You will be unable to receive any new memos until you delete some of your current ones."), nc->memos.memomax);
}
}
};
class MemoServCore : public Module
{
MyMemoServService mymemoserv;
public:
MemoServCore(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator), mymemoserv(this)
{
this->SetAuthor("Anope");
this->SetType(CORE);
Implementation i[] = { I_OnNickIdentify, I_OnJoinChannel, I_OnUserAway, I_OnNickUpdate };
ModuleManager::Attach(i, this, 4);
ModuleManager::RegisterService(&this->mymemoserv);
MemoServ = new BotInfo(Config->s_MemoServ, Config->ServiceUser, Config->ServiceHost, Config->desc_MemoServ);
MemoServ->SetFlag(BI_CORE);
spacesepstream coreModules(Config->MemoCoreModules);
Anope::string module;
while (coreModules.GetToken(module))
ModuleManager::LoadModule(module, NULL);
}
~MemoServCore()
{
spacesepstream coreModules(Config->MemoCoreModules);
Anope::string module;
while (coreModules.GetToken(module))
{
Module *m = FindModule(module);
if (m != NULL)
ModuleManager::UnloadModule(m, NULL);
}
delete MemoServ;
}
void OnNickIdentify(User *u)
{
this->mymemoserv.Check(u);
}
void OnJoinChannel(User *u, Channel *c)
{
if (c->ci && check_access(u, c->ci, CA_MEMO) && c->ci->memos.memos.size() > 0)
{
if (c->ci->memos.memos.size() == 1)
u->SendMessage(MemoServ, _("There is \002%d\002 memo on channel %s."), c->ci->memos.memos.size(), c->ci->name.c_str());
else
u->SendMessage(MemoServ, _("There are \002%d\002 memos on channel %s."), c->ci->memos.memos.size(), c->ci->name.c_str());
}
}
void OnUserAway(User *u, const Anope::string &message)
{
if (message.empty())
this->mymemoserv.Check(u);
}
void OnNickUpdate(User *u)
{
this->mymemoserv.Check(u);
}
};
MODULE_INIT(MemoServCore)
+40 -2
View File
@@ -12,6 +12,41 @@
/*************************************************************************/
#include "module.h"
#include "memoserv.h"
void rsend_notify(CommandSource &source, MemoInfo *mi, Memo *m, const Anope::string &targ)
{
/* Only send receipt if memos are allowed */
if (memoserv && !readonly)
{
/* Get nick alias for sender */
NickAlias *na = findnick(m->sender);
if (!na)
return;
/* Get nick core for sender */
NickCore *nc = na->nc;
if (!nc)
return;
/* Text of the memo varies if the recepient was a
nick or channel */
Anope::string text = Anope::printf(GetString(na->nc, _("\002[auto-memo]\002 The memo you sent to %s has been viewed.")).c_str(), targ.c_str());
/* Send notification */
memoserv->Send(source.u->nick, m->sender, text, true);
/* Notify recepient of the memo that a notification has
been sent to the sender */
source.Reply(_("A notification memo has been sent to %s informing him/her you have\n"
"read his/her memo."), nc->display.c_str());
}
/* Remove receipt flag from the original memo */
m->UnsetFlag(MF_RECEIPT);
}
class MemoListCallback : public NumberList
{
@@ -42,7 +77,7 @@ class MemoListCallback : public NumberList
/* Check if a receipt notification was requested */
if (m->HasFlag(MF_RECEIPT))
rsend_notify(source, m, ci ? ci->name : "");
rsend_notify(source, mi, m, ci ? ci->name : source.u->nick);
}
};
@@ -157,7 +192,10 @@ class MSRead : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(MemoServ, &commandmsread);
if (!memoserv)
throw ModuleException("MemoServ is not loaded!");
this->AddCommand(memoserv->Bot(), &commandmsread);
}
};
+31 -15
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "memoserv.h"
class CommandMSRSend : public Command
{
@@ -36,23 +37,35 @@ class CommandMSRSend : public Command
return MOD_CONT;
}
if (Config->MSMemoReceipt == 1)
if (Config->MSMemoReceipt == 1 && !u->IsServicesOper())
source.Reply(_(ACCESS_DENIED));
else if (Config->MSMemoReceipt > 2 || Config->MSMemoReceipt == 0)
{
/* Services opers and above can use rsend */
if (u->IsServicesOper())
memo_send(source, nick, text, 3);
else
source.Reply(_(ACCESS_DENIED));
}
else if (Config->MSMemoReceipt == 2)
/* Everybody can use rsend */
memo_send(source, nick, text, 3);
else
{
/* rsend has been disabled */
Log() << "MSMemoReceipt is set misconfigured to " << Config->MSMemoReceipt;
source.Reply(_("Sorry, RSEND has been disabled on this network."));
}
else
{
MemoServService::MemoResult result = memoserv->Send(u->nick, nick, text);
if (result == MemoServService::MEMO_INVALID_TARGET)
source.Reply(_("\002%s\002 is not a registered unforbidden nick or channel."), nick.c_str());
else if (result == MemoServService::MEMO_TOO_FAST)
source.Reply(_("Please wait %d seconds before using the SEND command again."), Config->MSSendDelay);
else if (result == MemoServService::MEMO_TARGET_FULL)
source.Reply(_("%s currently has too many memos and cannot receive more."), nick.c_str());
else
{
source.Reply(_("Memo sent to \002%s\002."), name.c_str());
bool ischan, isforbid;
MemoInfo *mi = memoserv->GetMemoInfo(nick, ischan, isforbid);
if (mi == NULL)
throw CoreException("NULL mi in ms_rsend");
Memo *m = (mi->memos.size() ? mi->memos[mi->memos.size() - 1] : NULL);
if (m != NULL)
m->SetFlag(MF_RECEIPT);
}
}
return MOD_CONT;
}
@@ -85,12 +98,15 @@ class MSRSend : public Module
MSRSend(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator)
{
if (!Config->MSMemoReceipt)
throw ModuleException("Don't like memo reciepts, or something.");
throw ModuleException("Invalid value for memoreceipt");
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(MemoServ, &commandmsrsend);
if (!memoserv)
throw ModuleException("MemoServ is not loaded!");
this->AddCommand(memoserv->Bot(), &commandmsrsend);
}
};
+16 -2
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "memoserv.h"
class CommandMSSend : public Command
{
@@ -25,7 +26,17 @@ class CommandMSSend : public Command
{
const Anope::string &nick = params[0];
const Anope::string &text = params[1];
memo_send(source, nick, text, 0);
MemoServService::MemoResult result = memoserv->Send(source.u->nick, nick, text);
if (result == MemoServService::MEMO_SUCCESS)
source.Reply(_("Memo sent to \002%s\002."), nick.c_str());
else if (result == MemoServService::MEMO_INVALID_TARGET)
source.Reply(_("\002%s\002 is not a registered unforbidden nick or channel."), nick.c_str());
else if (result == MemoServService::MEMO_TOO_FAST)
source.Reply(_("Please wait %d seconds before using the SEND command again."), Config->MSSendDelay);
else if (result == MemoServService::MEMO_TARGET_FULL)
source.Reply(_("%s currently has too many memos and cannot receive more."), nick.c_str());
return MOD_CONT;
}
@@ -56,7 +67,10 @@ class MSSend : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(MemoServ, &commandmssend);
if (!memoserv)
throw ModuleException("MemoServ is not loaded!");
this->AddCommand(memoserv->Bot(), &commandmssend);
}
};
+6 -2
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "memoserv.h"
class CommandMSSendAll : public Command
{
@@ -39,7 +40,7 @@ class CommandMSSendAll : public Command
NickCore *nc = it->second;
if ((na && na->nc == nc) || !nc->display.equals_ci(u->nick))
memo_send(source, nc->display, text, 1);
memoserv->Send(u->nick, nc->display, text);
}
source.Reply(_("A massmemo has been sent to all registered users."));
@@ -69,7 +70,10 @@ class MSSendAll : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(MemoServ, &commandmssendall);
if (!memoserv)
throw ModuleException("MemoServ is not loaded!");
this->AddCommand(memoserv->Bot(), &commandmssendall);
}
};
+6 -2
View File
@@ -12,6 +12,7 @@
/*************************************************************************/
#include "module.h"
#include "memoserv.h"
class CommandMSSet : public Command
{
@@ -237,7 +238,7 @@ class CommandMSSet : public Command
" receive\n"
" \n"
"Type \002%s%s HELP SET \037option\037\002 for more information\n"
"on a specific option."), Config->UseStrictPrivMsgString.c_str(), MemoServ->nick.c_str());
"on a specific option."), Config->UseStrictPrivMsgString.c_str(), Config->s_MemoServ.c_str());
else if (subcommand.equals_ci("NOTIFY"))
source.Reply(_("Syntax: \002SET NOTIFY {ON | LOGON | NEW | MAIL | NOMAIL | OFF}\002\n"
"Changes when you will be notified about new memos:\n"
@@ -307,7 +308,10 @@ class MSSet : public Module
this->SetAuthor("Anope");
this->SetType(CORE);
this->AddCommand(MemoServ, &commandmsset);
if (!memoserv)
throw ModuleException("MemoServ is not loaded!");
this->AddCommand(memoserv->Bot(), &commandmsset);
}
};

Some files were not shown because too many files have changed in this diff Show More