mirror of
https://github.com/anope/anope.git
synced 2026-06-19 10:24:46 +02:00
Compare commits
123 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 81cf9f0c71 | |||
| 3264669e03 | |||
| 271d723bbd | |||
| a0c4575122 | |||
| 1af64a9bbb | |||
| e3d5140dcc | |||
| f81d0113a2 | |||
| fde42899e7 | |||
| f7bf2fa960 | |||
| b894a569c9 | |||
| 48022c3ddf | |||
| 28aa981464 | |||
| 2b8a09bf55 | |||
| a12788e8f4 | |||
| 9b5f6d3c45 | |||
| af24dc6050 | |||
| f27560cc1e | |||
| 4b309b5044 | |||
| d8a99d619f | |||
| 2dec8e767a | |||
| ba53c7eb03 | |||
| 873d4287de | |||
| 3626fb246e | |||
| a661098ef2 | |||
| a4bf5ce609 | |||
| 437944d416 | |||
| db37b1c634 | |||
| 1e49e9b9dc | |||
| 2cbfbc98e9 | |||
| 38d5f20deb | |||
| 70fb5900a2 | |||
| bf7d1a55af | |||
| 1f73e27870 | |||
| 699087b2bf | |||
| ccd29085a9 | |||
| a883362c14 | |||
| ef88385d85 | |||
| 90b0283160 | |||
| 0a8d46b538 | |||
| a84226edf0 | |||
| 9370b063d0 | |||
| d5ffae0e46 | |||
| f89599726e | |||
| a81b3aaff1 | |||
| 820e4edc2b | |||
| 25586f3246 | |||
| b7149fc940 | |||
| 675b113c3e | |||
| c797987615 | |||
| eb0e07d564 | |||
| 1b5805eeb0 | |||
| 42e652cae7 | |||
| 62818abbf4 | |||
| 4d9a96e8df | |||
| e490a5461f | |||
| 5068483cb9 | |||
| 83ee20fc29 | |||
| b08aa4ed92 | |||
| 1081ecdae8 | |||
| 2370c16f1e | |||
| 3d84dc91f6 | |||
| 573e49a7ea | |||
| 63c639e108 | |||
| fc00406079 | |||
| b752c3a668 | |||
| 7372b457cc | |||
| deb5196101 | |||
| 9e1fda2a44 | |||
| 9d249ef96f | |||
| e03b73e8cd | |||
| 6b473f22bd | |||
| 05bb80c06c | |||
| e6edc6586e | |||
| cf3124c063 | |||
| 12a6a27b52 | |||
| 31a0e673b2 | |||
| 8d0b4a1bf5 | |||
| 1b0ebcadfa | |||
| 0d100ffacc | |||
| 88fd1da803 | |||
| a06934777c | |||
| a26f4b9a9a | |||
| 053d6a2247 | |||
| beae4775cf | |||
| cff91a532f | |||
| 92ed5d7208 | |||
| 7800375510 | |||
| ab25815694 | |||
| 8e0104363f | |||
| b7a6d518b0 | |||
| 4ed844ffd5 | |||
| 020467d472 | |||
| 141b87bd14 | |||
| a5b9e235ae | |||
| a78790eac4 | |||
| 07226feec4 | |||
| e73013830d | |||
| 2bc3bd3fcf | |||
| 83456f6040 | |||
| 601dc41baf | |||
| 2337b7717d | |||
| fde40dee7a | |||
| ba32aad4cb | |||
| 24811e5970 | |||
| f01aab5f9b | |||
| 3850b073dd | |||
| 81e50dd1f4 | |||
| bd31fbb9f0 | |||
| 000660608e | |||
| 826de43724 | |||
| b84e080463 | |||
| 0ba58d7d0e | |||
| 1536c5cf60 | |||
| f2ce9cd85c | |||
| ee5cd8493e | |||
| 41e8d27602 | |||
| e1f5fc6a0c | |||
| db59f1a70f | |||
| a9772cde21 | |||
| 086790d633 | |||
| 1bc8e2ab82 | |||
| 089c85b27e | |||
| 01194e3958 |
+32
-8
@@ -218,6 +218,7 @@ find_package(Gettext)
|
||||
|
||||
# Add an optional variable for using run-cc.pl for building, Perl will be checked later regardless of this setting
|
||||
option(USE_RUN_CC_PL "Use run-cc.pl for building" OFF)
|
||||
option(USE_PCH "Use precompiled headers" OFF)
|
||||
|
||||
# Use the following directories as includes
|
||||
# Note that it is important the binary include directory comes before the
|
||||
@@ -246,7 +247,7 @@ else(MSVC)
|
||||
set(CXXFLAGS "${CXXFLAGS} -Wall -Wshadow")
|
||||
# If on a *nix system, also set the compile flags to remove GNU extensions (favor ISO C++) as well as reject non-ISO C++ code, also remove all leading underscores in exported symbols (only on GNU compiler)
|
||||
if(UNIX)
|
||||
set(CXXFLAGS "${CXXFLAGS} -ansi -pedantic")
|
||||
set(CXXFLAGS "${CXXFLAGS} -ansi -pedantic ${CMAKE_CXX_FLAGS}")
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
set(CXXFLAGS "${CXXFLAGS} -Wno-long-long -fno-leading-underscore")
|
||||
endif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
@@ -379,6 +380,29 @@ else(INSTDIR)
|
||||
set(CMAKE_INSTALL_PREFIX "$ENV{HOME}/services")
|
||||
endif(INSTDIR)
|
||||
|
||||
# Set default paths for various directories if not already defined
|
||||
if(NOT BIN_DIR)
|
||||
set(BIN_DIR "bin")
|
||||
endif(NOT BIN_DIR)
|
||||
if(NOT DB_DIR)
|
||||
set(DB_DIR "data")
|
||||
endif(NOT DB_DIR)
|
||||
if(NOT DOC_DIR)
|
||||
set(DOC_DIR "doc")
|
||||
endif(NOT DOC_DIR)
|
||||
if(NOT CONF_DIR)
|
||||
set(CONF_DIR "conf")
|
||||
endif(NOT CONF_DIR)
|
||||
if(NOT LIB_DIR)
|
||||
set(LIB_DIR "lib")
|
||||
endif(NOT LIB_DIR)
|
||||
if(NOT LOCALE_DIR)
|
||||
set(LOCALE_DIR "locale")
|
||||
endif(NOT LOCALE_DIR)
|
||||
if(NOT LOGS_DIR)
|
||||
set(LOGS_DIR "logs")
|
||||
endif(NOT LOGS_DIR)
|
||||
|
||||
# Version number processing
|
||||
# Find all lines in src/version.sh that start with VERSION_
|
||||
read_from_file(${Anope_SOURCE_DIR}/src/version.sh "^VERSION_" VERSIONS)
|
||||
@@ -457,20 +481,20 @@ get_target_property(SERVICES_BINARY ${PROGRAM_NAME} LOCATION)
|
||||
get_filename_component(SERVICES_BINARY ${SERVICES_BINARY} NAME)
|
||||
|
||||
# At install time, create the following additional directories
|
||||
install(CODE "file(MAKE_DIRECTORY \"\${CMAKE_INSTALL_PREFIX}/data/backups\")")
|
||||
install(CODE "file(MAKE_DIRECTORY \"\${CMAKE_INSTALL_PREFIX}/data/logs\")")
|
||||
install(CODE "file(MAKE_DIRECTORY \"\${CMAKE_INSTALL_PREFIX}/data/modules/runtime\")")
|
||||
install(CODE "file(MAKE_DIRECTORY \"${DB_DIR}/backups\")")
|
||||
install(CODE "file(MAKE_DIRECTORY \"${LOGS_DIR}\")")
|
||||
install(CODE "file(MAKE_DIRECTORY \"${LIB_DIR}/modules/runtime\")")
|
||||
# On non-Windows platforms, if RUNGROUP is set, change the permissions of the below directories, as well as the group of the data directory
|
||||
if(NOT WIN32 AND RUNGROUP)
|
||||
install(CODE "execute_process(COMMAND ${CHMOD} 2775 \"\${CMAKE_INSTALL_PREFIX}/data/backups\")")
|
||||
install(CODE "execute_process(COMMAND ${CHMOD} 2775 \"\${CMAKE_INSTALL_PREFIX}/data/logs\")")
|
||||
install(CODE "execute_process(COMMAND ${CHMOD} 2775 \"\${CMAKE_INSTALL_PREFIX}/data/modules/runtime\")")
|
||||
install(CODE "execute_process(COMMAND ${CHMOD} 2775 \"\${DB_DIR}/backups\")")
|
||||
install(CODE "execute_process(COMMAND ${CHMOD} 2775 \"\${LOGS_DIR}\")")
|
||||
install(CODE "execute_process(COMMAND ${CHMOD} 2775 \"\${LIB_DIR}/modules/runtime\")")
|
||||
install(CODE "execute_process(COMMAND ${CHGRP} -R ${RUNGROUP} \"\${CMAKE_INSTALL_PREFIX}\")")
|
||||
endif(NOT WIN32 AND RUNGROUP)
|
||||
# On Windows platforms, install extra files
|
||||
if(WIN32)
|
||||
install(FILES ${Anope_SOURCE_DIR}/src/win32/anope.bat
|
||||
DESTINATION bin
|
||||
DESTINATION ${BIN_DIR}
|
||||
)
|
||||
endif(WIN32)
|
||||
|
||||
|
||||
@@ -67,6 +67,12 @@ Run_Build_System () {
|
||||
RUN_CC_PL="-DUSE_RUN_CC_PL:BOOLEAN=OFF"
|
||||
fi
|
||||
|
||||
if [ "$USE_PCH" = "yes" ] ; then
|
||||
PCH="-DUSE_PCH:BOOLEAN=ON"
|
||||
else
|
||||
PCH="-DUSE_PCH:BOOLEAN=OFF"
|
||||
fi
|
||||
|
||||
case `uname -s` in
|
||||
MINGW*)
|
||||
GEN_TYPE="-G\"MSYS Makefiles\""
|
||||
@@ -82,9 +88,9 @@ Run_Build_System () {
|
||||
REAL_SOURCE_DIR="$SOURCE_DIR"
|
||||
fi
|
||||
|
||||
echo "cmake $GEN_TYPE $WITH_INST $WITH_RUN $WITH_PERM $BUILD_TYPE $RUN_CC_PL $EXTRA_CONFIG_ARGS $REAL_SOURCE_DIR"
|
||||
echo "cmake $GEN_TYPE $WITH_INST $WITH_RUN $WITH_PERM $BUILD_TYPE $RUN_CC_PL $PCH $EXTRA_CONFIG_ARGS $REAL_SOURCE_DIR"
|
||||
|
||||
cmake $GEN_TYPE $WITH_INST $WITH_RUN $WITH_PERM $BUILD_TYPE $RUN_CC_PL $EXTRA_CONFIG_ARGS $REAL_SOURCE_DIR
|
||||
cmake $GEN_TYPE $WITH_INST $WITH_RUN $WITH_PERM $BUILD_TYPE $RUN_CC_PL $PCH $EXTRA_CONFIG_ARGS $REAL_SOURCE_DIR
|
||||
|
||||
echo ""
|
||||
if [ "$SOURCE_DIR" = "." ] ; then
|
||||
@@ -117,6 +123,7 @@ RUNGROUP=
|
||||
UMASK=
|
||||
DEBUG="yes"
|
||||
USE_RUN_CC_PL="no"
|
||||
USE_PCH="no"
|
||||
EXTRA_CONFIG_ARGS=
|
||||
CAN_QUICK="no"
|
||||
SOURCE_DIR=`dirname $0`
|
||||
@@ -209,23 +216,7 @@ if [ ! "$NO_INTRO" ] ; then
|
||||
;;
|
||||
esac
|
||||
. $SOURCE_DIR/src/version.sh
|
||||
if [ -d .git ] ; then
|
||||
VERSION=`git describe --tags`
|
||||
VERSION_BUILD=`echo "$VERSION" | cut -d'-' -f2`
|
||||
if [ "$SOURCE_DIR" = "." ] ; then
|
||||
test -d build || mkdir -p build/include
|
||||
BUILD_DIR="build"
|
||||
else
|
||||
BUILD_DIR="."
|
||||
fi
|
||||
VERSION_EXTRA=`echo "$VERSION" | cut -d'-' -f3`
|
||||
# Only do this if we are not on a tag, src/version.sh will be all we need then.
|
||||
if [ "$VERSION_BUILD" != "$VERSION_EXTRA" ] ; then
|
||||
echo "#define VERSION_BUILD $VERSION_BUILD" > $BUILD_DIR/include/version.h
|
||||
echo "#define VERSION_EXTRA \"-$VERSION_EXTRA\"" >> $BUILD_DIR/include/version.h
|
||||
fi
|
||||
fi
|
||||
cat $SOURCE_DIR/.BANNER | sed "s/CURVER/$VERSION/" | sed "s@SOURCE_DIR@$SOURCE_DIR@" | $PAGER
|
||||
cat $SOURCE_DIR/.BANNER | sed "s/CURVER/$VERSION_MAJOR.$VERSION_MINOR.$VERSION_PATCH$VERSION_EXTRA/" | sed "s@SOURCE_DIR@$SOURCE_DIR@" | $PAGER
|
||||
echo ""
|
||||
else
|
||||
echo ""
|
||||
@@ -376,6 +367,25 @@ echo ""
|
||||
|
||||
####
|
||||
|
||||
TEMP_YN="n"
|
||||
if [ "$USE_PCH" = "yes" ] ; then
|
||||
TEMP_YN="y"
|
||||
fi
|
||||
echo "Do you want to build using precompiled headers? This can speed up"
|
||||
echo "the build, but uses more disk space."
|
||||
echo2 "[$TEMP_YN] "
|
||||
read YN
|
||||
if [ "$YN" ] ; then
|
||||
if [ "$YN" = "y" ] ; then
|
||||
USE_PCH="yes"
|
||||
else
|
||||
USE_PCH="no"
|
||||
fi
|
||||
fi
|
||||
echo ""
|
||||
|
||||
####
|
||||
|
||||
echo "Are there any extra arguments you wish to pass to cmake?"
|
||||
echo "You may only need to do this if cmake is unable to locate"
|
||||
echo "missing dependencies without hints."
|
||||
@@ -401,6 +411,7 @@ RUNGROUP="$RUNGROUP"
|
||||
UMASK=$UMASK
|
||||
DEBUG="$DEBUG"
|
||||
USE_RUN_CC_PL="$USE_RUN_CC_PL"
|
||||
USE_PCH="$USE_PCH"
|
||||
EXTRA_CONFIG_ARGS="$EXTRA_CONFIG_ARGS"
|
||||
EOT
|
||||
echo "done."
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
# Only install example.chk and example.conf from this directory
|
||||
# NOTE: I would've had this just find all files in the directory, but that would include files not needed (like this file)
|
||||
set(DATA example.chk botserv.example.conf example.conf hostserv.example.conf modules.example.conf operserv.example.conf chanserv.example.conf global.example.conf memoserv.example.conf nickserv.example.conf)
|
||||
set(DATA example.chk botserv.example.conf example.conf hostserv.example.conf modules.example.conf operserv.example.conf chanserv.example.conf global.example.conf memoserv.example.conf nickserv.example.conf chanstats.example.conf)
|
||||
install(FILES ${DATA}
|
||||
DESTINATION data
|
||||
DESTINATION ${CONF_DIR}
|
||||
)
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
/*
|
||||
* First, create the service.
|
||||
* Note that an easy way to rename this service is to define{} the client name to something else.
|
||||
*/
|
||||
service
|
||||
{
|
||||
@@ -247,3 +248,63 @@ command { service = "BotServ"; name = "KICK"; command = "botserv/kick"; }
|
||||
module { name = "bs_set" }
|
||||
command { service = "BotServ"; name = "SET"; command = "botserv/set"; }
|
||||
|
||||
/*
|
||||
* bs_set_dontkickops
|
||||
*
|
||||
* Provides the command botserv/set/dontkickops.
|
||||
*
|
||||
* Used for preventing BotServ from kicking channel operators.
|
||||
*/
|
||||
module { name = "bs_set_dontkickops" }
|
||||
command { service = "BotServ"; name = "SET DONTKICKOPS"; command = "botserv/set/dontkickops"; }
|
||||
|
||||
/*
|
||||
* bs_set_dontkickvoices
|
||||
*
|
||||
* Provides the command botserv/set/dontkickvoices.
|
||||
*
|
||||
* Used for preventing BotServ from kicking voices.
|
||||
*/
|
||||
module { name = "bs_set_dontkickvoices" }
|
||||
command { service = "BotServ"; name = "SET DONTKICKVOICES"; command = "botserv/set/dontkickvoices"; }
|
||||
|
||||
/*
|
||||
* bs_set_fantasy
|
||||
*
|
||||
* Provides the command botserv/set/fantasy.
|
||||
*
|
||||
* Used for enabling or disabling BotServ's fantaisist commands.
|
||||
*/
|
||||
module { name = "bs_set_fantasy" }
|
||||
command { service = "BotServ"; name = "SET FANTASY"; command = "botserv/set/fantasy"; }
|
||||
|
||||
/*
|
||||
* bs_set_greet
|
||||
*
|
||||
* Provides the command botserv/set/greet.
|
||||
*
|
||||
* Used for enabling or disabling BotServ's greet messages in a channel.
|
||||
*/
|
||||
module { name = "bs_set_greet" }
|
||||
command { service = "BotServ"; name = "SET GREET"; command = "botserv/set/greet"; }
|
||||
|
||||
/*
|
||||
* bs_set_nobot
|
||||
*
|
||||
* Provides the command botserv/set/nobot.
|
||||
*
|
||||
* Used by Services Operators to prohibit specific channels from being assigned BotServ bots.
|
||||
*/
|
||||
module { name = "bs_set_nobot" }
|
||||
command { service = "BotServ"; name = "SET NOBOT"; command = "botserv/set/nobot"; }
|
||||
|
||||
/*
|
||||
* bs_set_private
|
||||
*
|
||||
* Provides the command botserv/set/private.
|
||||
*
|
||||
* Used by Services Operators to prohibit specific BotServ bots from being assigned to channels.
|
||||
*/
|
||||
module { name = "bs_set_private" }
|
||||
command { service = "BotServ"; name = "SET PRIVATE"; command = "botserv/set/private"; }
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
/*
|
||||
* First, create the service.
|
||||
* Note that an easy way to rename this service is to define{} the client name to something else.
|
||||
*/
|
||||
service
|
||||
{
|
||||
@@ -171,6 +172,32 @@ chanserv
|
||||
* This directive is optional.
|
||||
*/
|
||||
#opersonly = yes
|
||||
|
||||
/*
|
||||
* Default modes for mode lock, these are set on newly registered channels.
|
||||
*
|
||||
* If not set, the default is +nrt.
|
||||
*/
|
||||
mlock = "+nrt"
|
||||
|
||||
/*
|
||||
* Modes that will not be allowed to be locked. Oper only modes such as +O
|
||||
* are always restricted from regular users and are not affected by this.
|
||||
* Comment out for no restrictions.
|
||||
*/
|
||||
#nomlock = "P"
|
||||
|
||||
/*
|
||||
* Modes that are required to be set and only set on all registered channels.
|
||||
* These modes can not be locked or unlocked.
|
||||
*/
|
||||
require = "r"
|
||||
|
||||
/*
|
||||
* Some IRCds can enforce mode locks server-side. This reduces the spam caused by
|
||||
* services immediately reversing mode changes for locked modes.
|
||||
*/
|
||||
use_server_side_mlock = yes
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -205,7 +232,7 @@ privilege
|
||||
{
|
||||
name = "ACCESS_CHANGE"
|
||||
desc = "Allowed to modify the access list"
|
||||
rank = 290
|
||||
rank = 0
|
||||
level = 10
|
||||
flag = "f"
|
||||
}
|
||||
@@ -222,7 +249,7 @@ privilege
|
||||
name = "ACCESS_LIST"
|
||||
desc = "Allowed to view the access list"
|
||||
rank = 10
|
||||
level = 10
|
||||
level = 3
|
||||
flag = "f"
|
||||
}
|
||||
|
||||
@@ -552,7 +579,7 @@ privilege
|
||||
name = "MODE"
|
||||
desc = "Allowed to use the MODE command"
|
||||
rank = 170
|
||||
level = 5
|
||||
level = 9999
|
||||
flag = "s"
|
||||
}
|
||||
|
||||
@@ -636,7 +663,7 @@ privilege
|
||||
name = "OWNERME"
|
||||
desc = "Allowed to (de)owner him/herself"
|
||||
rank = 340
|
||||
level = "9999"
|
||||
level = 9999
|
||||
flag = "q"
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Example configuration file for chanstats
|
||||
* Make sure BotServ, ChanServ and NickServ are running.
|
||||
*/
|
||||
|
||||
module { name = "m_chanstats" }
|
||||
|
||||
chanstats
|
||||
{
|
||||
/*
|
||||
* The name of this engine.
|
||||
* This must match with the name of a SQL engine block
|
||||
*/
|
||||
|
||||
engine = "mysql/main"
|
||||
|
||||
/*
|
||||
* An optional prefix to prepended to the name of each created table.
|
||||
* Do not use the same prefix for other programs.
|
||||
*/
|
||||
prefix = "anope_"
|
||||
|
||||
smileyshappy = ":) :-) ;) :D :-D"
|
||||
smileyssad = ":( :-( ;( ;-("
|
||||
smileysother = ":/"
|
||||
|
||||
/*
|
||||
* Enable Chanstats for new registered nicks / channels
|
||||
* set it to 0 to disable it.
|
||||
*/
|
||||
NSDefChanstats = 1
|
||||
CSDefChanstats = 1
|
||||
}
|
||||
|
||||
|
||||
module { name = "cs_set_chanstats" }
|
||||
command { service = "ChanServ"; name = "SET CHANSTATS"; command = "chanserv/set/chanstats"; }
|
||||
|
||||
module { name = "ns_set_chanstats" }
|
||||
command { service = "NickServ"; name = "SET CHANSTATS"; command = "nickserv/set/chanstats"; }
|
||||
|
||||
module { name = "cs_fantasy_stats" }
|
||||
command { service = "ChanServ"; name = "STATS"; command = "chanserv/stats"; }
|
||||
command { service = "ChanServ"; name = "GSTATS"; command = "chanserv/gstats"; }
|
||||
|
||||
module { name = "cs_fantasy_top" }
|
||||
command { service = "ChanServ"; name = "TOP"; command = "chanserv/top"; }
|
||||
command { service = "ChanServ"; name = "TOP10"; command = "chanserv/top10"; }
|
||||
command { service = "ChanServ"; name = "GTOP"; command = "chanserv/gtop"; }
|
||||
command { service = "ChanServ"; name = "GTOP10"; command = "chanserv/gtop10"; }
|
||||
+73
-54
@@ -205,15 +205,15 @@ serverinfo
|
||||
|
||||
/*
|
||||
* The filename containing the Services process ID. The path is relative to the
|
||||
* services executable. If not given, defaults to "services.pid".
|
||||
* services root directory. If not given, defaults to "data/services.pid".
|
||||
*/
|
||||
pid = "services.pid"
|
||||
pid = "data/services.pid"
|
||||
|
||||
/*
|
||||
* The filename containing the Message of the Day. The path is relative to the
|
||||
* services executable. If not given, defaults to "services.motd".
|
||||
* services root directory. If not given, defaults to "conf/services.motd".
|
||||
*/
|
||||
motd = "services.motd"
|
||||
motd = "conf/services.motd"
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -276,25 +276,37 @@ networkinfo
|
||||
*/
|
||||
options
|
||||
{
|
||||
/*
|
||||
* The case mapping used by services. This must be set to a valid locale name
|
||||
* installed on your machine. Services use this case map to compare, with
|
||||
* case insensitivity, things such as nick names, channel names, etc.
|
||||
*
|
||||
* We provide two special casemaps shipped with Anope, ascii and rfc1459.
|
||||
*
|
||||
* This value should be set to what your IRCd uses, which is probably rfc1459,
|
||||
* however Anope has always used ascii for comparison, so the default is ascii.
|
||||
*
|
||||
* Changing this value once set is not recommended.
|
||||
*/
|
||||
casemap = "ascii"
|
||||
|
||||
/*
|
||||
* The maximum length of passwords
|
||||
*/
|
||||
passlen = 32
|
||||
|
||||
/*
|
||||
* These keys are used to initiate the random number generator. These numbers
|
||||
* MUST be random as you want your passcodes to be random. Don't give these
|
||||
* keys to anyone! Keep them private!
|
||||
* This key is used to initiate the random number generator. This number
|
||||
* MUST be random as you want your passcodes to be random. Don't give this
|
||||
* key to anyone! Keep it private!
|
||||
*
|
||||
* NOTE: If you don't uncomment these or keep their default values, any talented
|
||||
* NOTE: If you don't uncomment this or keep the default values, any talented
|
||||
* programmer would be able to easily "guess" random strings used to mask
|
||||
* information. Be safe, and come up with three different 7-digit numbers.
|
||||
* information. Be safe, and come up with a 7-digit number.
|
||||
*
|
||||
* These directives are optional, but highly recommended.
|
||||
* This directive is optional, but highly recommended.
|
||||
*/
|
||||
#userkey1 = 9866235
|
||||
#userkey2 = 8362013
|
||||
#userkey3 = 2362899
|
||||
#seed = 9866235
|
||||
|
||||
/*
|
||||
* Allows Services to continue file write operations (i.e. database saving)
|
||||
@@ -479,18 +491,6 @@ options
|
||||
*/
|
||||
#ulineservers = "stats.your.network"
|
||||
|
||||
/*
|
||||
* Default modes for mode lock, these are set on newly registered channels.
|
||||
*/
|
||||
mlock = "+nrt"
|
||||
|
||||
/*
|
||||
* Modes that will not be allowed to be locked. Oper only modes such as +O
|
||||
* are always restricted from regular users and are not affected by this.
|
||||
* Comment out for no restrictions.
|
||||
*/
|
||||
nomlock = "z"
|
||||
|
||||
/*
|
||||
* Modes to set on service bots when they join channels, comment this out for no modes
|
||||
*
|
||||
@@ -513,6 +513,13 @@ options
|
||||
* If set, Services do not allow ownership of nick names, only ownership of accounts.
|
||||
*/
|
||||
nonicknameownership = no
|
||||
|
||||
/* The regex engine to use, as provided by the regex modules.
|
||||
* Leave commented to disable regex matching.
|
||||
*
|
||||
* Note for this to work the regex module providing the regex engine must be loaded.
|
||||
*/
|
||||
regexengine = "regex/pcre"
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -667,13 +674,13 @@ log
|
||||
* pesudo-serv/commandname (eg, operserv/akill, chanserv/set)
|
||||
*
|
||||
* Valid server options are:
|
||||
* connect, quit, sync
|
||||
* connect, quit, sync, squit
|
||||
*
|
||||
* Valid channel options are:
|
||||
* create, destroy, join, part, kick, leave, mode
|
||||
*
|
||||
* Valid user options are:
|
||||
* connect, disconnect, quit, nick, ident, host, mode, maxusers
|
||||
* connect, disconnect, quit, nick, ident, host, mode, maxusers, oper
|
||||
*
|
||||
* Rawio and debug are simple yes/no answers, there are no types for them.
|
||||
*
|
||||
@@ -696,7 +703,10 @@ log
|
||||
log
|
||||
{
|
||||
target = "globops"
|
||||
admin = "global/* operserv/mode operserv/kick operserv/akill operserv/s*line operserv/noop operserv/jupe */forbid nickserv/getpass */drop"
|
||||
admin = "global/* operserv/mode operserv/kick operserv/akill operserv/s*line operserv/noop operserv/jupe operserv/oline operserv/set operserv/svsnick nickserv/getpass */drop"
|
||||
servers = "squit"
|
||||
users = "oper"
|
||||
other = "expire/* bados akill/*"
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -743,7 +753,7 @@ log
|
||||
* memoserv/sendall memoserv/staff
|
||||
*
|
||||
* nickserv/getpass nickserv/sendpass nickserv/getemail nickserv/suspend
|
||||
* nickserv/resetpass
|
||||
* nickserv/resetpass nickserv/release nickserv/list
|
||||
*
|
||||
* nickserv/saset/autoop nickserv/saset/email nickserv/saset/greet
|
||||
* nickserv/saset/icq nickserv/saset/kill nickserv/saset/language nickserv/saset/message
|
||||
@@ -788,7 +798,7 @@ opertype
|
||||
inherits = "Helper, Another Helper"
|
||||
|
||||
/* What commands (see above) this opertype may use */
|
||||
commands = "chanserv/list chanserv/suspend chanserv/topic memoserv/staff nickserv/sendpass nickserv/resetpass nickserv/suspend operserv/mode operserv/chankill operserv/szline operserv/akill operserv/session operserv/modlist operserv/sqline operserv/oper operserv/kick operserv/ignore operserv/snline"
|
||||
commands = "chanserv/list chanserv/suspend chanserv/topic memoserv/staff nickserv/list nickserv/sendpass nickserv/resetpass nickserv/suspend operserv/mode operserv/chankill operserv/szline operserv/akill operserv/session operserv/modlist operserv/sqline operserv/oper operserv/kick operserv/ignore operserv/snline"
|
||||
|
||||
/* What privs (see above) this opertype has */
|
||||
privs = "chanserv/auspex chanserv/no-register-limit memoserv/* nickserv/auspex nickserv/confirm"
|
||||
@@ -1095,38 +1105,37 @@ db_flatfile
|
||||
* db_sql
|
||||
*
|
||||
* This module allows saving and loading databases using one of the SQL engines.
|
||||
* This module loads the databases once on startup, then incrementally updates
|
||||
* objects in the database as they are changed within Anope in real time. Changes
|
||||
* to the SQL tables not done by Anope will have no effect and will be overwritten.
|
||||
*
|
||||
* WARNING: This module will delete every table in the database it uses. Be sure
|
||||
* to put Anope in its own separate database.
|
||||
*/
|
||||
#module { name = "db_sql" }
|
||||
|
||||
/*
|
||||
* db_sql_live
|
||||
*
|
||||
* This module allows saving and loading databases using one of the SQL engines.
|
||||
* This module reads and writes to SQL in real time. Changes to the SQL tables
|
||||
* will be immediately reflected into Anope. This module should not be loaded
|
||||
* in conjunction with db_sql.
|
||||
*/
|
||||
#module { name = "db_sql_live" }
|
||||
|
||||
db_sql
|
||||
{
|
||||
/*
|
||||
* The SQL service db_sql should use, these are configured in modules.conf.
|
||||
* The SQL service db_sql(_live) should use, these are configured in modules.conf.
|
||||
* For MySQL, this should probably be mysql/main.
|
||||
*/
|
||||
engine = "sqlite/main"
|
||||
}
|
||||
|
||||
/*
|
||||
* db_sql_live_read, db_sql_live_write
|
||||
*
|
||||
* Enables (live) SQL support.
|
||||
*
|
||||
* The db_sql_live modules are an extension to db_sql, and should only be used if
|
||||
* db_sql is being used.
|
||||
*
|
||||
* The db_sql_live_read module pulls data in real time from
|
||||
* SQL as it is needed by the core.
|
||||
* At this time this supports the three main tables: ChannelInfo, NickAlias, and NickCore.
|
||||
*
|
||||
* The db_sql_live_write module writes data to SQL in real time as it is modified by
|
||||
* the core.
|
||||
*
|
||||
*/
|
||||
#module { name = "db_sql_live_read" }
|
||||
#module { name = "db_sql_live_write" }
|
||||
/*
|
||||
* An optional prefix to prepended to the name of each created table.
|
||||
* Do not use the same prefix for other programs.
|
||||
*/
|
||||
#prefix = "anope_db_"
|
||||
}
|
||||
|
||||
/*
|
||||
* [REQUIRED] Encryption modules.
|
||||
@@ -1176,7 +1185,17 @@ module { name = "enc_md5" }
|
||||
/* Extra (optional) modules */
|
||||
include
|
||||
{
|
||||
type = "file"
|
||||
name = "modules.example.conf"
|
||||
type = "file"
|
||||
name = "modules.example.conf"
|
||||
}
|
||||
|
||||
/*
|
||||
* Chanstats Modules
|
||||
* Requires a MySQL Database
|
||||
*/
|
||||
|
||||
#include
|
||||
#{
|
||||
# type = "file"
|
||||
# name = "chanstats.example.conf"
|
||||
#}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
/*
|
||||
* First, create the service.
|
||||
* Note that an easy way to rename this service is to define{} the client name to something else.
|
||||
*/
|
||||
service
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
/*
|
||||
* First, create the service.
|
||||
* Note that an easy way to rename this service is to define{} the client name to something else.
|
||||
*/
|
||||
service
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
/*
|
||||
* First, create the service.
|
||||
* Note that an easy way to rename this service is to define{} the client name to something else.
|
||||
*/
|
||||
service
|
||||
{
|
||||
|
||||
+104
-3
@@ -91,6 +91,38 @@ m_helpchan
|
||||
helpchannel = "#help"
|
||||
}
|
||||
|
||||
/*
|
||||
* m_httpd
|
||||
*
|
||||
* Allows services to serve web pages. By itself, this module does nothing useful.
|
||||
*
|
||||
* Note that using this will allow users to get the IP of your services.
|
||||
* To prevent this we recommend using a reverse proxy or a tunnel.
|
||||
*/
|
||||
#module { name = "m_httpd" }
|
||||
httpd
|
||||
{
|
||||
/* Name of this service */
|
||||
name = "httpd/main"
|
||||
|
||||
/* IP to listen on */
|
||||
ip = "0.0.0.0"
|
||||
/* Port to listen on */
|
||||
port = 8080
|
||||
/* Time before connections to this server are timed out */
|
||||
timeout = 30
|
||||
|
||||
/* If you are using a reverse proxy that sends one of the
|
||||
* extforward_headers set below, set this to its IP.
|
||||
* This allows services to obtain the real IP of users by
|
||||
* reading the forwarded-for HTTP header.
|
||||
*/
|
||||
#extforward_ip = "192.168.0.255"
|
||||
|
||||
/* The header to look for. These probably work as is. */
|
||||
extforward_header = "X-Forwarded-For Forwarded-For"
|
||||
}
|
||||
|
||||
/*
|
||||
* m_ldap
|
||||
*
|
||||
@@ -101,6 +133,10 @@ ldap
|
||||
{
|
||||
server = "ldap://127.0.0.1"
|
||||
port = 389
|
||||
|
||||
/*
|
||||
* Admin credentials used for performing searches and adding users.
|
||||
*/
|
||||
admin_binddn = "cn=Manager,dc=anope,dc=org"
|
||||
admin_password = "secret"
|
||||
}
|
||||
@@ -115,9 +151,16 @@ ldap
|
||||
m_ldap_authentication
|
||||
{
|
||||
/*
|
||||
* The distinguished name we should bind to when a user tries to identify.
|
||||
* The distinguished name used for searching for users's accounts.
|
||||
*/
|
||||
binddn = "ou=users,dc=anope,dc=org"
|
||||
basedn = "ou=users,dc=anope,dc=org"
|
||||
|
||||
/*
|
||||
* The search filter used to look up users's accounts.
|
||||
* %account is replaced with the user's account
|
||||
* %object_class is replaced with the object_class configured below.
|
||||
*/
|
||||
search_filter = "(&(uid=%account)(objectClass=%object_class))"
|
||||
|
||||
/*
|
||||
* The object class used by LDAP to store user account information.
|
||||
@@ -215,7 +258,7 @@ mysql
|
||||
* m_proxyscan
|
||||
*
|
||||
* This module allows you to scan connecting clients for open proxies.
|
||||
* Note that using this will allow users to get the IP or your services.
|
||||
* Note that using this will allow users to get the IP of your services.
|
||||
*
|
||||
* Currently the two supported proxy types are HTTP and SOCKS5.
|
||||
*
|
||||
@@ -310,6 +353,28 @@ sqlite
|
||||
database = "anope.db"
|
||||
}
|
||||
|
||||
/*
|
||||
* m_regex_pcre
|
||||
*
|
||||
* Provides the regex engine regex/pcre, which uses the Perl Compatible Regular Expressions library.
|
||||
*/
|
||||
module { name = "m_regex_pcre" }
|
||||
|
||||
/*
|
||||
* m_regex_posix
|
||||
*
|
||||
* Provides the regex engine regex/posix, which uses the POSIX compliant regular expressions.
|
||||
* This is likely the only regex module you will not need extra libraries for.
|
||||
*/
|
||||
#module { name = "m_regex_posix" }
|
||||
|
||||
/*
|
||||
* m_regex_tre
|
||||
*
|
||||
* Provides the regex engine regex/tre, which uses the TRE regex library.
|
||||
*/
|
||||
#module { name = "m_regex_tre" }
|
||||
|
||||
/*
|
||||
* m_rewrite
|
||||
*
|
||||
@@ -337,6 +402,19 @@ rewrite
|
||||
* This module uses SSL to connect to the uplink server(s)
|
||||
*/
|
||||
module { name = "m_ssl" }
|
||||
ssl
|
||||
{
|
||||
/*
|
||||
* An optional certificate and key for m_ssl to give to the uplink.
|
||||
*
|
||||
* You can generate your own certificate and key pair by using:
|
||||
*
|
||||
* openssl genrsa -out anope.key 2048
|
||||
* openssl req -new -x509 -key anope.key -out anope.crt -days 1095
|
||||
*/
|
||||
cert = "data/anope.crt"
|
||||
key = "data/anope.key"
|
||||
}
|
||||
|
||||
/*
|
||||
* m_statusupdate
|
||||
@@ -394,3 +472,26 @@ ns_maxemail
|
||||
#maxemails = 1
|
||||
}
|
||||
|
||||
/*
|
||||
* webcpanel
|
||||
*
|
||||
* This module creates a web configuration panel that allows users and operators to perform any task
|
||||
* as they could over IRC. If you are using the default configuration you should be able to access
|
||||
* this panel by visiting http://127.0.0.1:8080 in your web browser from the machine Anope is running on.
|
||||
*
|
||||
* This module requires m_httpd.
|
||||
*/
|
||||
#module { name = "webcpanel" }
|
||||
webcpanel
|
||||
{
|
||||
/* Web server to use */
|
||||
server = "httpd/main";
|
||||
|
||||
/* Template to use */
|
||||
template = "default";
|
||||
|
||||
/* Page title */
|
||||
title = "Anope IRC Services";
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
/*
|
||||
* First, create the service.
|
||||
* Note that an easy way to rename this service is to define{} the client name to something else.
|
||||
*/
|
||||
service
|
||||
{
|
||||
@@ -81,9 +82,18 @@ nickserv
|
||||
confirmemailchanges = no
|
||||
|
||||
/*
|
||||
* Require an e-mail to be sent to the user before they can register their nick.
|
||||
* Registration confirmation setting. Set to "none" for no registration confirmation,
|
||||
* "mail" for email confirmation, and "admin" to have services operators manually confirm
|
||||
* every registration. Set to "disable" to completely disable all registrations.
|
||||
*/
|
||||
#emailregistration = yes
|
||||
registration = "none"
|
||||
|
||||
/*
|
||||
* A message sent to users on connect if they user an unregistered nick.
|
||||
*
|
||||
* This directive is optional.
|
||||
*/
|
||||
#unregistered_notice = "Your nickname is not registered. To register it use /nickserv register password email."
|
||||
|
||||
/*
|
||||
* The default options for newly registered nicks. Note that changing these options
|
||||
@@ -211,8 +221,8 @@ nickserv
|
||||
guestnickprefix = "Guest"
|
||||
|
||||
/*
|
||||
* Prevents the use of the ACCESS, DROP, FORBID, GETPASS, and SET PASSWORD commands by Services Admins
|
||||
* on other Services Admins or the Services Root(s).
|
||||
* Prevents the use of the ACCESS (excluding the LIST subcommand), DROP, FORBID, SUSPEND,
|
||||
* GETPASS and SET PASSWORD commands by services operators on other services operators.
|
||||
*
|
||||
* This directive is optional, but recommended.
|
||||
*/
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
/*
|
||||
* First, create the service.
|
||||
* Note that an easy way to rename this service is to define{} the client name to something else.
|
||||
*/
|
||||
service
|
||||
{
|
||||
@@ -110,21 +111,6 @@ operserv
|
||||
*/
|
||||
#killonsqline = yes
|
||||
|
||||
/*
|
||||
* Defines what actions should trigger notifications. The list must be separated by spaces.
|
||||
*
|
||||
* The notifications are:
|
||||
* - oper: A user has become an IRC operator
|
||||
* - bados: A non-IRCop attempts to use OperServ
|
||||
* - akillexpire: An AKILL has expired
|
||||
* - snlineexpire: An SNLINE has expired
|
||||
* - sqlineexpire: An SQLINE has expired
|
||||
* - exceptionexpire: A session exception has expired
|
||||
*
|
||||
* This directive is optional, if left blank, there will be no notifications.
|
||||
*/
|
||||
notifications = "oper"
|
||||
|
||||
/*
|
||||
* Enables session limiting. Session limiting prevents users from connecting more than a certain
|
||||
* number of times from the same host at the same time - thus preventing most types of cloning.
|
||||
|
||||
@@ -1,3 +1,126 @@
|
||||
Revision 271d723 - Sun, 2 Sep 2012 08:31:11 -0400 - Update Changes
|
||||
Revision a0c4575 - Sun, 2 Sep 2012 08:31:04 -0400 - Regenerate language files
|
||||
Revision 1af64a9 - Sun, 2 Sep 2012 08:30:54 -0400 - Fix Windows
|
||||
Revision e3d5140 - Sat, 1 Sep 2012 18:54:51 -0400 - Added a web panel module + a default template
|
||||
Revision f81d011 - Tue, 28 Aug 2012 00:39:50 -0400 - Actually set xline's manager...
|
||||
Revision fde4289 - Thu, 9 Aug 2012 23:28:02 -0400 - Fixed db_old loading encrypted passwords from 1.8
|
||||
Revision f7bf2fa - Wed, 8 Aug 2012 17:09:34 -0400 - Put motd in conf/ not data/ and fixed the default values in the config
|
||||
Revision b894a56 - Wed, 8 Aug 2012 04:28:33 -0400 - Update pid and motd file paths
|
||||
Revision 48022c3 - Wed, 18 Jul 2012 16:52:14 -0400 - Warn about really big integer values in the config
|
||||
Revision 28aa981 - Sun, 1 Jul 2012 23:50:38 -0400 - Actually the core can't handle empty realnames, just ignore them
|
||||
Revision 2b8a09b - Sun, 1 Jul 2012 22:26:05 -0400 - Remove some unused code in inspircd20 protocol module & allow /chghost/ident/naming services clients
|
||||
Revision a12788e - Sun, 1 Jul 2012 22:26:05 -0400 - Don't crash on empty setnames on inspircd1.2
|
||||
Revision 9b5f6d3 - Sun, 1 Jul 2012 22:26:05 -0400 - Remove ExtensibleString everywhere
|
||||
Revision af24dc6 - Tue, 26 Jun 2012 16:21:24 +0100 - Removed old set xop references and cleared up some other stuff.
|
||||
Revision f27560c - Tue, 26 Jun 2012 02:01:01 +0100 - Merge branch '1.9' of ssh://anope.git.sf.net/gitroot/anope/anope into 1.9
|
||||
Revision 4b309b5 - Mon, 25 Jun 2012 20:51:08 -0400 - Fixed accidentally recursion in User::SendMessage from last commit
|
||||
Revision d8a99d6 - Fri, 22 Jun 2012 21:26:33 +0100 - Merge branch '1.9' of ssh://anope.git.sf.net/gitroot/anope/anope into 1.9
|
||||
Revision 2dec8e7 - Mon, 18 Jun 2012 05:04:30 -0400 - Allow userless command sources
|
||||
Revision ba53c7e - Sun, 17 Jun 2012 22:23:22 +0100 - Updated MODULES somewhat
|
||||
Revision 873d428 - Mon, 11 Jun 2012 15:44:48 -0400 - Split up bs_set
|
||||
Revision 3626fb2 - Wed, 6 Jun 2012 15:16:46 -0400 - Fixed fd leak in win32/pipe.cpp
|
||||
Revision a661098 - Mon, 4 Jun 2012 05:45:13 +0100 - Some more fantasy character help output
|
||||
Revision a4bf5ce - Mon, 4 Jun 2012 04:50:35 +0100 - minor help output changes, including some confusion in fantasy chars
|
||||
Revision 437944d - Fri, 1 Jun 2012 04:43:26 -0400 - Merge branch '1.9' of anope.git.sf.net:/gitroot/anope/anope into 1.9
|
||||
Revision db37b1c - Fri, 1 Jun 2012 07:37:34 +0200 - updated chanstats
|
||||
Revision 1e49e9b - Sat, 26 May 2012 02:36:02 -0400 - This should actually be LOG_TERMINAL, quitmsg isn't logged to terminal on shutdown
|
||||
Revision 2cbfbc9 - Sat, 26 May 2012 02:15:48 -0400 - Some access level fixes from Robby to more closely match the historic levels, and some code cleanup
|
||||
Revision 38d5f20 - Thu, 24 May 2012 21:54:15 -0400 - Added a ./Config option for using precompiled headers
|
||||
Revision 70fb590 - Wed, 23 May 2012 19:35:56 -0400 - Add support for inspircd2.0+s mlock, improved on Unreal's, and made server side mlock usage configurable
|
||||
Revision bf7d1a5 - Wed, 23 May 2012 15:09:41 -0400 - Fixed some problems found by Robby
|
||||
Revision 1f73e27 - Sun, 20 May 2012 04:14:26 -0400 - Updated help messages for ns_list, cs_list, cs_entrymsg, and cs_info. Also fixed logging for cs_entrymsg.
|
||||
Revision 699087b - Sun, 20 May 2012 03:57:22 -0400 - Fixed cs_entrymsg loading entries from the database
|
||||
Revision ccd2908 - Thu, 17 May 2012 03:57:19 -0400 - reinterpret_cast off of a virtual base does Bad Things
|
||||
Revision a883362 - Thu, 17 May 2012 02:03:22 -0400 - Fixed not always calling operator bool() in dynamic_reference, which would mess up service references and do weird things
|
||||
Revision ef88385 - Tue, 15 May 2012 17:19:50 -0400 - m_ldap_authentication: Removed the dependency on a specific binddn in favour of searching the tree for matching criteria and using the returned DN
|
||||
Revision 90b0283 - Tue, 15 May 2012 04:27:36 -0400 - Grab the DN for every LDAP query and send it in the result
|
||||
Revision 0a8d46b - Mon, 14 May 2012 22:30:03 -0400 - Fixed parsing FMODE on inspircd 1.1
|
||||
Revision a84226e - Fri, 11 May 2012 00:50:58 -0400 - Do not show help for set message if useprivmsg is disabled
|
||||
Revision 9370b06 - Thu, 10 May 2012 17:53:53 -0400 - Fixed crash on access del + valgrind errors
|
||||
Revision d5ffae0 - Wed, 9 May 2012 03:37:37 -0400 - Made ssl cert and keyfiles configurable
|
||||
Revision f895997 - Wed, 9 May 2012 03:11:57 +0100 - fixed paste error (failed awesomeness) in last commit.
|
||||
Revision a81b3aa - Wed, 9 May 2012 01:23:34 +0100 - Fixed saving backups
|
||||
Revision 820e4ed - Tue, 8 May 2012 18:04:49 -0400 - Fixed some 100% cpu bugs with the new SQL stuff, and fixed sqlite+db_sql_live
|
||||
Revision 25586f3 - Tue, 8 May 2012 02:01:44 -0400 - Allow services operators to release other user's nicks, and allow services operators to view the access list of other operators
|
||||
Revision b7149fc - Sun, 6 May 2012 21:44:11 -0400 - Merge branch '1.9' of anope.git.sf.net:/gitroot/anope/anope into 1.9
|
||||
Revision 675b113 - Sun, 6 May 2012 21:43:50 -0400 - Split up db/conf/lib/locale install directories, and allow alternate ones to be specified at runtime
|
||||
Revision c797987 - Sat, 5 May 2012 09:35:18 +0200 - Readding missing valid nick check to ns register/group removed in os_forbid commit
|
||||
Revision eb0e07d - Fri, 4 May 2012 16:03:02 -0400 - Use Unreal's MLOCK command if supported
|
||||
Revision 1b5805e - Sun, 29 Apr 2012 20:39:33 -0400 - Set quitmsg on ERROR
|
||||
Revision 42e652c - Sun, 29 Apr 2012 19:24:37 -0400 - Pull table schemas from SQL on startup so we can alter the schemas if we need to, fixed sqlite to work again
|
||||
Revision 62818ab - Sun, 29 Apr 2012 15:43:51 -0400 - Added options:casemap to chose how case insensitive strings are compared, using ascii, rfc1459, or a locale installed on the system
|
||||
Revision 4d9a96e - Fri, 27 Apr 2012 17:06:16 -0400 - Fixes to db_sql
|
||||
Revision e490a54 - Fri, 27 Apr 2012 16:05:49 -0400 - Process defines even before includes, fixes defining{} pseudoclient names to something else in their respective configurations
|
||||
Revision 5068483 - Fri, 27 Apr 2012 15:38:50 -0400 - Add db_sql:prefix allow prefixing all anope tables similarly, and changed db_sql to update the databases incrementally instead of one big flush
|
||||
Revision 83ee20f - Wed, 25 Apr 2012 19:02:09 -0400 - Clarify access denied messages caused by NSSecureAdmins
|
||||
Revision b08aa4e - Wed, 25 Apr 2012 18:49:53 -0400 - Check for os_sesion to exist before having defcon try and place session bans
|
||||
Revision 1081ecd - Wed, 25 Apr 2012 14:29:50 -0400 - Fixed non-debug build
|
||||
Revision 2370c16 - Tue, 24 Apr 2012 16:02:07 -0400 - Fixed build from the previous merge
|
||||
Revision 3d84dc9 - Mon, 23 Apr 2012 05:17:02 -0400 - Merge branch '1.9' of anope.git.sf.net:/gitroot/anope/anope into 1.9
|
||||
Revision 573e49a - Mon, 23 Apr 2012 05:08:26 -0400 - Reworked live SQL support yet again
|
||||
Revision 63c639e - Mon, 23 Apr 2012 05:07:06 -0400 - Fixed hashm checking in db_old and loading 1.9.1 databases
|
||||
Revision fc00406 - Sun, 22 Apr 2012 02:57:17 -0400 - Fixed ./services --version etc not getting printed when stdout is a file/pipe/not a tty
|
||||
Revision b752c3a - Fri, 13 Apr 2012 18:33:22 +0200 - fixed a bug in chanstats
|
||||
Revision 7372b45 - Sun, 8 Apr 2012 19:29:56 +0200 - fixed a compile error in m_sqlite
|
||||
Revision deb5196 - Sun, 8 Apr 2012 12:43:34 +0200 - Added Chanstats. It uses a new, improved database format and is not compatible with current phpdenora or magirc installations.
|
||||
Revision 9e1fda2 - Sun, 8 Apr 2012 12:30:48 +0200 - Modified the SQL API to allow unescaped parameters (useful for passing row names and NULL values)
|
||||
Revision 9d249ef - Fri, 6 Apr 2012 14:41:28 -0400 - Fixed unpacking questions from dns packets
|
||||
Revision e03b73e - Fri, 6 Apr 2012 15:36:49 +0200 - Revert changes made to line endings.
|
||||
Revision 6b473f2 - Fri, 6 Apr 2012 15:12:22 +0200 - Revert last commit cause guess what, I screwed things up
|
||||
Revision 05bb80c - Fri, 6 Apr 2012 14:35:34 +0200 - Fixed mail function causing some MTAs to sent blank messages
|
||||
Revision e6edc65 - Sun, 1 Apr 2012 20:50:46 +0200 - updated the german language file
|
||||
Revision cf3124c - Sun, 1 Apr 2012 20:50:04 +0200 - fixed some typos
|
||||
Revision 12a6a27 - Tue, 27 Mar 2012 19:14:55 -0400 - Merge branch '1.9' of anope.git.sf.net:/gitroot/anope/anope into 1.9
|
||||
Revision 31a0e67 - Tue, 27 Mar 2012 19:01:29 -0400 - Fixed unpacking multiple names from dns packets when one has multiple compression pointers. Currently this will just fail at unpacking the later name due to offsets being invalid. Also cleaned up the existing code and made unpacking error messages more helpful.
|
||||
Revision 8d0b4a1 - Thu, 22 Mar 2012 07:30:38 +0100 - added a missing error message when a module file does not exist. this fixes bug #1401. also moved some debug messages to debug level 2
|
||||
Revision 1b0ebca - Wed, 21 Mar 2012 22:20:18 +0100 - fixed bug #1399
|
||||
Revision 0d100ff - Wed, 21 Mar 2012 20:25:25 +0100 - fixed ns_ajoin
|
||||
Revision 88fd1da - Tue, 13 Mar 2012 21:07:10 -0400 - Fixed typos
|
||||
Revision a069347 - Tue, 13 Mar 2012 19:26:11 -0400 - Actually check if the nicks arent registered, oops
|
||||
Revision a26f4b9 - Tue, 13 Mar 2012 17:45:07 -0400 - Bug #1389 - readd RNG seed in the config and start DNS query ids off on a random number
|
||||
Revision 053d6a2 - Tue, 13 Mar 2012 17:18:11 -0400 - Add a nickserv:unregistered_notice config option to send a message to unregistered users on connect. Suggested by Cronus.
|
||||
Revision beae477 - Tue, 13 Mar 2012 16:58:14 -0400 - Bug #1382 - Save maxusercount and maxusertime
|
||||
Revision cff91a5 - Sun, 11 Mar 2012 21:21:47 -0400 - Made gch files depend on the header they were generated from
|
||||
Revision 92ed5d7 - Sun, 11 Mar 2012 16:44:44 -0400 - Fixed having multiple uplink blocks work right if the first uplink fails on startup
|
||||
Revision 7800375 - Sun, 11 Mar 2012 05:20:28 -0400 - Bug #1384 - Fixed spacing of connection log message if users have no vhost - patch from cbiedl
|
||||
Revision ab25815 - Mon, 5 Mar 2012 20:15:56 -0500 - Fixed backup databases having their names collide due to not separating month and day, #1383
|
||||
Revision 8e01043 - Mon, 5 Mar 2012 14:29:48 -0500 - Fixed bs_kick syntax error
|
||||
Revision b7a6d51 - Sun, 4 Mar 2012 10:18:25 +0100 - fixed the --dir commandline parameter
|
||||
Revision 4ed844f - Fri, 2 Mar 2012 17:05:59 -0500 - Escape all column names when building sql queries
|
||||
Revision 020467d - Mon, 27 Feb 2012 00:16:15 -0500 - Fixed db_old loading noexpire
|
||||
Revision 141b87b - Sun, 26 Feb 2012 23:28:02 -0500 - Changed the OnChanDrop event to be called right before channels are dropped, not after
|
||||
Revision a5b9e23 - Sun, 26 Feb 2012 23:23:15 -0500 - Added chanserv:require config option to set which modes must be on all registered channels. Prevents the core from always enforcing +r on every channel, even if chanserv is not loaded.
|
||||
Revision a78790e - Sun, 26 Feb 2012 20:18:22 -0500 - Fixed vhost check on identify
|
||||
Revision 07226fe - Sun, 26 Feb 2012 19:49:02 -0500 - Track plexus umode and cmode +C and renamed UMODE_NO_CTCP to match up with the names of other modes.
|
||||
Revision e730138 - Sat, 25 Feb 2012 22:45:51 -0500 - Fixed missing #include in init.cpp
|
||||
Revision 2bc3bd3 - Sat, 25 Feb 2012 00:06:02 -0500 - Do not send kills after sending XLines because it causes us to internally remove the user and then recieve a quit from the user (who is now nonexistant) once the IRCd processes the XLine
|
||||
Revision 83456f6 - Fri, 24 Feb 2012 23:25:29 -0500 - Fixed akill setter and ids showing in akill reasons
|
||||
Revision 601dc41 - Fri, 24 Feb 2012 14:54:44 -0500 - Merge branch '1.9' of anope.git.sf.net:/gitroot/anope/anope into 1.9
|
||||
Revision 2337b77 - Fri, 24 Feb 2012 14:53:34 -0500 - Fixed calculating bots channel count of assigned channels and fixed the order of saving memos (among other things)
|
||||
Revision fde40de - Fri, 24 Feb 2012 01:50:21 +0000 - Tell users to use NickServ for registering nicks, not chanserv...
|
||||
Revision ba32aad - Thu, 23 Feb 2012 02:32:49 +0000 - Merge branch '1.9' of ssh://anope.git.sf.net/gitroot/anope/anope into 1.9
|
||||
Revision 24811e5 - Wed, 22 Feb 2012 20:55:59 -0500 - Added a configuration option to make all nick registrations require admin verification
|
||||
Revision f01aab5 - Thu, 23 Feb 2012 00:04:36 +0000 - Merge branch '1.9' of ssh://anope.git.sf.net/gitroot/anope/anope into 1.9
|
||||
Revision 3850b07 - Wed, 22 Feb 2012 18:12:02 -0500 - Added regex support for many commands, such as akill, sqline, snline, all of the */list commands, etc.
|
||||
Revision 81e50dd - Wed, 22 Feb 2012 16:25:20 -0500 - Fixed db_old loading memo owners
|
||||
Revision bd31fbb - Wed, 22 Feb 2012 14:41:36 -0500 - Also fixed m_proxyscan to handle users with invalid ips
|
||||
Revision 0006606 - Tue, 21 Feb 2012 20:50:14 -0500 - Fixed m_dnsbl handling users with spoofs/other non ips
|
||||
Revision 826de43 - Wed, 22 Feb 2012 00:28:58 +0000 - Fixed some trivial formatting
|
||||
Revision b84e080 - Sun, 19 Feb 2012 20:54:55 -0500 - Made our message sources actual clients/servers, and put in a few more default messages for very standard things (KICK etc)
|
||||
Revision 0ba58d7 - Sat, 18 Feb 2012 18:07:34 -0500 - Fixed some events
|
||||
Revision 1536c5c - Sat, 18 Feb 2012 17:21:55 -0500 - Add users hostmask to access lists not nick when access add is used on a non registered user
|
||||
Revision f2ce9cd - Sat, 18 Feb 2012 15:47:16 -0500 - Made mode lock del check status of the mode lock before removing it
|
||||
Revision ee5cd84 - Sat, 18 Feb 2012 15:04:26 -0500 - Use C++11's explicit override feature if available
|
||||
Revision 41e8d27 - Thu, 16 Feb 2012 16:02:17 -0500 - Fixed FreeBSD build
|
||||
Revision e1f5fc6 - Wed, 15 Feb 2012 00:06:25 -0500 - Remove revision numbers as they're only ever set by Config reading git since we've switched off of SVN. Instead just use the hash for the current head when building. Also recheck the hash on every make not just Config.
|
||||
Revision db59f1a - Tue, 14 Feb 2012 19:03:09 -0500 - Fixed detecting when to set +r and fixed crash on shutdown introduced by the last commit
|
||||
Revision a9772cd - Tue, 14 Feb 2012 15:13:27 -0500 - Clean up and reorganize our header files
|
||||
Revision 086790d - Mon, 13 Feb 2012 00:10:45 -0500 - Removed our RNG and just use the systems, it's not very widely used. Also made DNS query ids not random as they don't need to be.
|
||||
Revision 1bc8e2a - Wed, 8 Feb 2012 18:00:24 -0500 - Removed operserv:notifications in favor of log blocks, as well as some other notifiications
|
||||
Revision 089c85b - Sat, 4 Feb 2012 17:28:38 -0500 - Fixed WallBadOS
|
||||
Revision 01194e3 - Sat, 4 Feb 2012 13:12:11 -0500 - Bump for 1.9.7-git
|
||||
Revision f082530 - Fri, 3 Feb 2012 15:19:09 -0500 - Anope 1.9.6 Release
|
||||
Revision b906656 - Fri, 3 Feb 2012 15:18:27 -0500 - Update version.log
|
||||
Revision 378ae4c - Fri, 3 Feb 2012 15:18:06 -0500 - Regenerate language files
|
||||
Revision ce2a0f7 - Tue, 31 Jan 2012 16:19:47 -0500 - Fixed a memory leak in m_ldap
|
||||
Revision be5ba49 - Tue, 31 Jan 2012 15:44:04 -0500 - Not sure what I was thinking here
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ if(WIN32)
|
||||
endif(IN_SOURCE)
|
||||
set(DOCS Changes Changes.conf DEFCON FAQ INSTALL LANGUAGE MODULES NEWS ${CMAKE_CURRENT_BINARY_DIR}/README.txt WIN32.txt)
|
||||
install(FILES ${DOCS}
|
||||
DESTINATION docs
|
||||
DESTINATION ${DOC_DIR}
|
||||
)
|
||||
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${CMAKE_CURRENT_BINARY_DIR}/README.txt")
|
||||
endif(WIN32)
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
Anope Version 1.9.7
|
||||
--------------------
|
||||
A Added ability for using regex as patterns for various commands
|
||||
A Extended ability of operserv/akill to also match against nick and realname
|
||||
A Added chanserv:require configuration option
|
||||
A Added nickserv:unregistered_notice and nickserv:registration configuration option
|
||||
A Added options:casemap configuration option
|
||||
A Added a web panel
|
||||
A db_sql_live now allows all tables to be "live", not just a select few
|
||||
|
||||
Anope Version 1.9.6
|
||||
--------------------
|
||||
A Added ability to configure emails sent by services
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
Anope Version 1.9.7
|
||||
-------------------
|
||||
operserv:notifications removed in favor of log{} blocks
|
||||
options:regexengine added
|
||||
options:casemap added
|
||||
chanserv:require added
|
||||
nickserv:registration added, emailregistration removed.
|
||||
nickserv:unregistered_notice added
|
||||
|
||||
Anope Version 1.9.6
|
||||
-------------------
|
||||
service:channels added to join services to channels
|
||||
|
||||
+42
-38
@@ -22,16 +22,16 @@ Anope Modules
|
||||
1. If modules are supported by your system, they will be configured
|
||||
automatically when you run ./Config. The modules will be installed
|
||||
to the modules directory in your data path (by default this will
|
||||
be ~/services/modules).
|
||||
be ~/services/data/modules).
|
||||
|
||||
Note: you might need to run "make distclean" prior to running ./Config
|
||||
2. Compile Anope as usual using ./Config. The "make" process will now
|
||||
compile module support into Anope, and compile the default sample
|
||||
modules, and any other module located in the modules folder or any
|
||||
of its sub-directories, eg. modules/extra.
|
||||
|
||||
2. Compile Anope as usual. The (g)make process will now compile module
|
||||
support into Anope, and compile the default sample modules, and/or
|
||||
any other module located on the modules folder ("src/modules/").
|
||||
|
||||
3. Install Anope as usual. The install process will place the compiled
|
||||
modules in their runtime location, making them available for loading.
|
||||
3. Install Anope as usual. The "make install" process will place the
|
||||
compiled modules in their runtime location, making them available
|
||||
for loading.
|
||||
|
||||
4. Start or restart services to make use of the new Anope executable.
|
||||
Note that you do not need to restart to load new or changed modules,
|
||||
@@ -42,59 +42,64 @@ Anope Modules
|
||||
All module manipulation commands are done through OperServ. These are:
|
||||
|
||||
MODLOAD Load a module
|
||||
MODRELOAD Reload a module
|
||||
MODUNLOAD Un-Load a module
|
||||
MODLIST List loaded modules
|
||||
MODINFO Info about a loaded module
|
||||
|
||||
These commands available to Service Roots only.
|
||||
Access to the above commands require the operserv/modload and modlist
|
||||
permissions. Refer to operserv.example.conf.
|
||||
|
||||
You can also load (and pre-load) Modules automatically by loading them
|
||||
on startup. To do so, edit your services.conf file and change the values
|
||||
of "ModuleAutoload" and "ModuleDelayedAutoload" to include the modules
|
||||
you want to load every time Anope starts.
|
||||
on startup. To do so, edit any one of the configuration files (you may
|
||||
want to use modules.conf for third-party/extra modules, or a config
|
||||
file relevant to the *Serv your module operates on, eg. hostserv.conf),
|
||||
and use the following method to load a module on startup or reload:
|
||||
module { name="hs_modname" }
|
||||
|
||||
4) Usage Example
|
||||
|
||||
/msg OperServ modload hs_moo
|
||||
*** Global -- from OperServ: dengel loaded module hs_moo
|
||||
-OperServ- Module hs_moo loaded
|
||||
/msg OperServ modload ns_identify
|
||||
-OperServ- Module ns_identify loaded
|
||||
|
||||
/msg OperServ modinfo hs_moo
|
||||
-OperServ- Module: hs_moo Version: 1.1 Author: Anope loaded: Mar 21 10:54:37 2004 CLT
|
||||
-OperServ- Providing command: /msg HostServ moo
|
||||
/msg OperServ modinfo ns_identify
|
||||
-OperServ- Module: ns_identify Version: 1.9.7 Author: Anope loaded: Jun 17 18:43:08 2012 BST (2 minutes ago)
|
||||
-OperServ- Providing service: nickserv/identify
|
||||
-OperServ- Command ID on NickServ is linked to nickserv/identify
|
||||
-OperServ- Command IDENTIFY on NickServ is linked to nickserv/identify
|
||||
|
||||
/msg HostServ moo
|
||||
-HostServ- MOO! - This command was loaded via a module!
|
||||
/msg OperServ modreload ns_identify
|
||||
-OperServ- Module ns_identify reloaded
|
||||
|
||||
/msg OperServ modunload hs_moo
|
||||
*** Global -- from OperServ: dengel unloaded module hs_moo
|
||||
-OperServ- Module hs_moo unloaded
|
||||
/msg OperServ modunload ns_identify
|
||||
-OperServ- Module ns_identify unloaded
|
||||
|
||||
/msg HostServ moo
|
||||
-HostServ- Unknown command moo. "/msg HostServ HELP" for help.
|
||||
/msg NickServ IDENTIFY
|
||||
-NickServ- Unknown command identify. "/msg NickServ HELP" for help.
|
||||
NOTE: Doing the above, with the command still existing in a config file,
|
||||
will result in a log message, similar to the following:
|
||||
<@NickServ> Command IDENTIFY exists on me, but its service nickserv/identify was not found!
|
||||
|
||||
* Note that the name of the module file is "hs_moo.c", yet we load
|
||||
and reference the module as "hs_moo" only. By naming convention
|
||||
* Note that the name of the module source file is "ns_identify.cpp", yet we
|
||||
load and reference the module as "ns_identify" only. By naming convention
|
||||
modules have an abbreviated service name they attach to (hs_ for
|
||||
HostServ, cs_ for ChanServ, etc) followed by a descriptive keyword.
|
||||
|
||||
5) More Modules
|
||||
|
||||
Anope ships with three sample modules that only illustrates some of the
|
||||
implemented module capabilities. They don't really do much or anything
|
||||
useful.
|
||||
|
||||
You can download more useful modules from http://modules.anope.org/. Just
|
||||
grab the module file (usually with a .c extension). Place the module
|
||||
file in your modules (src/modules) folder; the same folder that contains
|
||||
both hs_moo.c and catserv.c module files.
|
||||
grab the module file (usually with a .cpp extension). Place the module
|
||||
file in your modules (anope-1.9.x/modules/third) folder; although any of
|
||||
the other folders within the modules directory will work.
|
||||
|
||||
The new modules need to be compiled and installed before you can make
|
||||
use of them:
|
||||
|
||||
|
||||
1. Make sure you're in the main source directory. (usually anope-1.X.XX/)
|
||||
2. Run `make modules` to compile any new or changed modules.
|
||||
3. Run `make install` to install the modules.
|
||||
2. Run ./Config to find and configure modules, then `cd build`.
|
||||
3. Run `make` to compile Anope, and any modules.
|
||||
4. Run `make install` to copy the compiled binaries to the ~/services/
|
||||
directory.
|
||||
|
||||
You can now use /msg OperServ MODLOAD to load the new modules.
|
||||
|
||||
@@ -115,7 +120,6 @@ Anope Modules
|
||||
|
||||
* http://wiki.anope.org/
|
||||
|
||||
|
||||
8) Modules Repository
|
||||
|
||||
You can find modules at http://modules.anope.org
|
||||
|
||||
+2
-2
@@ -17,9 +17,9 @@ channel - Takes one parameter, a channel name, and returns real time information
|
||||
|
||||
user - Takes one parameter, a user name, and returns real time information regarding that user.
|
||||
|
||||
XMLRPC was designed to be used with db_mysql, and will not return any information that can be pulled from the SQL
|
||||
XMLRPC was designed to be used with db_sql, and will not return any information that can be pulled from the SQL
|
||||
database, such as accounts and registered channel information. It is instead used for pulling realtime data such
|
||||
as users and channels currently onlive. For examples on how to use these calls in PHP, see xmlrpc.php in docs/XMLRPC.
|
||||
as users and channels currently online. For examples on how to use these calls in PHP, see xmlrpc.php in docs/XMLRPC.
|
||||
|
||||
Also note that the parameter named "id" is reserved for query ID. If you pass a query to Anope containing a value for id. it will
|
||||
be stored by Anope and the same id will be passed back in the result.
|
||||
|
||||
+25
-10
@@ -7,7 +7,7 @@ get_target_property(version_BINARY version LOCATION)
|
||||
# Modify version.h from the above executable, with dependencies to version.cpp
|
||||
# and all of the source files in the main build
|
||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/version_build
|
||||
COMMAND ${version_BINARY} ${Anope_SOURCE_DIR}/src/version.sh ${CMAKE_CURRENT_BINARY_DIR}/version.h
|
||||
COMMAND ${version_BINARY} ${Anope_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/version.h
|
||||
DEPENDS version ${SRC_SRCS}
|
||||
)
|
||||
# Add version to list of files for CPack to ignore
|
||||
@@ -18,13 +18,27 @@ if(NOT WIN32)
|
||||
endif(NOT WIN32)
|
||||
|
||||
set(PCH_SOURCES_GCH "")
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
string(REPLACE " " ";" PCH_CXXFLAGS ${CXXFLAGS})
|
||||
file(GLOB INCLUDE_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.h")
|
||||
remove_item_from_list(INCLUDE_SRCS "version.h")
|
||||
if(USE_PCH AND CMAKE_COMPILER_IS_GNUCXX)
|
||||
string(REPLACE " " ";" PCH_CXXFLAGS "${CXXFLAGS} ${CMAKE_CXX_FLAGS}")
|
||||
|
||||
file(GLOB PCH_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.h")
|
||||
sort_list(PCH_SOURCES)
|
||||
|
||||
set(PCH_SOURCES "module.h;modules.h;services.h")
|
||||
foreach(PCH_SOURCE ${PCH_SOURCES})
|
||||
find_includes(${PCH_SOURCE} INCLUDES)
|
||||
set(INCLUDES_LIST)
|
||||
append_to_list(INCLUDES_LIST ${PCH_SOURCE})
|
||||
foreach(INCLUDE ${INCLUDES})
|
||||
# Extract the filename from the #include line
|
||||
extract_include_filename(${INCLUDE} FILENAME QUOTE_TYPE)
|
||||
if(QUOTE_TYPE STREQUAL "quotes")
|
||||
find_in_list(PCH_SOURCES "${FILENAME}" FOUND)
|
||||
if(NOT FOUND EQUAL -1)
|
||||
append_to_list(INCLUDES_LIST ${FILENAME})
|
||||
endif(NOT FOUND EQUAL -1)
|
||||
endif(QUOTE_TYPE STREQUAL "quotes")
|
||||
endforeach(INCLUDE)
|
||||
|
||||
set(PCH_EXTRAFLAGS "")
|
||||
if(DEBUG_BUILD)
|
||||
set(PCH_EXTRAFLAGS "-g")
|
||||
@@ -33,16 +47,17 @@ if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
set(PCH_EXTRAFLAGS ${PCH_EXTRAFLAGS} -fPIC)
|
||||
endif(PCH_SOURCE STREQUAL "module.h")
|
||||
if(GETTEXT_INCLUDE)
|
||||
set(PCH_GETTEXT_INCLUDE "-I${GETTEXT_INCLUDE}")
|
||||
set(PCH_GETTEXT_INCLUDE "-I${GETTEXT_INCLUDE}")
|
||||
endif(GETTEXT_INCLUDE)
|
||||
|
||||
set(PCH_SOURCES_GCH "${PCH_SOURCES_GCH};${CMAKE_CURRENT_BINARY_DIR}/${PCH_SOURCE}.gch")
|
||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${PCH_SOURCE}.gch
|
||||
COMMAND ${CMAKE_CXX_COMPILER} ARGS ${PCH_CXXFLAGS} ${PCH_EXTRAFLAGS} ${PCH_GETTEXT_INCLUDE} -I${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/${PCH_SOURCE} -o ${CMAKE_CURRENT_BINARY_DIR}/${PCH_SOURCE}.gch
|
||||
DEPENDS ${INCLUDE_SRCS} VERBATIM
|
||||
COMMAND ${CMAKE_CXX_COMPILER} ARGS ${PCH_CXXFLAGS} ${PCH_EXTRAFLAGS}
|
||||
${PCH_GETTEXT_INCLUDE} -I${CMAKE_CURRENT_BINARY_DIR} -I${Anope_SOURCE_DIR}/modules/pseudoclients ${CMAKE_CURRENT_SOURCE_DIR}/${PCH_SOURCE} -o ${CMAKE_CURRENT_BINARY_DIR}/${PCH_SOURCE}.gch
|
||||
DEPENDS ${INCLUDES_LIST} VERBATIM
|
||||
)
|
||||
endforeach(PCH_SOURCE ${PCH_SOURCES})
|
||||
endif(CMAKE_COMPILER_IS_GNUCXX)
|
||||
endif(USE_PCH AND CMAKE_COMPILER_IS_GNUCXX)
|
||||
|
||||
# Add a custom target to the above file
|
||||
add_custom_target(headers DEPENDS version ${CMAKE_CURRENT_BINARY_DIR}/version_build ${PCH_SOURCES_GCH})
|
||||
|
||||
+32
-10
@@ -1,6 +1,24 @@
|
||||
/*
|
||||
*
|
||||
* (C) 2003-2012 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.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ACCESS_H
|
||||
#define ACCESS_H
|
||||
|
||||
#include "services.h"
|
||||
#include "anope.h"
|
||||
#include "serialize.h"
|
||||
#include "service.h"
|
||||
|
||||
enum
|
||||
{
|
||||
ACCESS_INVALID = -10000,
|
||||
@@ -28,7 +46,6 @@ class CoreExport PrivilegeManager
|
||||
static void ClearPrivileges();
|
||||
};
|
||||
|
||||
class ChanAccess;
|
||||
|
||||
class CoreExport AccessProvider : public Service
|
||||
{
|
||||
@@ -36,13 +53,18 @@ class CoreExport AccessProvider : public Service
|
||||
AccessProvider(Module *o, const Anope::string &n);
|
||||
virtual ~AccessProvider();
|
||||
virtual ChanAccess *Create() = 0;
|
||||
|
||||
private:
|
||||
static std::list<AccessProvider *> providers;
|
||||
public:
|
||||
static const std::list<AccessProvider *>& GetProviders();
|
||||
};
|
||||
|
||||
class CoreExport ChanAccess : public Serializable
|
||||
{
|
||||
public:
|
||||
AccessProvider *provider;
|
||||
ChannelInfo *ci;
|
||||
serialize_obj<ChannelInfo> ci;
|
||||
Anope::string mask;
|
||||
Anope::string creator;
|
||||
time_t last_seen;
|
||||
@@ -51,13 +73,13 @@ class CoreExport ChanAccess : public Serializable
|
||||
ChanAccess(AccessProvider *p);
|
||||
virtual ~ChanAccess();
|
||||
|
||||
Anope::string serialize_name() const;
|
||||
serialized_data serialize();
|
||||
static void unserialize(serialized_data &);
|
||||
const Anope::string serialize_name() const anope_override;
|
||||
Serialize::Data serialize() const anope_override;
|
||||
static Serializable* unserialize(Serializable *obj, Serialize::Data &);
|
||||
|
||||
virtual bool Matches(User *u, NickCore *nc);
|
||||
virtual bool Matches(const User *u, const NickCore *nc) const;
|
||||
virtual bool HasPriv(const Anope::string &name) const = 0;
|
||||
virtual Anope::string Serialize() = 0;
|
||||
virtual Anope::string Serialize() const = 0;
|
||||
virtual void Unserialize(const Anope::string &data) = 0;
|
||||
|
||||
bool operator>(const ChanAccess &other) const;
|
||||
@@ -69,12 +91,12 @@ class CoreExport ChanAccess : public Serializable
|
||||
class CoreExport AccessGroup : public std::vector<ChanAccess *>
|
||||
{
|
||||
public:
|
||||
ChannelInfo *ci;
|
||||
NickCore *nc;
|
||||
const ChannelInfo *ci;
|
||||
const NickCore *nc;
|
||||
bool SuperAdmin, Founder;
|
||||
AccessGroup();
|
||||
bool HasPriv(const Anope::string &priv) const;
|
||||
ChanAccess *Highest() const;
|
||||
const ChanAccess *Highest() const;
|
||||
bool operator>(const AccessGroup &other) const;
|
||||
bool operator<(const AccessGroup &other) const;
|
||||
bool operator>=(const AccessGroup &other) const;
|
||||
|
||||
+77
-76
@@ -1,16 +1,30 @@
|
||||
/*
|
||||
*
|
||||
* (C) 2003-2012 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.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ACCOUNT_H
|
||||
#define ACCOUNT_H
|
||||
|
||||
#include "extensible.h"
|
||||
#include "serialize.h"
|
||||
#include "anope.h"
|
||||
|
||||
class NickAlias;
|
||||
class NickCore;
|
||||
#include "memo.h"
|
||||
#include "base.h"
|
||||
|
||||
typedef Anope::insensitive_map<NickAlias *> nickalias_map;
|
||||
typedef Anope::insensitive_map<NickCore *> nickcore_map;
|
||||
|
||||
extern CoreExport nickalias_map NickAliasList;
|
||||
extern CoreExport nickcore_map NickCoreList;
|
||||
extern CoreExport serialize_checker<nickalias_map> NickAliasList;
|
||||
extern CoreExport serialize_checker<nickcore_map> NickCoreList;
|
||||
|
||||
/* NickServ nickname structures. */
|
||||
|
||||
@@ -83,6 +97,8 @@ enum NickCoreFlag
|
||||
/* If set means the nick core does not have their email addrses confirmed.
|
||||
*/
|
||||
NI_UNCONFIRMED,
|
||||
/* Chanstats are enabled for this user */
|
||||
NI_STATS,
|
||||
|
||||
NI_END
|
||||
};
|
||||
@@ -90,15 +106,18 @@ enum NickCoreFlag
|
||||
const Anope::string NickCoreFlagStrings[] = {
|
||||
"BEGIN", "KILLPROTECT", "SECURE", "MSG", "MEMO_HARDMAX", "MEMO_SIGNON", "MEMO_RECEIVE",
|
||||
"PRIVATE", "HIDE_EMAIL", "HIDE_MASK", "HIDE_QUIT", "KILL_QUICK", "KILL_IMMED",
|
||||
"MEMO_MAIL", "HIDE_STATUS", "SUSPENDED", "AUTOOP", "FORBIDDEN", "UNCONFIRMED", ""
|
||||
"MEMO_MAIL", "HIDE_STATUS", "SUSPENDED", "AUTOOP", "FORBIDDEN", "UNCONFIRMED", "STATS", ""
|
||||
};
|
||||
|
||||
class CoreExport NickAlias : public Extensible, public Flags<NickNameFlag, NS_END>, public Serializable
|
||||
{
|
||||
Anope::string vhost_ident, vhost_host, vhost_creator;
|
||||
time_t vhost_created;
|
||||
|
||||
public:
|
||||
/** Default constructor
|
||||
* @param nickname The nick
|
||||
* @param nickcore The nickcofe for this nick
|
||||
* @param nickcore The nickcore for this nick
|
||||
*/
|
||||
NickAlias(const Anope::string &nickname, NickCore *nickcore);
|
||||
|
||||
@@ -113,12 +132,11 @@ class CoreExport NickAlias : public Extensible, public Flags<NickNameFlag, NS_EN
|
||||
Anope::string last_realhost; /* Last uncloaked usermask, requires nickserv/auspex to see */
|
||||
time_t time_registered; /* When the nick was registered */
|
||||
time_t last_seen; /* When it was seen online for the last time */
|
||||
NickCore *nc; /* I'm an alias of this */
|
||||
HostInfo hostinfo;
|
||||
serialize_obj<NickCore> nc; /* I'm an alias of this */
|
||||
|
||||
Anope::string serialize_name() const;
|
||||
serialized_data serialize();
|
||||
static void unserialize(serialized_data &);
|
||||
const Anope::string serialize_name() const anope_override;
|
||||
Serialize::Data serialize() const anope_override;
|
||||
static Serializable* unserialize(Serializable *obj, Serialize::Data &);
|
||||
|
||||
/** Release a nick
|
||||
* See the comment in users.cpp
|
||||
@@ -131,6 +149,43 @@ class CoreExport NickAlias : public Extensible, public Flags<NickNameFlag, NS_EN
|
||||
* @param u The user
|
||||
*/
|
||||
void OnCancel(User *u);
|
||||
|
||||
/** Set a vhost for the user
|
||||
* @param ident The ident
|
||||
* @param host The host
|
||||
* @param creator Who created the vhost
|
||||
* @param time When the vhost was craated
|
||||
*/
|
||||
void SetVhost(const Anope::string &ident, const Anope::string &host, const Anope::string &creator, time_t created = Anope::CurTime);
|
||||
|
||||
/** Remove a users vhost
|
||||
**/
|
||||
void RemoveVhost();
|
||||
|
||||
/** Check if the user has a vhost
|
||||
* @return true or false
|
||||
*/
|
||||
bool HasVhost() const;
|
||||
|
||||
/** Retrieve the vhost ident
|
||||
* @return the ident
|
||||
*/
|
||||
const Anope::string &GetVhostIdent() const;
|
||||
|
||||
/** Retrieve the vhost host
|
||||
* @return the host
|
||||
*/
|
||||
const Anope::string &GetVhostHost() const;
|
||||
|
||||
/** Retrieve the vhost creator
|
||||
* @return the creator
|
||||
*/
|
||||
const Anope::string &GetVhostCreator() const;
|
||||
|
||||
/** Retrieve when the vhost was created
|
||||
* @return the time it was created
|
||||
*/
|
||||
time_t GetVhostCreated() const;
|
||||
};
|
||||
|
||||
class CoreExport NickCore : public Extensible, public Flags<NickCoreFlag, NI_END>, public Serializable
|
||||
@@ -161,11 +216,11 @@ class CoreExport NickCore : public Extensible, public Flags<NickCoreFlag, NI_END
|
||||
/* Unsaved data */
|
||||
uint16_t channelcount; /* Number of channels currently registered */
|
||||
time_t lastmail; /* Last time this nick record got a mail */
|
||||
std::list<NickAlias *> aliases; /* List of aliases */
|
||||
std::list<serialize_obj<NickAlias> > aliases; /* List of aliases */
|
||||
|
||||
Anope::string serialize_name() const;
|
||||
serialized_data serialize();
|
||||
static void unserialize(serialized_data &);
|
||||
const Anope::string serialize_name() const anope_override;
|
||||
Serialize::Data serialize() const anope_override;
|
||||
static Serializable* unserialize(Serializable *obj, Serialize::Data &);
|
||||
|
||||
/** Checks whether this account is a services oper or not.
|
||||
* @return True if this account is a services oper, false otherwise.
|
||||
@@ -236,7 +291,7 @@ class CoreExport NickCore : public Extensible, public Flags<NickCoreFlag, NI_END
|
||||
*
|
||||
* Search for an fingerprint within the cert list.
|
||||
*/
|
||||
bool FindCert(const Anope::string &entry);
|
||||
bool FindCert(const Anope::string &entry) const;
|
||||
|
||||
/** Erase a fingerprint from the nick's certificate list
|
||||
*
|
||||
@@ -254,65 +309,11 @@ class CoreExport NickCore : public Extensible, public Flags<NickCoreFlag, NI_END
|
||||
|
||||
};
|
||||
|
||||
/** Timer for colliding nicks to force people off of nicknames
|
||||
*/
|
||||
class CoreExport NickServCollide : public Timer
|
||||
{
|
||||
dynamic_reference<User> u;
|
||||
Anope::string nick;
|
||||
extern CoreExport void change_core_display(NickCore *nc);
|
||||
extern CoreExport void change_core_display(NickCore *nc, const Anope::string &newdisplay);
|
||||
|
||||
public:
|
||||
/** Default constructor
|
||||
* @param nick The nick we're colliding
|
||||
* @param delay How long to delay before kicking the user off the nick
|
||||
*/
|
||||
NickServCollide(User *user, time_t delay);
|
||||
|
||||
/** Default destructor
|
||||
*/
|
||||
virtual ~NickServCollide();
|
||||
|
||||
/** Called when the delay is up
|
||||
* @param t The current time
|
||||
*/
|
||||
void Tick(time_t t);
|
||||
};
|
||||
|
||||
/** Timers for removing HELD status from nicks.
|
||||
*/
|
||||
class NickServHeld : public Timer
|
||||
{
|
||||
dynamic_reference<NickAlias> na;
|
||||
Anope::string nick;
|
||||
public:
|
||||
NickServHeld(NickAlias *n, long t);
|
||||
|
||||
~NickServHeld();
|
||||
|
||||
void Tick(time_t);
|
||||
};
|
||||
|
||||
/** Timers for releasing nicks to be available for use
|
||||
*/
|
||||
class CoreExport NickServRelease : public User, public Timer
|
||||
{
|
||||
Anope::string nick;
|
||||
|
||||
public:
|
||||
/** Default constructor
|
||||
* @param na The nick
|
||||
* @param delay The delay before the nick is released
|
||||
*/
|
||||
NickServRelease(NickAlias *na, time_t delay);
|
||||
|
||||
/** Default destructor
|
||||
*/
|
||||
virtual ~NickServRelease();
|
||||
|
||||
/** Called when the delay is up
|
||||
* @param t The current time
|
||||
*/
|
||||
void Tick(time_t t);
|
||||
};
|
||||
extern CoreExport NickAlias *findnick(const Anope::string &nick);
|
||||
extern CoreExport NickCore *findcore(const Anope::string &nick);
|
||||
extern CoreExport bool is_on_access(const User *u, const NickCore *nc);
|
||||
|
||||
#endif // ACCOUNT_H
|
||||
|
||||
+239
-103
@@ -11,13 +11,8 @@
|
||||
#ifndef ANOPE_H
|
||||
#define ANOPE_H
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include "hashcomp.h"
|
||||
|
||||
class Message;
|
||||
|
||||
namespace Anope
|
||||
{
|
||||
template<typename T> class map : public std::map<string, T> { };
|
||||
@@ -28,12 +23,12 @@ namespace Anope
|
||||
* allow us to only require one type of string everywhere that can be converted
|
||||
* at any time to a specific type of string.
|
||||
*/
|
||||
class string
|
||||
class CoreExport string
|
||||
{
|
||||
private:
|
||||
/**
|
||||
* The actual string is stored in an std::string as it can be converted to
|
||||
* ci::string, irc::string, or a C-style string at any time.
|
||||
* ci::string, or a C-style string at any time.
|
||||
*/
|
||||
std::string _string;
|
||||
public:
|
||||
@@ -56,7 +51,6 @@ namespace Anope
|
||||
string(const char *_str) : _string(_str) { }
|
||||
string(const std::string &_str) : _string(_str) { }
|
||||
string(const ci::string &_str) : _string(_str.c_str()) { }
|
||||
string(const irc::string &_str) : _string(_str.c_str()) { }
|
||||
string(const string &_str, size_type pos = 0, size_type n = npos) : _string(_str._string, pos, n) { }
|
||||
template <class InputIterator> string(InputIterator first, InputIterator last) : _string(first, last) { }
|
||||
|
||||
@@ -66,8 +60,6 @@ namespace Anope
|
||||
inline string &operator=(char chr) { this->_string = chr; return *this; }
|
||||
inline string &operator=(const char *_str) { this->_string = _str; return *this; }
|
||||
inline string &operator=(const std::string &_str) { this->_string = _str; return *this; }
|
||||
inline string &operator=(const ci::string &_str) { this->_string = _str.c_str(); return *this; }
|
||||
inline string &operator=(const irc::string &_str) { this->_string = _str.c_str(); return *this; }
|
||||
inline string &operator=(const string &_str) { if (this != &_str) this->_string = _str._string; return *this; }
|
||||
|
||||
/**
|
||||
@@ -75,35 +67,21 @@ namespace Anope
|
||||
*/
|
||||
inline bool operator==(const char *_str) const { return this->_string == _str; }
|
||||
inline bool operator==(const std::string &_str) const { return this->_string == _str; }
|
||||
inline bool operator==(const ci::string &_str) const { return ci::string(this->_string.c_str()) == _str; }
|
||||
inline bool operator==(const irc::string &_str) const { return irc::string(this->_string.c_str()) == _str; }
|
||||
inline bool operator==(const string &_str) const { return this->_string == _str._string; }
|
||||
|
||||
inline bool equals_cs(const char *_str) const { return this->_string == _str; }
|
||||
inline bool equals_cs(const std::string &_str) const { return this->_string == _str; }
|
||||
inline bool equals_cs(const ci::string &_str) const { return this->_string == _str.c_str(); }
|
||||
inline bool equals_cs(const irc::string &_str) const { return this->_string == _str.c_str(); }
|
||||
inline bool equals_cs(const string &_str) const { return this->_string == _str._string; }
|
||||
|
||||
inline bool equals_ci(const char *_str) const { return ci::string(this->_string.c_str()) == _str; }
|
||||
inline bool equals_ci(const std::string &_str) const { return ci::string(this->_string.c_str()) == _str.c_str(); }
|
||||
inline bool equals_ci(const ci::string &_str) const { return _str == this->_string.c_str(); }
|
||||
inline bool equals_ci(const irc::string &_str) const { return ci::string(this->_string.c_str()) == _str.c_str(); }
|
||||
inline bool equals_ci(const string &_str) const { return ci::string(this->_string.c_str()) == _str._string.c_str(); }
|
||||
|
||||
inline bool equals_irc(const char *_str) const { return irc::string(this->_string.c_str()) == _str; }
|
||||
inline bool equals_irc(const std::string &_str) const { return irc::string(this->_string.c_str()) == _str.c_str(); }
|
||||
inline bool equals_irc(const ci::string &_str) const { return irc::string(this->_string.c_str()) == _str.c_str(); }
|
||||
inline bool equals_irc(const irc::string &_str) const { return _str == this->_string.c_str(); }
|
||||
inline bool equals_irc(const string &_str) const { return irc::string(this->_string.c_str()) == _str._string.c_str(); }
|
||||
|
||||
/**
|
||||
* Inequality operators, exact opposites of the above.
|
||||
*/
|
||||
inline bool operator!=(const char *_str) const { return !operator==(_str); }
|
||||
inline bool operator!=(const std::string &_str) const { return !operator==(_str); }
|
||||
inline bool operator!=(const ci::string &_str) const { return !operator==(_str); }
|
||||
inline bool operator!=(const irc::string &_str) const { return !operator==(_str); }
|
||||
inline bool operator!=(const string &_str) const { return !operator==(_str); }
|
||||
|
||||
/**
|
||||
@@ -112,8 +90,6 @@ namespace Anope
|
||||
inline string &operator+=(char chr) { this->_string += chr; return *this; }
|
||||
inline string &operator+=(const char *_str) { this->_string += _str; return *this; }
|
||||
inline string &operator+=(const std::string &_str) { this->_string += _str; return *this; }
|
||||
inline string &operator+=(const ci::string &_str) { this->_string += _str.c_str(); return *this; }
|
||||
inline string &operator+=(const irc::string &_str) { this->_string += _str.c_str(); return *this; }
|
||||
inline string &operator+=(const string &_str) { if (this != &_str) this->_string += _str._string; return *this; }
|
||||
|
||||
/**
|
||||
@@ -122,15 +98,11 @@ namespace Anope
|
||||
inline const string operator+(char chr) const { return string(*this) += chr; }
|
||||
inline const string operator+(const char *_str) const { return string(*this) += _str; }
|
||||
inline const string operator+(const std::string &_str) const { return string(*this) += _str; }
|
||||
inline const string operator+(const ci::string &_str) const { return string(*this) += _str; }
|
||||
inline const string operator+(const irc::string &_str) const { return string(*this) += _str; }
|
||||
inline const string operator+(const string &_str) const { return string(*this) += _str; }
|
||||
|
||||
friend const string operator+(char chr, const string &str);
|
||||
friend const string operator+(const char *_str, const string &str);
|
||||
friend const string operator+(const std::string &_str, const string &str);
|
||||
friend const string operator+(const ci::string &_str, const string &str);
|
||||
friend const string operator+(const irc::string &_str, const string &str);
|
||||
|
||||
/**
|
||||
* Less-than operator.
|
||||
@@ -144,7 +116,6 @@ namespace Anope
|
||||
inline std::string &str() { return this->_string; }
|
||||
inline const std::string &str() const { return this->_string; }
|
||||
inline ci::string ci_str() const { return ci::string(this->_string.c_str()); }
|
||||
inline irc::string irc_str() const { return irc::string(this->_string.c_str()); }
|
||||
|
||||
/**
|
||||
* Returns if the string is empty or not.
|
||||
@@ -265,7 +236,7 @@ namespace Anope
|
||||
{
|
||||
Anope::string new_string = *this;
|
||||
for (size_type i = 0; i < new_string.length(); ++i)
|
||||
new_string[i] = static_cast<char>(tolower(new_string[i]));
|
||||
new_string[i] = std::tolower(new_string[i], Anope::casemap);
|
||||
return new_string;
|
||||
}
|
||||
|
||||
@@ -276,7 +247,7 @@ namespace Anope
|
||||
{
|
||||
Anope::string new_string = *this;
|
||||
for (size_type i = 0; i < new_string.length(); ++i)
|
||||
new_string[i] = static_cast<char>(toupper(new_string[i]));
|
||||
new_string[i] = std::toupper(new_string[i], Anope::casemap);
|
||||
return new_string;
|
||||
}
|
||||
|
||||
@@ -330,8 +301,6 @@ namespace Anope
|
||||
inline const string operator+(char chr, const string &str) { string tmp(chr); tmp += str; return tmp; }
|
||||
inline const string operator+(const char *_str, const string &str) { string tmp(_str); tmp += str; return tmp; }
|
||||
inline const string operator+(const std::string &_str, const string &str) { string tmp(_str); tmp += str; return tmp; }
|
||||
inline const string operator+(const ci::string &_str, const string &str) { string tmp(_str); tmp += str; return tmp; }
|
||||
inline const string operator+(const irc::string &_str, const string &str) { string tmp(_str); tmp += str; return tmp; }
|
||||
|
||||
static const char *const compiled = __TIME__ " " __DATE__;
|
||||
|
||||
@@ -346,14 +315,14 @@ namespace Anope
|
||||
extern CoreExport int VersionMajor();
|
||||
extern CoreExport int VersionMinor();
|
||||
extern CoreExport int VersionPatch();
|
||||
extern CoreExport int VersionBuild();
|
||||
|
||||
/** Check whether two strings match.
|
||||
* @param str The string to check against the pattern (e.g. foobar)
|
||||
* @param mask The pattern to check (e.g. foo*bar)
|
||||
* @param case_sensitive Whether or not the match is case sensitive, default false.
|
||||
* @param use_regex Whether or not to try regex. case_sensitive is not used in regex.
|
||||
*/
|
||||
extern CoreExport bool Match(const Anope::string &str, const Anope::string &mask, bool case_sensitive = false);
|
||||
extern CoreExport bool Match(const string &str, const string &mask, bool case_sensitive = false, bool use_regex = false);
|
||||
|
||||
/** Find a message in the message table
|
||||
* @param name The name of the message were looking for
|
||||
@@ -372,20 +341,20 @@ namespace Anope
|
||||
* @param src The data to be converted
|
||||
* @param dest The destination string
|
||||
*/
|
||||
extern CoreExport void Unhex(const Anope::string &src, Anope::string &dest);
|
||||
extern CoreExport void Unhex(const Anope::string &src, char *dest);
|
||||
extern CoreExport void Unhex(const string &src, string &dest);
|
||||
extern CoreExport void Unhex(const string &src, char *dest, size_t sz);
|
||||
|
||||
/** Base 64 encode a string
|
||||
* @param src The string to encode
|
||||
* @param target Where the encoded string is placed
|
||||
*/
|
||||
extern CoreExport void B64Encode(const Anope::string &src, Anope::string &target);
|
||||
extern CoreExport void B64Encode(const string &src, string &target);
|
||||
|
||||
/** Base 64 decode a string
|
||||
* @param src The base64 encoded string
|
||||
* @param target The plain text result
|
||||
*/
|
||||
extern CoreExport void B64Decode(const Anope::string &src, Anope::string &target);
|
||||
extern CoreExport void B64Decode(const string &src, string &target);
|
||||
|
||||
/** Returns a sequence of data formatted as the format argument specifies.
|
||||
** After the format parameter, the function expects at least as many
|
||||
@@ -404,7 +373,7 @@ namespace Anope
|
||||
/** Return the last error, uses errno/GetLastError() to determine this
|
||||
* @return An error message
|
||||
*/
|
||||
extern CoreExport const Anope::string LastError();
|
||||
extern CoreExport const string LastError();
|
||||
}
|
||||
|
||||
/** sepstream allows for splitting token seperated lists.
|
||||
@@ -470,95 +439,262 @@ class spacesepstream : public sepstream
|
||||
spacesepstream(const Anope::string &source) : sepstream(source, ' ') { }
|
||||
};
|
||||
|
||||
/** The base class that most classes in Anope inherit from
|
||||
/** This class can be used on its own to represent an exception, or derived to represent a module-specific exception.
|
||||
* When a module whishes to abort, e.g. within a constructor, it should throw an exception using ModuleException or
|
||||
* a class derived from ModuleException. If a module throws an exception during its constructor, the module will not
|
||||
* be loaded. If this happens, the error message returned by ModuleException::GetReason will be displayed to the user
|
||||
* attempting to load the module, or dumped to the console if the ircd is currently loading for the first time.
|
||||
*/
|
||||
class dynamic_reference_base;
|
||||
class CoreExport Base
|
||||
{
|
||||
/* References to this base class */
|
||||
std::set<dynamic_reference_base *> References;
|
||||
public:
|
||||
Base();
|
||||
virtual ~Base();
|
||||
void AddReference(dynamic_reference_base *r);
|
||||
void DelReference(dynamic_reference_base *r);
|
||||
};
|
||||
|
||||
class dynamic_reference_base
|
||||
class CoreException : public std::exception
|
||||
{
|
||||
protected:
|
||||
bool invalid;
|
||||
/** Holds the error message to be displayed
|
||||
*/
|
||||
Anope::string err;
|
||||
/** Source of the exception
|
||||
*/
|
||||
Anope::string source;
|
||||
public:
|
||||
dynamic_reference_base() : invalid(false) { }
|
||||
virtual ~dynamic_reference_base() { }
|
||||
inline void Invalidate() { this->invalid = true; }
|
||||
/** Default constructor, just uses the error mesage 'Core threw an exception'.
|
||||
*/
|
||||
CoreException() : err("Core threw an exception"), source("The core") { }
|
||||
/** This constructor can be used to specify an error message before throwing.
|
||||
*/
|
||||
CoreException(const Anope::string &message) : err(message), source("The core") { }
|
||||
/** This constructor can be used to specify an error message before throwing,
|
||||
* and to specify the source of the exception.
|
||||
*/
|
||||
CoreException(const Anope::string &message, const Anope::string &src) : err(message), source(src) { }
|
||||
/** This destructor solves world hunger, cancels the world debt, and causes the world to end.
|
||||
* Actually no, it does nothing. Never mind.
|
||||
* @throws Nothing!
|
||||
*/
|
||||
virtual ~CoreException() throw() { }
|
||||
/** Returns the reason for the exception.
|
||||
* The module should probably put something informative here as the user will see this upon failure.
|
||||
*/
|
||||
virtual const Anope::string &GetReason() const
|
||||
{
|
||||
return err;
|
||||
}
|
||||
|
||||
virtual const Anope::string &GetSource() const
|
||||
{
|
||||
return source;
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class dynamic_reference : public dynamic_reference_base
|
||||
class FatalException : public CoreException
|
||||
{
|
||||
public:
|
||||
FatalException(const Anope::string &reason = "") : CoreException(reason) { }
|
||||
|
||||
virtual ~FatalException() throw() { }
|
||||
};
|
||||
|
||||
class ModuleException : public CoreException
|
||||
{
|
||||
public:
|
||||
/** Default constructor, just uses the error mesage 'Module threw an exception'.
|
||||
*/
|
||||
ModuleException() : CoreException("Module threw an exception", "A Module") { }
|
||||
|
||||
/** This constructor can be used to specify an error message before throwing.
|
||||
*/
|
||||
ModuleException(const Anope::string &message) : CoreException(message, "A Module") { }
|
||||
/** This destructor solves world hunger, cancels the world debt, and causes the world to end.
|
||||
* Actually no, it does nothing. Never mind.
|
||||
* @throws Nothing!
|
||||
*/
|
||||
virtual ~ModuleException() throw() { }
|
||||
};
|
||||
|
||||
class ConvertException : public CoreException
|
||||
{
|
||||
public:
|
||||
ConvertException(const Anope::string &reason = "") : CoreException(reason) { }
|
||||
|
||||
virtual ~ConvertException() throw() { }
|
||||
};
|
||||
|
||||
/** Convert something to a string
|
||||
*/
|
||||
template<typename T> inline Anope::string stringify(const T &x)
|
||||
{
|
||||
std::ostringstream stream;
|
||||
|
||||
if (!(stream << x))
|
||||
throw ConvertException("Stringify fail");
|
||||
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
template<typename T> inline void convert(const Anope::string &s, T &x, Anope::string &leftover, bool failIfLeftoverChars = true)
|
||||
{
|
||||
leftover.clear();
|
||||
std::istringstream i(s.str());
|
||||
char c;
|
||||
bool res = i >> x;
|
||||
if (!res)
|
||||
throw ConvertException("Convert fail");
|
||||
if (failIfLeftoverChars)
|
||||
{
|
||||
if (i.get(c))
|
||||
throw ConvertException("Convert fail");
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string left;
|
||||
getline(i, left);
|
||||
leftover = left;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T> inline void convert(const Anope::string &s, T &x, bool failIfLeftoverChars = true)
|
||||
{
|
||||
Anope::string Unused;
|
||||
convert(s, x, Unused, failIfLeftoverChars);
|
||||
}
|
||||
|
||||
template<typename T> inline T convertTo(const Anope::string &s, Anope::string &leftover, bool failIfLeftoverChars = true)
|
||||
{
|
||||
T x;
|
||||
convert(s, x, leftover, failIfLeftoverChars);
|
||||
return x;
|
||||
}
|
||||
|
||||
template<typename T> inline T convertTo(const Anope::string &s, bool failIfLeftoverChars = true)
|
||||
{
|
||||
T x;
|
||||
convert(s, x, failIfLeftoverChars);
|
||||
return x;
|
||||
}
|
||||
|
||||
/** Casts to be used instead of dynamic_cast, this uses dynamic_cast
|
||||
* for debug builds and static_cast/reinterpret_cast on releass builds
|
||||
* to speed up the program because dynamic_cast relies on RTTI.
|
||||
*/
|
||||
#ifdef DEBUG_BUILD
|
||||
# include <typeinfo>
|
||||
#endif
|
||||
template<typename T, typename O> inline T anope_dynamic_static_cast(O ptr)
|
||||
{
|
||||
#ifdef DEBUG_BUILD
|
||||
T ret = dynamic_cast<T>(ptr);
|
||||
if (ptr != NULL && ret == NULL)
|
||||
throw CoreException(Anope::string("anope_dynamic_static_cast<") + typeid(T).name() + ">(" + typeid(O).name() + ") fail");
|
||||
return ret;
|
||||
#else
|
||||
return static_cast<T>(ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
template<typename T, typename O> inline T anope_dynamic_reinterpret_cast(O ptr)
|
||||
{
|
||||
#ifdef DEBUG_BUILD
|
||||
T ret = dynamic_cast<T>(ptr);
|
||||
if (ptr != NULL && ret == NULL)
|
||||
throw CoreException(Anope::string("anope_dynamic_reinterpret_cast<") + typeid(T).name() + ">(" + typeid(O).name() + ") fail");
|
||||
return ret;
|
||||
#else
|
||||
return reinterpret_cast<T>(ptr);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/** Class with the ability to keep flags on items, they should extend from this
|
||||
* where T is an enum.
|
||||
*/
|
||||
template<typename T, size_t Size = 32> class Flags
|
||||
{
|
||||
protected:
|
||||
T *ref;
|
||||
std::bitset<Size> Flag_Values;
|
||||
const Anope::string *Flag_Strings;
|
||||
|
||||
public:
|
||||
dynamic_reference(T *obj) : ref(obj)
|
||||
Flags() : Flag_Strings(NULL) { }
|
||||
Flags(const Anope::string *flag_strings) : Flag_Strings(flag_strings) { }
|
||||
|
||||
/** Add a flag to this item
|
||||
* @param Value The flag
|
||||
*/
|
||||
void SetFlag(T Value)
|
||||
{
|
||||
if (ref)
|
||||
ref->AddReference(this);
|
||||
Flag_Values[Value] = true;
|
||||
}
|
||||
|
||||
dynamic_reference(const dynamic_reference<T> &obj) : ref(obj.ref)
|
||||
/** Remove a flag from this item
|
||||
* @param Value The flag
|
||||
*/
|
||||
void UnsetFlag(T Value)
|
||||
{
|
||||
if (ref)
|
||||
ref->AddReference(this);
|
||||
Flag_Values[Value] = false;
|
||||
}
|
||||
|
||||
virtual ~dynamic_reference()
|
||||
/** Check if this item has a flag
|
||||
* @param Value The flag
|
||||
* @return true or false
|
||||
*/
|
||||
bool HasFlag(T Value) const
|
||||
{
|
||||
if (this->invalid)
|
||||
{
|
||||
this->invalid = false;
|
||||
this->ref = NULL;
|
||||
}
|
||||
else if (this->operator bool())
|
||||
ref->DelReference(this);
|
||||
return Flag_Values.test(Value);
|
||||
}
|
||||
|
||||
virtual operator bool()
|
||||
/** Check how many flags are set
|
||||
* @return The number of flags set
|
||||
*/
|
||||
size_t FlagCount() const
|
||||
{
|
||||
if (this->invalid)
|
||||
{
|
||||
this->invalid = false;
|
||||
this->ref = NULL;
|
||||
}
|
||||
return this->ref != NULL;
|
||||
return Flag_Values.count();
|
||||
}
|
||||
|
||||
virtual inline operator T*()
|
||||
/** Unset all of the flags
|
||||
*/
|
||||
void ClearFlags()
|
||||
{
|
||||
if (this->operator bool())
|
||||
return this->ref;
|
||||
return NULL;
|
||||
Flag_Values.reset();
|
||||
}
|
||||
|
||||
virtual inline T *operator->()
|
||||
Anope::string ToString() const
|
||||
{
|
||||
if (this->operator bool())
|
||||
return this->ref;
|
||||
return NULL;
|
||||
std::vector<Anope::string> v = ToVector();
|
||||
Anope::string flag_buf;
|
||||
for (unsigned i = 0; i < v.size(); ++i)
|
||||
flag_buf += v[i] + " ";
|
||||
flag_buf.trim();
|
||||
return flag_buf;
|
||||
}
|
||||
|
||||
virtual inline void operator=(T *newref)
|
||||
void FromString(const Anope::string &str)
|
||||
{
|
||||
if (this->invalid)
|
||||
{
|
||||
this->invalid = false;
|
||||
this->ref = NULL;
|
||||
}
|
||||
else if (this->operator bool())
|
||||
this->ref->DelReference(this);
|
||||
this->ref = newref;
|
||||
if (this->operator bool())
|
||||
this->ref->AddReference(this);
|
||||
spacesepstream sep(str);
|
||||
Anope::string buf;
|
||||
std::vector<Anope::string> v;
|
||||
|
||||
while (sep.GetToken(buf))
|
||||
v.push_back(buf);
|
||||
|
||||
FromVector(v);
|
||||
}
|
||||
|
||||
std::vector<Anope::string> ToVector() const
|
||||
{
|
||||
std::vector<Anope::string> ret;
|
||||
for (unsigned i = 0; this->Flag_Strings && !this->Flag_Strings[i].empty(); ++i)
|
||||
if (this->HasFlag(static_cast<T>(i)))
|
||||
ret.push_back(this->Flag_Strings[i]);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void FromVector(const std::vector<Anope::string> &strings)
|
||||
{
|
||||
this->ClearFlags();
|
||||
|
||||
for (unsigned i = 0; this->Flag_Strings && !this->Flag_Strings[i].empty(); ++i)
|
||||
for (unsigned j = 0; j < strings.size(); ++j)
|
||||
if (this->Flag_Strings[i] == strings[j])
|
||||
this->SetFlag(static_cast<T>(i));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
*
|
||||
* Copyright (C) 2008-2011 Adam <Adam@anope.org>
|
||||
* Copyright (C) 2008-2012 Anope Team <team@anope.org>
|
||||
*
|
||||
* Please read COPYING and README for further details.
|
||||
*/
|
||||
|
||||
#ifndef BASE_H
|
||||
#define BASE_H
|
||||
|
||||
#include "services.h"
|
||||
|
||||
/** The base class that most classes in Anope inherit from
|
||||
*/
|
||||
class CoreExport Base
|
||||
{
|
||||
/* References to this base class */
|
||||
std::set<dynamic_reference_base *> References;
|
||||
public:
|
||||
Base();
|
||||
virtual ~Base();
|
||||
void AddReference(dynamic_reference_base *r);
|
||||
void DelReference(dynamic_reference_base *r);
|
||||
};
|
||||
|
||||
class dynamic_reference_base
|
||||
{
|
||||
protected:
|
||||
bool invalid;
|
||||
public:
|
||||
dynamic_reference_base() : invalid(false) { }
|
||||
dynamic_reference_base(const dynamic_reference_base &other) : invalid(other.invalid) { }
|
||||
virtual ~dynamic_reference_base() { }
|
||||
inline void Invalidate() { this->invalid = true; }
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class dynamic_reference : public dynamic_reference_base
|
||||
{
|
||||
protected:
|
||||
T *ref;
|
||||
public:
|
||||
dynamic_reference() : ref(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
dynamic_reference(T *obj) : ref(obj)
|
||||
{
|
||||
if (ref)
|
||||
ref->AddReference(this);
|
||||
}
|
||||
|
||||
dynamic_reference(const dynamic_reference<T> &other) : dynamic_reference_base(other), ref(other.ref)
|
||||
{
|
||||
if (operator bool())
|
||||
ref->AddReference(this);
|
||||
}
|
||||
|
||||
virtual ~dynamic_reference()
|
||||
{
|
||||
if (operator bool())
|
||||
ref->DelReference(this);
|
||||
}
|
||||
|
||||
/* We explicitly call operator bool here in several places to prevent other
|
||||
* operators, such operator T*, from being called instead, which will mess
|
||||
* with any class inheriting from this that overloads this operator.
|
||||
*/
|
||||
virtual operator bool()
|
||||
{
|
||||
if (!this->invalid)
|
||||
return this->ref != NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
inline operator T*()
|
||||
{
|
||||
if (operator bool())
|
||||
return this->ref;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
inline T* operator->()
|
||||
{
|
||||
if (operator bool())
|
||||
return this->ref;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
inline void operator=(T *newref)
|
||||
{
|
||||
if (operator bool())
|
||||
this->ref->DelReference(this);
|
||||
this->ref = newref;
|
||||
this->invalid = false;
|
||||
if (operator bool())
|
||||
this->ref->AddReference(this);
|
||||
}
|
||||
|
||||
inline bool operator<(const dynamic_reference<T> &other) const
|
||||
{
|
||||
return this < &other;
|
||||
}
|
||||
|
||||
inline bool operator==(const dynamic_reference<T> &other)
|
||||
{
|
||||
if (!this->invalid)
|
||||
return this->ref == other;
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // BASE_H
|
||||
|
||||
+21
-7
@@ -8,11 +8,17 @@
|
||||
#ifndef BOTS_H
|
||||
#define BOTS_H
|
||||
|
||||
class BotInfo;
|
||||
#include "users.h"
|
||||
#include "anope.h"
|
||||
#include "serialize.h"
|
||||
#include "commands.h"
|
||||
|
||||
|
||||
extern CoreExport Anope::insensitive_map<BotInfo *> BotListByNick;
|
||||
extern CoreExport Anope::map<BotInfo *> BotListByUID;
|
||||
typedef Anope::insensitive_map<BotInfo *> botinfo_map;
|
||||
typedef Anope::map<BotInfo *> botinfouid_map;
|
||||
|
||||
extern CoreExport serialize_checker<botinfo_map> BotListByNick;
|
||||
extern CoreExport serialize_checker<botinfouid_map> BotListByUID;
|
||||
|
||||
/** Flags settable on a bot
|
||||
*/
|
||||
@@ -35,7 +41,6 @@ static const Anope::string BotFlagString[] = { "BEGIN", "CORE", "PRIVATE", "CONF
|
||||
class CoreExport BotInfo : public User, public Flags<BotFlag, BI_END>, public Serializable
|
||||
{
|
||||
public:
|
||||
uint32_t chancount;
|
||||
time_t created; /* Birth date ;) */
|
||||
time_t lastmsg; /* Last time we said something */
|
||||
typedef Anope::insensitive_map<CommandInfo> command_map;
|
||||
@@ -57,9 +62,9 @@ class CoreExport BotInfo : public User, public Flags<BotFlag, BI_END>, public Se
|
||||
*/
|
||||
virtual ~BotInfo();
|
||||
|
||||
Anope::string serialize_name() const;
|
||||
serialized_data serialize();
|
||||
static void unserialize(serialized_data &);
|
||||
const Anope::string serialize_name() const;
|
||||
Serialize::Data serialize() const;
|
||||
static Serializable* unserialize(Serializable *obj, Serialize::Data &);
|
||||
|
||||
void GenerateUID();
|
||||
|
||||
@@ -85,6 +90,10 @@ class CoreExport BotInfo : public User, public Flags<BotFlag, BI_END>, public Se
|
||||
*/
|
||||
void UnAssign(User *u, ChannelInfo *ci);
|
||||
|
||||
/** Get the number of channels this bot is assigned to
|
||||
*/
|
||||
unsigned GetChannelCount() const;
|
||||
|
||||
/** Join this bot to a channel
|
||||
* @param c The channel
|
||||
* @param status The status the bot should have on the channel
|
||||
@@ -123,4 +132,9 @@ class CoreExport BotInfo : public User, public Flags<BotFlag, BI_END>, public Se
|
||||
CommandInfo *GetCommand(const Anope::string &cname);
|
||||
};
|
||||
|
||||
extern CoreExport BotInfo *findbot(const Anope::string &nick);
|
||||
|
||||
extern CoreExport void bot_raw_ban(User *requester, ChannelInfo *ci, const Anope::string &nick, const Anope::string &reason);
|
||||
extern CoreExport void bot_raw_kick(User *requester, ChannelInfo *ci, const Anope::string &nick, const Anope::string &reason);
|
||||
|
||||
#endif // BOTS_H
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
*
|
||||
* (C) 2003-2012 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.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef BOTSERV_H
|
||||
#define BOTSERV_H
|
||||
|
||||
#include "anope.h"
|
||||
|
||||
/* BotServ SET flags */
|
||||
enum BotServFlag
|
||||
{
|
||||
BS_BEGIN,
|
||||
/* BotServ won't kick ops */
|
||||
BS_DONTKICKOPS,
|
||||
/* BotServ won't kick voices */
|
||||
BS_DONTKICKVOICES,
|
||||
/* BotServ bot accepts fantasy commands */
|
||||
BS_FANTASY,
|
||||
/* BotServ should show greets */
|
||||
BS_GREET,
|
||||
/* BotServ bots are not allowed to be in this channel */
|
||||
BS_NOBOT,
|
||||
/* BotServ kicks for bolds */
|
||||
BS_KICK_BOLDS,
|
||||
/* BotServ kicks for colors */
|
||||
BS_KICK_COLORS,
|
||||
/* BOtServ kicks for reverses */
|
||||
BS_KICK_REVERSES,
|
||||
/* BotServ kicks for underlines */
|
||||
BS_KICK_UNDERLINES,
|
||||
/* BotServ kicks for badwords */
|
||||
BS_KICK_BADWORDS,
|
||||
/* BotServ kicks for caps */
|
||||
BS_KICK_CAPS,
|
||||
/* BotServ kicks for flood */
|
||||
BS_KICK_FLOOD,
|
||||
/* BotServ kicks for repeating */
|
||||
BS_KICK_REPEAT,
|
||||
/* BotServ kicks for italics */
|
||||
BS_KICK_ITALICS,
|
||||
/* BotServ kicks for amsgs */
|
||||
BS_KICK_AMSGS,
|
||||
BS_END
|
||||
};
|
||||
|
||||
const Anope::string BotServFlagStrings[] = {
|
||||
"BEGIN", "DONTKICKOPS", "DONTKICKVOICES", "FANTASY", "GREET", "NOBOT",
|
||||
"KICK_BOLDs", "KICK_COLORS", "KICK_REVERSES", "KICK_UNDERLINES", "KICK_BADWORDS", "KICK_CAPS",
|
||||
"KICK_FLOOD", "KICK_REPEAT", "KICK_ITALICS", "KICK_AMSGS", "MSG_PRIVMSG", "MSG_NOTICE",
|
||||
"MSG_NOTICEOPS", ""
|
||||
};
|
||||
|
||||
/* Indices for TTB (Times To Ban) */
|
||||
enum
|
||||
{
|
||||
TTB_BOLDS,
|
||||
TTB_COLORS,
|
||||
TTB_REVERSES,
|
||||
TTB_UNDERLINES,
|
||||
TTB_BADWORDS,
|
||||
TTB_CAPS,
|
||||
TTB_FLOOD,
|
||||
TTB_REPEAT,
|
||||
TTB_ITALICS,
|
||||
TTB_AMSGS,
|
||||
TTB_SIZE
|
||||
};
|
||||
|
||||
#endif // BOTSERV_H
|
||||
+33
-7
@@ -9,6 +9,11 @@
|
||||
#ifndef CHANNELS_H
|
||||
#define CHANNELS_H
|
||||
|
||||
#include "anope.h"
|
||||
#include "extensible.h"
|
||||
#include "modes.h"
|
||||
#include "serialize.h"
|
||||
|
||||
typedef Anope::insensitive_map<Channel *> channel_map;
|
||||
extern CoreExport channel_map ChannelList;
|
||||
|
||||
@@ -35,7 +40,7 @@ enum ChannelFlag
|
||||
|
||||
const Anope::string ChannelFlagString[] = { "CH_INABIT", "CH_PERSIST", "CH_SYNCING", "" };
|
||||
|
||||
class CoreExport Channel : public Extensible, public Flags<ChannelFlag, 3>
|
||||
class CoreExport Channel : public virtual Base, public Extensible, public Flags<ChannelFlag, 3>
|
||||
{
|
||||
public:
|
||||
typedef std::multimap<ChannelModeName, Anope::string> ModeList;
|
||||
@@ -56,7 +61,7 @@ class CoreExport Channel : public Extensible, public Flags<ChannelFlag, 3>
|
||||
~Channel();
|
||||
|
||||
Anope::string name; /* Channel name */
|
||||
ChannelInfo *ci; /* Corresponding ChannelInfo */
|
||||
serialize_obj<ChannelInfo> ci; /* Corresponding ChannelInfo */
|
||||
time_t creation_time; /* When channel was created */
|
||||
|
||||
/* List of users in the channel */
|
||||
@@ -81,6 +86,10 @@ class CoreExport Channel : public Extensible, public Flags<ChannelFlag, 3>
|
||||
*/
|
||||
void Sync();
|
||||
|
||||
/** Check if a channels modes are correct.
|
||||
*/
|
||||
void CheckModes();
|
||||
|
||||
/** Join a user internally to the channel
|
||||
* @param u The user
|
||||
*/
|
||||
@@ -95,14 +104,14 @@ class CoreExport Channel : public Extensible, public Flags<ChannelFlag, 3>
|
||||
* @param u The user
|
||||
* @return A user container if found, else NULL
|
||||
*/
|
||||
UserContainer *FindUser(User *u);
|
||||
UserContainer *FindUser(const User *u) const;
|
||||
|
||||
/** Check if a user has a status on a channel
|
||||
* @param u The user
|
||||
* @param cms The status mode, or NULL to represent no status
|
||||
* @return true or false
|
||||
*/
|
||||
bool HasUserStatus(User *u, ChannelModeStatus *cms) const;
|
||||
bool HasUserStatus(const User *u, ChannelModeStatus *cms) const;
|
||||
|
||||
/** Check if a user has a status on a channel
|
||||
* Use the overloaded function for ChannelModeStatus* to check for no status
|
||||
@@ -110,7 +119,7 @@ class CoreExport Channel : public Extensible, public Flags<ChannelFlag, 3>
|
||||
* @param Name The Mode name, eg CMODE_OP, CMODE_VOICE
|
||||
* @return true or false
|
||||
*/
|
||||
bool HasUserStatus(User *u, ChannelModeName Name) const;
|
||||
bool HasUserStatus(const User *u, ChannelModeName Name) const;
|
||||
|
||||
/** See if a channel has a mode
|
||||
* @param Name The mode name
|
||||
@@ -126,18 +135,20 @@ class CoreExport Channel : public Extensible, public Flags<ChannelFlag, 3>
|
||||
std::pair<ModeList::iterator, ModeList::iterator> GetModeList(ChannelModeName Name);
|
||||
|
||||
/** Set a mode internally on a channel, this is not sent out to the IRCd
|
||||
* @param setter The setter
|
||||
* @param cm The mode
|
||||
* @param param The param
|
||||
* @param EnforceMLock true if mlocks should be enforced, false to override mlock
|
||||
*/
|
||||
void SetModeInternal(ChannelMode *cm, const Anope::string ¶m = "", bool EnforceMLock = true);
|
||||
void SetModeInternal(User *setter, ChannelMode *cm, const Anope::string ¶m = "", bool EnforceMLock = true);
|
||||
|
||||
/** Remove a mode internally on a channel, this is not sent out to the IRCd
|
||||
* @param setter The Setter
|
||||
* @param cm The mode
|
||||
* @param param The param
|
||||
* @param EnforceMLock true if mlocks should be enforced, false to override mlock
|
||||
*/
|
||||
void RemoveModeInternal(ChannelMode *cm, const Anope::string ¶m = "", bool EnforceMLock = true);
|
||||
void RemoveModeInternal(User *setter, ChannelMode *cm, const Anope::string ¶m = "", bool EnforceMLock = true);
|
||||
|
||||
/** Set a mode on a channel
|
||||
* @param bi The client setting the modes
|
||||
@@ -229,6 +240,21 @@ class CoreExport Channel : public Extensible, public Flags<ChannelFlag, 3>
|
||||
* @param ts The time when the new topic is being set
|
||||
*/
|
||||
void ChangeTopic(const Anope::string &user, const Anope::string &newtopic, time_t ts = Anope::CurTime);
|
||||
|
||||
/** Hold the channel open using ChanServ
|
||||
*/
|
||||
void Hold();
|
||||
};
|
||||
|
||||
extern CoreExport Channel *findchan(const Anope::string &chan);
|
||||
|
||||
extern CoreExport User *nc_on_chan(Channel *c, const NickCore *nc);
|
||||
|
||||
extern CoreExport void do_cmode(const Anope::string &source, const Anope::string &channel, const Anope::string &modes, const Anope::string &ts);
|
||||
extern CoreExport void do_join(const Anope::string &source, const Anope::string &channels, const Anope::string &ts);
|
||||
extern CoreExport void do_kick(const Anope::string &source, const Anope::string &channel, const Anope::string &users, const Anope::string &reason);
|
||||
extern CoreExport void do_part(const Anope::string &source, const Anope::string &channels, const Anope::string &reason);
|
||||
|
||||
extern CoreExport void chan_set_correct_modes(const User *user, Channel *c, int give_modes);
|
||||
|
||||
#endif // CHANNELS_H
|
||||
|
||||
+31
-8
@@ -12,11 +12,8 @@
|
||||
#ifndef COMMAND_H
|
||||
#define COMMAND_H
|
||||
|
||||
#include "services.h"
|
||||
|
||||
class Module;
|
||||
class BotInfo;
|
||||
class Command;
|
||||
#include "service.h"
|
||||
#include "anope.h"
|
||||
|
||||
enum CommandFlag
|
||||
{
|
||||
@@ -36,11 +33,23 @@ struct CommandInfo
|
||||
Anope::string permission;
|
||||
};
|
||||
|
||||
/* The source for a command */
|
||||
struct CoreExport CommandSource
|
||||
struct CommandReply
|
||||
{
|
||||
/* User executing the command */
|
||||
virtual void SendMessage(const BotInfo *source, const Anope::string &msg) = 0;
|
||||
};
|
||||
|
||||
/* The source for a command */
|
||||
class CoreExport CommandSource
|
||||
{
|
||||
/* The nick executing the command */
|
||||
Anope::string nick;
|
||||
/* User executing the command, may be NULL */
|
||||
User *u;
|
||||
public:
|
||||
/* The account executing the command */
|
||||
NickCore *nc;
|
||||
/* Where the reply should go */
|
||||
CommandReply *reply;
|
||||
/* Channel the command was executed on (fantasy) */
|
||||
Channel *c;
|
||||
/* The service this command is on */
|
||||
@@ -52,8 +61,20 @@ struct CoreExport CommandSource
|
||||
/* The permission of the command being executed */
|
||||
Anope::string permission;
|
||||
|
||||
CommandSource(const Anope::string &n, User *user, NickCore *core, CommandReply *reply);
|
||||
|
||||
const Anope::string &GetNick() const;
|
||||
User *GetUser() const;
|
||||
AccessGroup AccessFor(ChannelInfo *ci) const;
|
||||
bool IsFounder(ChannelInfo *ci) const;
|
||||
|
||||
void Reply(const char *message, ...);
|
||||
void Reply(const Anope::string &message);
|
||||
|
||||
bool HasCommand(const Anope::string &cmd);
|
||||
bool HasPriv(const Anope::string &cmd);
|
||||
bool IsServicesOper() const;
|
||||
bool IsOper() const;
|
||||
};
|
||||
|
||||
/** Every services command is a class, inheriting from Command.
|
||||
@@ -121,4 +142,6 @@ class CoreExport Command : public Service, public Flags<CommandFlag>
|
||||
virtual void OnSyntaxError(CommandSource &source, const Anope::string &subcommand);
|
||||
};
|
||||
|
||||
extern CoreExport void RunCommand(CommandSource &source, const Anope::string &message);
|
||||
|
||||
#endif // COMMANDS_H
|
||||
|
||||
+57
-27
@@ -1,14 +1,22 @@
|
||||
/*
|
||||
*
|
||||
* (C) 2003-2012 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.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_H
|
||||
#define CONFIG_H
|
||||
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <deque>
|
||||
|
||||
#include "anope.h"
|
||||
#include "account.h"
|
||||
#include "regchannel.h"
|
||||
#include "users.h"
|
||||
|
||||
/** A configuration key and value pair
|
||||
*/
|
||||
@@ -23,7 +31,6 @@ typedef std::vector<KeyVal> KeyValList;
|
||||
typedef std::multimap<Anope::string, KeyValList> ConfigDataHash;
|
||||
|
||||
// Required forward definitions
|
||||
class ServerConfig;
|
||||
|
||||
/** Types of data in the core config
|
||||
*/
|
||||
@@ -341,6 +348,29 @@ class CoreExport ServerConfig
|
||||
void ValidateIP(const Anope::string &p, const Anope::string &, const Anope::string &, bool) const;
|
||||
void ValidateNoSpaces(const Anope::string &, const Anope::string &, const Anope::string &) const;
|
||||
|
||||
struct Uplink
|
||||
{
|
||||
Anope::string host;
|
||||
unsigned port;
|
||||
Anope::string password;
|
||||
bool ipv6;
|
||||
|
||||
Uplink(const Anope::string &_host, int _port, const Anope::string &_password, bool _ipv6) : host(_host), port(_port), password(_password), ipv6(_ipv6) { }
|
||||
bool operator==(const Uplink &other) const
|
||||
{
|
||||
if (this->host != other.host)
|
||||
return false;
|
||||
if (this->port != other.port)
|
||||
return false;
|
||||
if (this->password != other.password)
|
||||
return false;
|
||||
if (this->ipv6 != other.ipv6)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
inline bool operator!=(const Uplink &other) const { return !(*this == other); }
|
||||
};
|
||||
|
||||
/** Below here is a list of variables which contain the config files values
|
||||
*/
|
||||
/* Host to bind to */
|
||||
@@ -362,6 +392,9 @@ class CoreExport ServerConfig
|
||||
/* Max lenght of hostnames */
|
||||
unsigned HostLen;
|
||||
|
||||
/* Casemapping to use */
|
||||
Anope::string CaseMap;
|
||||
|
||||
/* Max length of passwords */
|
||||
unsigned PassLen;
|
||||
|
||||
@@ -416,6 +449,10 @@ class CoreExport ServerConfig
|
||||
Anope::string MLock;
|
||||
/* Unmlockable modes */
|
||||
Anope::string NoMLock;
|
||||
/* Modes that are required to be on registered channels */
|
||||
Anope::string CSRequire;
|
||||
/* Use server side mlock */
|
||||
bool UseServerSideMLock;
|
||||
/* Default botmodes on channels, defaults to ao */
|
||||
Anope::string BotModes;
|
||||
/* THe actual modes */
|
||||
@@ -426,6 +463,8 @@ class CoreExport ServerConfig
|
||||
bool HidePrivilegedCommands;
|
||||
/* If set, nicks cant be owned/everything is entirely account based */
|
||||
bool NoNicknameOwnership;
|
||||
/* Regex engine to use */
|
||||
Anope::string RegexEngine;
|
||||
|
||||
/* A vector of our logfile options */
|
||||
std::vector<LogInfo *> LogInfos;
|
||||
@@ -497,8 +536,10 @@ class CoreExport ServerConfig
|
||||
bool NSSecureAdmins;
|
||||
/* Services opers must be /operd on the ircd aswell */
|
||||
bool NSStrictPrivileges;
|
||||
/* Use email to verify new users registering */
|
||||
bool NSEmailReg;
|
||||
/* Type of confirmation to use, or to disable registration completely */
|
||||
Anope::string NSRegistration;
|
||||
/* A message sent to unregistered users on connect */
|
||||
Anope::string NSUnregisteredNotice;
|
||||
/* Core NickServ modules */
|
||||
Anope::string NickCoreModules;
|
||||
/* Set the proper channel modes on users when they identify */
|
||||
@@ -598,18 +639,6 @@ class CoreExport ServerConfig
|
||||
bool KillonSNline;
|
||||
/* Kill users on SQline */
|
||||
bool KillonSQline;
|
||||
/* Send a WALLOPS/GLOBOPS when a user opers */
|
||||
bool WallOper;
|
||||
/* Send a WALLOPS/GLOBOPS when a nonoper tries to use OperServ */
|
||||
bool WallBadOS;
|
||||
/* Send a WALLOPS/GLOBOPS when an akill expires */
|
||||
bool WallAkillExpire;
|
||||
/* Send a WALLOPS/GLOBOPS when SNLines expire */
|
||||
bool WallSNLineExpire;
|
||||
/* Send a WALLOPS/GLOBOPS when SQLines expire */
|
||||
bool WallSQLineExpire;
|
||||
/* Send a WALLOPS/GLOBOPS when exceptions expire */
|
||||
bool WallExceptionExpire;
|
||||
/* Add the akillers nick to the akill reason */
|
||||
bool AddAkiller;
|
||||
/* Add akill ids to akill reason */
|
||||
@@ -637,10 +666,8 @@ class CoreExport ServerConfig
|
||||
/* List of modules to autoload */
|
||||
std::list<Anope::string> ModulesAutoLoad;
|
||||
|
||||
/* User keys to use for generating random hashes for pass codes etc */
|
||||
unsigned long UserKey1;
|
||||
unsigned long UserKey2;
|
||||
unsigned long UserKey3;
|
||||
/* Seed to use for RNG */
|
||||
unsigned long Seed;
|
||||
|
||||
/* Numeric */
|
||||
Anope::string Numeric;
|
||||
@@ -777,4 +804,7 @@ class CoreExport ConfigReader
|
||||
int EnumerateValues(const Anope::string &, int);
|
||||
};
|
||||
|
||||
extern ConfigurationFile services_conf;
|
||||
extern CoreExport ServerConfig *Config;
|
||||
|
||||
#endif // CONFIG_H
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
*
|
||||
* (C) 2003-2012 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.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
class AccessGroup;
|
||||
class AutoKick;
|
||||
class BotInfo;
|
||||
class CallBack;
|
||||
class ChanAccess;
|
||||
class Channel;
|
||||
class ChannelInfo;
|
||||
class ChannelStatus;
|
||||
class ClientSocket;
|
||||
class Command;
|
||||
class CommandSource;
|
||||
class ConnectionSocket;
|
||||
class DNSPacket;
|
||||
class dynamic_reference_base;
|
||||
class Entry;
|
||||
class InfoFormatter;
|
||||
class ListenSocket;
|
||||
class Log;
|
||||
class LogInfo;
|
||||
class Memo;
|
||||
class Message;
|
||||
class Module;
|
||||
class NickAlias;
|
||||
class NickCore;
|
||||
class OperType;
|
||||
class Regex;
|
||||
class Serializable;
|
||||
class Server;
|
||||
class ServerConfig;
|
||||
class Socket;
|
||||
class Thread;
|
||||
class User;
|
||||
class XLine;
|
||||
class XLineManager;
|
||||
struct BadWord;
|
||||
struct DNSQuery;
|
||||
struct Exception;
|
||||
struct MemoInfo;
|
||||
struct ModeLock;
|
||||
struct Oper;
|
||||
|
||||
+21
-6
@@ -1,6 +1,24 @@
|
||||
/*
|
||||
*
|
||||
* (C) 2003-2012 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.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef DNS_H
|
||||
#define DNS_H
|
||||
|
||||
#include "sockets.h"
|
||||
#include "timers.h"
|
||||
#include "extern.h"
|
||||
#include "config.h"
|
||||
|
||||
/** Valid query types
|
||||
*/
|
||||
enum QueryType
|
||||
@@ -48,9 +66,6 @@ enum DNSError
|
||||
DNS_ERROR_INVALIDTYPE
|
||||
};
|
||||
|
||||
class Module;
|
||||
struct DNSQuery;
|
||||
class DNSPacket;
|
||||
|
||||
struct CoreExport Question
|
||||
{
|
||||
@@ -106,7 +121,7 @@ class CoreExport DNSRequest : public Timer, public Question
|
||||
|
||||
virtual void OnError(const DNSQuery *r);
|
||||
|
||||
void Tick(time_t);
|
||||
void Tick(time_t) anope_override;
|
||||
};
|
||||
|
||||
/** A full packet sent or recieved to/from the nameserver, may contain multiple queries
|
||||
@@ -143,7 +158,7 @@ class CoreExport DNSManager : public Timer, public Socket
|
||||
sockaddrs addrs;
|
||||
public:
|
||||
std::deque<DNSPacket *> packets;
|
||||
std::map<short, DNSRequest *> requests;
|
||||
std::map<unsigned short, DNSRequest *> requests;
|
||||
|
||||
static const int DNSPort = 53;
|
||||
|
||||
@@ -167,7 +182,7 @@ class CoreExport DNSManager : public Timer, public Socket
|
||||
|
||||
/** Tick this timer, used to clear the DNS cache.
|
||||
*/
|
||||
void Tick(time_t now);
|
||||
void Tick(time_t now) anope_override;
|
||||
|
||||
/** Cleanup all pending DNS queries for a module
|
||||
* @param mod The module
|
||||
|
||||
+9
-11
@@ -8,7 +8,6 @@
|
||||
#define EXTENSIBLE_H
|
||||
|
||||
#include "anope.h"
|
||||
#include "hashcomp.h"
|
||||
|
||||
class CoreExport ExtensibleItem
|
||||
{
|
||||
@@ -18,13 +17,12 @@ class CoreExport ExtensibleItem
|
||||
virtual void OnDelete();
|
||||
};
|
||||
|
||||
class ExtensibleString : public Anope::string, public ExtensibleItem
|
||||
template<typename T> struct CoreExport ExtensibleItemClass : T, ExtensibleItem
|
||||
{
|
||||
public:
|
||||
ExtensibleString(const Anope::string &s) : Anope::string(s), ExtensibleItem() { }
|
||||
ExtensibleItemClass(const T& t) : T(t) { }
|
||||
};
|
||||
|
||||
class CoreExport Extensible : public Base
|
||||
class CoreExport Extensible
|
||||
{
|
||||
private:
|
||||
typedef Anope::map<ExtensibleItem *> extensible_map;
|
||||
@@ -93,11 +91,11 @@ class CoreExport Extensible : public Base
|
||||
* @param key The key parameter is an arbitary string which identifies the extension data
|
||||
* @return The item found
|
||||
*/
|
||||
template<typename T> T GetExt(const Anope::string &key)
|
||||
template<typename T> T GetExt(const Anope::string &key) const
|
||||
{
|
||||
extensible_map::iterator it = this->extension_items.find(key);
|
||||
extensible_map::const_iterator it = this->extension_items.find(key);
|
||||
if (it != this->extension_items.end())
|
||||
return debug_cast<T>(it->second);
|
||||
return anope_dynamic_reinterpret_cast<T>(it->second);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -107,7 +105,7 @@ class CoreExport Extensible : public Base
|
||||
* @param key The key parameter is an arbitary string which identifies the extension data
|
||||
* @return True if the item was found.
|
||||
*/
|
||||
bool HasExt(const Anope::string &key)
|
||||
bool HasExt(const Anope::string &key) const
|
||||
{
|
||||
return this->extension_items.count(key) > 0;
|
||||
}
|
||||
@@ -117,9 +115,9 @@ class CoreExport Extensible : public Base
|
||||
* @return This function writes a list of all extension items stored
|
||||
* in this object by name into the given deque and returns void.
|
||||
*/
|
||||
void GetExtList(std::deque<Anope::string> &list)
|
||||
void GetExtList(std::deque<Anope::string> &list) const
|
||||
{
|
||||
for (extensible_map::iterator it = extension_items.begin(), it_end = extension_items.end(); it != it_end; ++it)
|
||||
for (extensible_map::const_iterator it = extension_items.begin(), it_end = extension_items.end(); it != it_end; ++it)
|
||||
list.push_back(it->first);
|
||||
}
|
||||
};
|
||||
|
||||
+13
-118
@@ -12,65 +12,26 @@
|
||||
#ifndef EXTERN_H
|
||||
#define EXTERN_H
|
||||
|
||||
#include "modes.h"
|
||||
|
||||
#define E extern CoreExport
|
||||
#define EI extern DllExport
|
||||
|
||||
#include "hashcomp.h"
|
||||
|
||||
/* IRC Variables */
|
||||
|
||||
E IRCDVar *ircd;
|
||||
E IRCDProto *ircdproto;
|
||||
E IRCdMessage *ircdmessage;
|
||||
|
||||
/**** actions.c ****/
|
||||
|
||||
E bool bad_password(User *u);
|
||||
E void common_unban(ChannelInfo *ci, User *u, bool full = false);
|
||||
|
||||
/**** botserv.c ****/
|
||||
|
||||
E BotInfo *findbot(const Anope::string &nick);
|
||||
|
||||
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 Channel *findchan(const Anope::string &chan);
|
||||
|
||||
E User *nc_on_chan(Channel *c, const NickCore *nc);
|
||||
|
||||
E void do_cmode(const Anope::string &source, const Anope::string &channel, const Anope::string &modes, const Anope::string &ts);
|
||||
E void do_join(const Anope::string &source, const Anope::string &channels, const Anope::string &ts);
|
||||
E void do_kick(const Anope::string &source, const Anope::string &channel, const Anope::string &users, const Anope::string &reason);
|
||||
E void do_part(const Anope::string &source, const Anope::string &channels, const Anope::string &reason);
|
||||
|
||||
E void chan_set_correct_modes(User *user, Channel *c, int give_modes);
|
||||
|
||||
/**** chanserv.c ****/
|
||||
|
||||
E void check_modes(Channel *c);
|
||||
|
||||
E ChannelInfo *cs_findchan(const Anope::string &chan);
|
||||
E bool IsFounder(User *user, ChannelInfo *ci);
|
||||
E void update_cs_lastseen(User *user, ChannelInfo *ci);
|
||||
E int get_idealban(ChannelInfo *ci, User *u, Anope::string &ret);
|
||||
|
||||
/**** config.c ****/
|
||||
|
||||
E ConfigurationFile services_conf;
|
||||
E ServerConfig *Config;
|
||||
E void common_unban(const ChannelInfo *ci, User *u, bool full = false);
|
||||
|
||||
/**** encrypt.c ****/
|
||||
|
||||
E void enc_encrypt(const Anope::string &src, Anope::string &dest);
|
||||
E bool enc_decrypt(const Anope::string &src, Anope::string &dest);
|
||||
|
||||
/**** hostserv.c ****/
|
||||
|
||||
/**** init.c ****/
|
||||
|
||||
E Anope::string conf_dir, db_dir, modules_dir, locale_dir, log_dir;
|
||||
|
||||
E void introduce_user(const Anope::string &user);
|
||||
E bool GetCommandLineArgument(const Anope::string &name, char shortname = 0);
|
||||
E bool GetCommandLineArgument(const Anope::string &name, char shortname, Anope::string ¶m);
|
||||
@@ -78,18 +39,14 @@ E bool AtTerm();
|
||||
E void Fork();
|
||||
E void Init(int ac, char **av);
|
||||
|
||||
/**** ircd.c ****/
|
||||
E void pmodule_ircd_proto(IRCDProto *);
|
||||
E void pmodule_ircd_var(IRCDVar *ircdvar);
|
||||
E void pmodule_ircd_message(IRCdMessage *message);
|
||||
|
||||
/**** language.cpp ****/
|
||||
|
||||
E std::vector<Anope::string> languages;
|
||||
E std::vector<Anope::string> domains;
|
||||
E void InitLanguages();
|
||||
E const char *translate(const char *string);
|
||||
E const char *translate(User *u, const char *string);
|
||||
E const char *translate(NickCore *nc, const char *string);
|
||||
E const char *translate(const NickCore *nc, const char *string);
|
||||
E const char *anope_gettext(const char *lang, const char *string);
|
||||
|
||||
/**** main.c ****/
|
||||
@@ -109,31 +66,6 @@ E bool restarting;
|
||||
E Anope::string quitmsg;
|
||||
E time_t start_time;
|
||||
|
||||
class UplinkSocket : public ConnectionSocket, public BufferedSocket
|
||||
{
|
||||
public:
|
||||
UplinkSocket();
|
||||
~UplinkSocket();
|
||||
bool Read(const Anope::string &);
|
||||
void OnConnect();
|
||||
void OnError(const Anope::string &);
|
||||
|
||||
class CoreExport Message
|
||||
{
|
||||
Anope::string source;
|
||||
std::stringstream buffer;
|
||||
public:
|
||||
Message();
|
||||
Message(const Anope::string &);
|
||||
~Message();
|
||||
template<typename T> Message &operator<<(const T &val)
|
||||
{
|
||||
this->buffer << val;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
};
|
||||
E UplinkSocket *UplinkSock;
|
||||
E int CurrentUplink;
|
||||
|
||||
E void save_databases();
|
||||
@@ -172,9 +104,9 @@ E bool OnError(const Anope::string &, const std::vector<Anope::string> &);
|
||||
E bool IsFile(const Anope::string &filename);
|
||||
|
||||
E time_t dotime(const Anope::string &s);
|
||||
E Anope::string duration(const time_t &seconds, NickCore *nc = NULL);
|
||||
E Anope::string expire_left(NickCore *nc, time_t expires);
|
||||
E Anope::string do_strftime(const time_t &t, NickCore *nc = NULL, bool short_output = false);
|
||||
E Anope::string duration(const time_t &seconds, const NickCore *nc = NULL);
|
||||
E Anope::string expire_left(const NickCore *nc, time_t expires);
|
||||
E Anope::string do_strftime(const time_t &t, const NickCore *nc = NULL, bool short_output = false);
|
||||
E bool IsValidIdent(const Anope::string &ident);
|
||||
E bool IsValidHost(const Anope::string &host);
|
||||
|
||||
@@ -183,12 +115,6 @@ E Anope::string myStrGetTokenRemainder(const Anope::string &str, char dilim, int
|
||||
E int myNumToken(const Anope::string &str, char dilim);
|
||||
E bool nickIsServices(const Anope::string &nick, bool bot);
|
||||
|
||||
E void add_entropy_userkeys();
|
||||
E void rand_init();
|
||||
E unsigned char getrandom8();
|
||||
E uint16_t getrandom16();
|
||||
E uint32_t getrandom32();
|
||||
|
||||
E std::list<Anope::string> BuildStringList(const Anope::string &, char = ' ');
|
||||
E std::vector<Anope::string> BuildStringVector(const Anope::string &, char = ' ');
|
||||
|
||||
@@ -197,45 +123,14 @@ 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 */
|
||||
E unsigned GenericChannelModes, GenericUserModes;
|
||||
E std::multimap<ChannelModeName, ModeLock> def_mode_locks;
|
||||
E std::multimap<ChannelModeName, ModeLock *> def_mode_locks;
|
||||
E void SetDefaultMLock(ServerConfig *config);
|
||||
|
||||
/**** nickserv.c ****/
|
||||
|
||||
E void change_core_display(NickCore *nc);
|
||||
E void change_core_display(NickCore *nc, const Anope::string &newdisplay);
|
||||
|
||||
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);
|
||||
|
||||
/**** process.c ****/
|
||||
|
||||
E void process(const Anope::string &buf);
|
||||
|
||||
/**** sockets.cpp ****/
|
||||
|
||||
E int32_t TotalRead;
|
||||
E int32_t TotalWritten;
|
||||
E SocketIO normalSocketIO;
|
||||
|
||||
/**** users.c ****/
|
||||
|
||||
E int32_t opcnt;
|
||||
E uint32_t maxusercnt, usercnt;
|
||||
E time_t maxusertime;
|
||||
|
||||
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);
|
||||
|
||||
E void do_umode(const Anope::string &user, const Anope::string &modes);
|
||||
E void do_kill(User *user, const Anope::string &reason);
|
||||
|
||||
E bool matches_list(Channel *c, User *user, ChannelModeName mode);
|
||||
|
||||
E Anope::string create_mask(User *u);
|
||||
|
||||
#endif /* EXTERN_H */
|
||||
|
||||
+40
-232
@@ -13,141 +13,57 @@
|
||||
#ifndef HASHCOMP_H
|
||||
#define HASHCOMP_H
|
||||
|
||||
#ifdef _WIN32
|
||||
# ifdef MODULE_COMPILE
|
||||
# define CoreExport __declspec(dllimport)
|
||||
# define DllExport __declspec(dllexport)
|
||||
# else
|
||||
# define CoreExport __declspec(dllexport)
|
||||
# define DllExport __declspec(dllimport)
|
||||
# endif
|
||||
#else
|
||||
# define CoreExport
|
||||
# define DllExport
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
#include <locale>
|
||||
|
||||
#include "services.h"
|
||||
|
||||
namespace Anope
|
||||
{
|
||||
class string;
|
||||
}
|
||||
|
||||
/*******************************************************
|
||||
* This file contains classes and templates that deal
|
||||
* with the comparison and hashing of 'irc strings'.
|
||||
* An 'irc string' is a string which compares in a
|
||||
* case insensitive manner, and as per RFC 1459 will
|
||||
* treat [ identical to {, ] identical to }, and \
|
||||
* as identical to |.
|
||||
*
|
||||
* Our hashing functions are designed to accept
|
||||
* std::string and compare/hash them as type irc::string
|
||||
* by converting them internally. This makes them
|
||||
* backwards compatible with other code which is not
|
||||
* aware of irc::string.
|
||||
*******************************************************/
|
||||
extern std::locale casemap;
|
||||
|
||||
/** A mapping of uppercase to lowercase, including scandinavian
|
||||
* 'oddities' as specified by RFC1459, e.g. { -> [, and | -> \
|
||||
*/
|
||||
unsigned const char rfc_case_insensitive_map[256] = {
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, /* 0-19 */
|
||||
20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, /* 20-39 */
|
||||
40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, /* 40-59 */
|
||||
60, 61, 62, 63, 64, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, /* 60-79 */
|
||||
112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 94, 95, 96, 97, 98, 99, /* 80-99 */
|
||||
100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, /* 100-119 */
|
||||
120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, /* 120-139 */
|
||||
140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, /* 140-159 */
|
||||
160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, /* 160-179 */
|
||||
180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, /* 180-199 */
|
||||
200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, /* 200-219 */
|
||||
220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, /* 220-239 */
|
||||
240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255 /* 240-255 */
|
||||
};
|
||||
|
||||
/** Case insensitive map, ASCII rules.
|
||||
* That is;
|
||||
* [ != {, but A == a.
|
||||
*/
|
||||
unsigned const char ascii_case_insensitive_map[256] = {
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, /* 0-19 */
|
||||
20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, /* 20-39 */
|
||||
40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, /* 40-59 */
|
||||
60, 61, 62, 63, 64, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, /* 60-79 */
|
||||
112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 91, 92, 93, 94, 95, 96, 97, 98, 99, /* 80-99 */
|
||||
100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, /* 100-119 */
|
||||
120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, /* 120-139 */
|
||||
140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, /* 140-159 */
|
||||
160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, /* 160-179 */
|
||||
180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, /* 180-199 */
|
||||
200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, /* 200-219 */
|
||||
220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, /* 220-239 */
|
||||
240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255 /* 240-255 */
|
||||
};
|
||||
|
||||
/** The irc namespace contains a number of helper classes.
|
||||
*/
|
||||
namespace irc
|
||||
{
|
||||
/** The irc_char_traits class is used for RFC-style comparison of strings.
|
||||
* This class is used to implement irc::string, a case-insensitive, RFC-
|
||||
* comparing string class.
|
||||
*/
|
||||
struct irc_char_traits : std::char_traits<char>
|
||||
template<typename charT>
|
||||
class ascii_ctype : public std::ctype<charT>
|
||||
{
|
||||
/** Check if two chars match.
|
||||
* @param c1st First character
|
||||
* @param c2nd Second character
|
||||
* @return true if the characters are equal
|
||||
*/
|
||||
static bool eq(char c1st, char c2nd);
|
||||
public:
|
||||
charT do_toupper(charT c) const anope_override
|
||||
{
|
||||
if (c >= 'a' && c <= 'z')
|
||||
return c - 32;
|
||||
else
|
||||
return c;
|
||||
}
|
||||
|
||||
/** Check if two chars do NOT match.
|
||||
* @param c1st First character
|
||||
* @param c2nd Second character
|
||||
* @return true if the characters are unequal
|
||||
*/
|
||||
static bool ne(char c1st, char c2nd);
|
||||
|
||||
/** Check if one char is less than another.
|
||||
* @param c1st First character
|
||||
* @param c2nd Second character
|
||||
* @return true if c1st is less than c2nd
|
||||
*/
|
||||
static bool lt(char c1st, char c2nd);
|
||||
|
||||
/** Compare two strings of size n.
|
||||
* @param str1 First string
|
||||
* @param str2 Second string
|
||||
* @param n Length to compare to
|
||||
* @return similar to strcmp, zero for equal, less than zero for str1
|
||||
* being less and greater than zero for str1 being greater than str2.
|
||||
*/
|
||||
static int compare(const char *str1, const char *str2, size_t n);
|
||||
|
||||
/** Find a char within a string up to position n.
|
||||
* @param s1 String to find in
|
||||
* @param n Position to search up to
|
||||
* @param c Character to search for
|
||||
* @return Pointer to the first occurance of c in s1
|
||||
*/
|
||||
static const char *find(const char *s1, int n, char c);
|
||||
charT do_tolower(charT c) const anope_override
|
||||
{
|
||||
if (c >= 'A' && c <= 'Z')
|
||||
return c + 32;
|
||||
else
|
||||
return c;
|
||||
}
|
||||
};
|
||||
|
||||
/** This typedef declares irc::string based upon irc_char_traits.
|
||||
*/
|
||||
typedef std::basic_string<char, irc_char_traits, std::allocator<char> > string;
|
||||
|
||||
struct CoreExport less
|
||||
template<typename charT>
|
||||
class rfc1459_ctype : public ascii_ctype<charT>
|
||||
{
|
||||
/** Compare two Anope::strings as irc::strings and find which one is less
|
||||
* @param s1 The first string
|
||||
* @param s2 The second string
|
||||
* @return true if s1 < s2, else false
|
||||
*/
|
||||
bool operator()(const Anope::string &s1, const Anope::string &s2) const;
|
||||
public:
|
||||
charT do_toupper(charT c) const anope_override
|
||||
{
|
||||
if (c == '{' || c == '}' || c == '|')
|
||||
return c - 32;
|
||||
else
|
||||
return ascii_ctype<charT>::do_toupper(c);
|
||||
}
|
||||
|
||||
charT do_tolower(charT c) const anope_override
|
||||
{
|
||||
if (c == '[' || c == ']' || c == '\\')
|
||||
return c + 32;
|
||||
else
|
||||
return ascii_ctype<charT>::do_tolower(c);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -215,26 +131,6 @@ namespace ci
|
||||
};
|
||||
}
|
||||
|
||||
/* Define operators for + and == with irc::string to std::string for easy assignment
|
||||
* and comparison
|
||||
*
|
||||
* Operator +
|
||||
*/
|
||||
inline std::string operator+(std::string &leftval, irc::string &rightval)
|
||||
{
|
||||
return leftval + std::string(rightval.c_str());
|
||||
}
|
||||
|
||||
/* Define operators for + and == with irc::string to std::string for easy assignment
|
||||
* and comparison
|
||||
*
|
||||
* Operator +
|
||||
*/
|
||||
inline irc::string operator+(irc::string &leftval, std::string &rightval)
|
||||
{
|
||||
return leftval + irc::string(rightval.c_str());
|
||||
}
|
||||
|
||||
/* Define operators for + and == with ci::string to std::string for easy assignment
|
||||
* and comparison
|
||||
*
|
||||
@@ -255,46 +151,6 @@ inline ci::string operator+(ci::string &leftval, std::string &rightval)
|
||||
return leftval + ci::string(rightval.c_str());
|
||||
}
|
||||
|
||||
/* Define operators for + and == with irc::string to ci::string for easy assignment
|
||||
* and comparison
|
||||
*
|
||||
* Operator +
|
||||
*/
|
||||
inline irc::string operator+(irc::string &leftval, ci::string &rightval)
|
||||
{
|
||||
return leftval + irc::string(rightval.c_str());
|
||||
}
|
||||
|
||||
/* Define operators for + and == with irc::string to ci::string for easy assignment
|
||||
* and comparison
|
||||
*
|
||||
* Operator +
|
||||
*/
|
||||
inline ci::string operator+(ci::string &leftval, irc::string &rightval)
|
||||
{
|
||||
return leftval + ci::string(rightval.c_str());
|
||||
}
|
||||
|
||||
/* Define operators for + and == with irc::string to std::string for easy assignment
|
||||
* and comparison
|
||||
*
|
||||
* Operator ==
|
||||
*/
|
||||
inline bool operator==(const std::string &leftval, const irc::string &rightval)
|
||||
{
|
||||
return leftval.c_str() == rightval;
|
||||
}
|
||||
|
||||
/* Define operators for + and == with irc::string to std::string for easy assignment
|
||||
* and comparison
|
||||
*
|
||||
* Operator ==
|
||||
*/
|
||||
inline bool operator==(const irc::string &leftval, const std::string &rightval)
|
||||
{
|
||||
return leftval == rightval.c_str();
|
||||
}
|
||||
|
||||
/* Define operators for + and == with ci::string to std::string for easy assignment
|
||||
* and comparison
|
||||
*
|
||||
@@ -315,40 +171,6 @@ inline bool operator==(const ci::string &leftval, const std::string &rightval)
|
||||
return leftval == rightval.c_str();
|
||||
}
|
||||
|
||||
/* Define operators for + and == with irc::string to ci::string for easy assignment
|
||||
* and comparison
|
||||
*
|
||||
* Operator ==
|
||||
*/
|
||||
inline bool operator==(const ci::string &leftval, const irc::string &rightval)
|
||||
{
|
||||
return leftval.c_str() == rightval;
|
||||
}
|
||||
|
||||
/* Define operators for + and == with irc::string to ci::string for easy assignment
|
||||
* and comparison
|
||||
*
|
||||
* Operator ==
|
||||
*/
|
||||
inline bool operator==(const irc::string &leftval, const ci::string &rightval)
|
||||
{
|
||||
return leftval == rightval.c_str();
|
||||
}
|
||||
|
||||
/* Define operators != for irc::string to std::string for easy comparison
|
||||
*/
|
||||
inline bool operator!=(const irc::string &leftval, const std::string &rightval)
|
||||
{
|
||||
return !(leftval == rightval.c_str());
|
||||
}
|
||||
|
||||
/* Define operators != for std::string to irc::string for easy comparison
|
||||
*/
|
||||
inline bool operator!=(const std::string &leftval, const irc::string &rightval)
|
||||
{
|
||||
return !(leftval.c_str() == rightval);
|
||||
}
|
||||
|
||||
/* Define operators != for ci::string to std::string for easy comparison
|
||||
*/
|
||||
inline bool operator!=(const ci::string &leftval, const std::string &rightval)
|
||||
@@ -356,25 +178,11 @@ inline bool operator!=(const ci::string &leftval, const std::string &rightval)
|
||||
return !(leftval == rightval.c_str());
|
||||
}
|
||||
|
||||
/* Define operators != for ci::string to irc::string for easy comparison
|
||||
/* Define operators != for std::string to ci::string for easy comparison
|
||||
*/
|
||||
inline bool operator!=(const std::string &leftval, const ci::string &rightval)
|
||||
{
|
||||
return !(leftval.c_str() == rightval);
|
||||
}
|
||||
|
||||
/* Define operators != for irc::string to ci::string for easy comparison
|
||||
*/
|
||||
inline bool operator!=(const irc::string &leftval, const ci::string &rightval)
|
||||
{
|
||||
return !(leftval == rightval.c_str());
|
||||
}
|
||||
|
||||
/* Define operators != for irc::string to ci::string for easy comparison
|
||||
*/
|
||||
inline bool operator!=(const ci::string &leftval, const irc::string &rightval)
|
||||
{
|
||||
return !(leftval.c_str() == rightval);
|
||||
}
|
||||
|
||||
#endif // HASHCOMP_H
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
*
|
||||
* (C) 2003-2012 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.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LISTS_H
|
||||
#define LISTS_H
|
||||
|
||||
#include "services.h"
|
||||
#include "anope.h"
|
||||
|
||||
/** A class to process numbered lists (passed to most DEL/LIST/VIEW commands).
|
||||
* The function HandleNumber is called for every number in the list. Note that
|
||||
* if descending is true it gets called in descending order. This is so deleting
|
||||
* the index passed to the function from an array will not cause the other indexes
|
||||
* passed to the function to be incorrect. This keeps us from having to have an
|
||||
* 'in use' flag on everything.
|
||||
*/
|
||||
class CoreExport NumberList
|
||||
{
|
||||
private:
|
||||
bool is_valid;
|
||||
|
||||
std::set<unsigned> numbers;
|
||||
|
||||
bool desc;
|
||||
public:
|
||||
/** Processes a numbered list
|
||||
* @param list The list
|
||||
* @param descending True to make HandleNumber get called with numbers in descending order
|
||||
*/
|
||||
NumberList(const Anope::string &list, bool descending);
|
||||
|
||||
/** Destructor, does nothing
|
||||
*/
|
||||
virtual ~NumberList();
|
||||
|
||||
/** Should be called after the constructors are done running. This calls the callbacks.
|
||||
*/
|
||||
void Process();
|
||||
|
||||
/** Called with a number from the list
|
||||
* @param Number The number
|
||||
*/
|
||||
virtual void HandleNumber(unsigned Number);
|
||||
|
||||
/** Called when there is an error with the numbered list
|
||||
* Return false to immediatly stop processing the list and return
|
||||
* This is all done before we start calling HandleNumber, so no numbers will have been processed yet
|
||||
* @param list The list
|
||||
* @return false to stop processing
|
||||
*/
|
||||
virtual bool InvalidRange(const Anope::string &list);
|
||||
};
|
||||
|
||||
/** This class handles formatting LIST/VIEW replies.
|
||||
*/
|
||||
class CoreExport ListFormatter
|
||||
{
|
||||
public:
|
||||
typedef std::map<Anope::string, Anope::string> ListEntry;
|
||||
private:
|
||||
std::vector<Anope::string> columns;
|
||||
std::vector<ListEntry> entries;
|
||||
public:
|
||||
ListFormatter &addColumn(const Anope::string &name);
|
||||
void addEntry(const ListEntry &entry);
|
||||
bool isEmpty() const;
|
||||
void Process(std::vector<Anope::string> &);
|
||||
};
|
||||
|
||||
/** This class handles formatting INFO replies
|
||||
*/
|
||||
class CoreExport InfoFormatter
|
||||
{
|
||||
NickCore *nc;
|
||||
std::vector<std::pair<Anope::string, Anope::string> > replies;
|
||||
unsigned longest;
|
||||
public:
|
||||
InfoFormatter(NickCore *nc);
|
||||
void Process(std::vector<Anope::string> &);
|
||||
Anope::string &operator[](const Anope::string &key);
|
||||
};
|
||||
|
||||
#endif // LISTS_H
|
||||
|
||||
+26
-10
@@ -1,6 +1,21 @@
|
||||
/*
|
||||
*
|
||||
* (C) 2003-2012 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LOGGER_H
|
||||
#define LOGGER_H
|
||||
|
||||
#include "anope.h"
|
||||
#include "defs.h"
|
||||
|
||||
enum LogType
|
||||
{
|
||||
LOG_ADMIN,
|
||||
@@ -29,16 +44,17 @@ struct LogFile
|
||||
Anope::string GetName() const;
|
||||
};
|
||||
|
||||
class Command;
|
||||
|
||||
class CoreExport Log
|
||||
{
|
||||
public:
|
||||
BotInfo *bi;
|
||||
User *u;
|
||||
const BotInfo *bi;
|
||||
Anope::string nick;
|
||||
const User *u;
|
||||
const NickCore *nc;
|
||||
Command *c;
|
||||
Channel *chan;
|
||||
ChannelInfo *ci;
|
||||
const ChannelInfo *ci;
|
||||
Server *s;
|
||||
LogType Type;
|
||||
Anope::string Category;
|
||||
@@ -46,21 +62,21 @@ class CoreExport Log
|
||||
|
||||
std::stringstream buf;
|
||||
|
||||
Log(LogType type = LOG_NORMAL, const Anope::string &category = "", BotInfo *bi = NULL);
|
||||
Log(LogType type = LOG_NORMAL, const Anope::string &category = "", const BotInfo *bi = NULL);
|
||||
|
||||
/* LOG_COMMAND/OVERRIDE/ADMIN */
|
||||
Log(LogType type, User *u, Command *c, ChannelInfo *ci = NULL);
|
||||
Log(LogType type, const CommandSource &source, Command *c, const ChannelInfo *ci = NULL);
|
||||
|
||||
/* LOG_CHANNEL */
|
||||
Log(User *u, Channel *c, const Anope::string &category = "");
|
||||
Log(const User *u, Channel *c, const Anope::string &category = "");
|
||||
|
||||
/* LOG_USER */
|
||||
explicit Log(User *u, const Anope::string &category = "");
|
||||
explicit Log(const User *u, const Anope::string &category = "", const BotInfo *bi = NULL);
|
||||
|
||||
/* LOG_SERVER */
|
||||
Log(Server *s, const Anope::string &category = "");
|
||||
explicit Log(Server *s, const Anope::string &category = "", const BotInfo *bi = NULL);
|
||||
|
||||
Log(BotInfo *b, const Anope::string &category = "");
|
||||
explicit Log(const BotInfo *b, const Anope::string &category = "");
|
||||
|
||||
~Log();
|
||||
|
||||
|
||||
+16
-1
@@ -1,9 +1,24 @@
|
||||
/*
|
||||
*
|
||||
* (C) 2003-2012 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.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MAIL_H
|
||||
#define MAIL_H
|
||||
|
||||
#include "anope.h"
|
||||
#include "threadengine.h"
|
||||
#include "serialize.h"
|
||||
|
||||
extern CoreExport bool Mail(User *u, NickCore *nc, BotInfo *service, const Anope::string &subject, const Anope::string &message);
|
||||
extern CoreExport bool Mail(User *u, NickCore *nc, const BotInfo *service, const Anope::string &subject, const Anope::string &message);
|
||||
extern CoreExport bool Mail(NickCore *nc, const Anope::string &subject, const Anope::string &message);
|
||||
extern CoreExport bool MailValidate(const Anope::string &email);
|
||||
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
*
|
||||
* (C) 2003-2012 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.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MEMO_H
|
||||
#define MEMO_H
|
||||
|
||||
#include "anope.h"
|
||||
#include "serialize.h"
|
||||
|
||||
/** Memo Flags
|
||||
*/
|
||||
enum MemoFlag
|
||||
{
|
||||
/* Memo is unread */
|
||||
MF_UNREAD,
|
||||
/* Sender requests a receipt */
|
||||
MF_RECEIPT
|
||||
};
|
||||
|
||||
const Anope::string MemoFlagStrings[] = {
|
||||
"MF_UNREAD", "MF_RECEIPT", ""
|
||||
};
|
||||
|
||||
/* Memo info structures. Since both nicknames and channels can have memos,
|
||||
* we encapsulate memo data in a MemoList to make it easier to handle. */
|
||||
class CoreExport Memo : public Flags<MemoFlag>, public Serializable
|
||||
{
|
||||
public:
|
||||
Memo();
|
||||
|
||||
const Anope::string serialize_name() const anope_override;
|
||||
Serialize::Data serialize() const anope_override;
|
||||
static Serializable* unserialize(Serializable *obj, Serialize::Data &);
|
||||
|
||||
Anope::string owner;
|
||||
time_t time; /* When it was sent */
|
||||
Anope::string sender;
|
||||
Anope::string text;
|
||||
};
|
||||
|
||||
struct CoreExport MemoInfo
|
||||
{
|
||||
int16_t memomax;
|
||||
serialize_checker<std::vector<Memo *> > memos;
|
||||
std::vector<Anope::string> ignores;
|
||||
|
||||
MemoInfo();
|
||||
Memo *GetMemo(unsigned index) const;
|
||||
unsigned GetIndex(Memo *m) const;
|
||||
void Del(unsigned index);
|
||||
void Del(Memo *m);
|
||||
bool HasIgnore(User *u);
|
||||
};
|
||||
|
||||
#endif // MEMO_H
|
||||
+63
-49
@@ -9,6 +9,9 @@
|
||||
#ifndef MODES_H
|
||||
#define MODES_H
|
||||
|
||||
#include "anope.h"
|
||||
#include "base.h"
|
||||
|
||||
/** All of the valid user mode names
|
||||
*/
|
||||
enum UserModeName
|
||||
@@ -16,7 +19,7 @@ enum UserModeName
|
||||
UMODE_BEGIN,
|
||||
|
||||
UMODE_SERV_ADMIN, UMODE_BOT, UMODE_CO_ADMIN, UMODE_FILTER, UMODE_HIDEOPER, UMODE_NETADMIN,
|
||||
UMODE_REGPRIV, UMODE_PROTECTED, UMODE_NO_CTCP, UMODE_WEBTV, UMODE_WEBIRC, UMODE_WHOIS, UMODE_ADMIN, UMODE_DEAF,
|
||||
UMODE_REGPRIV, UMODE_PROTECTED, UMODE_NOCTCP, UMODE_WEBTV, UMODE_WEBIRC, UMODE_WHOIS, UMODE_ADMIN, UMODE_DEAF,
|
||||
UMODE_GLOBOPS, UMODE_HELPOP, UMODE_INVIS, UMODE_OPER, UMODE_PRIV, UMODE_GOD, UMODE_REGISTERED,
|
||||
UMODE_SNOMASK, UMODE_VHOST, UMODE_WALLOPS, UMODE_CLOAK, UMODE_SSL, UMODE_SOFTCALLERID, UMODE_CALLERID,
|
||||
UMODE_COMMONCHANS, UMODE_HIDDEN, UMODE_STRIPCOLOR, UMODE_INVISIBLE_OPER, UMODE_RESTRICTED, UMODE_HIDEIDLE,
|
||||
@@ -28,7 +31,7 @@ const Anope::string UserModeNameStrings[] = {
|
||||
"UMODE_BEGIN",
|
||||
|
||||
"UMODE_SERV_ADMIN", "UMODE_BOT", "UMODE_CO_ADMIN", "UMODE_FILTER", "UMODE_HIDEOPER", "UMODE_NETADMIN",
|
||||
"UMODE_REGPRIV", "UMODE_PROTECTED", "UMODE_NO_CTCP", "UMODE_WEBTV", "UMODE_WEBIRC", "UMODE_WHOIS", "UMODE_ADMIN", "UMODE_DEAF",
|
||||
"UMODE_REGPRIV", "UMODE_PROTECTED", "UMODE_NOCTCP", "UMODE_WEBTV", "UMODE_WEBIRC", "UMODE_WHOIS", "UMODE_ADMIN", "UMODE_DEAF",
|
||||
"UMODE_GLOBOPS", "UMODE_HELPOP", "UMODE_INVIS", "UMODE_OPER", "UMODE_PRIV", "UMODE_GOD", "UMODE_REGISTERED",
|
||||
"UMODE_SNOMASK", "UMODE_VHOST", "UMODE_WALLOPS", "UMODE_CLOAK", "UMODE_SSL", "UMODE_SOFTCALLERID", "UMODE_CALLERID",
|
||||
"UMODE_COMMONCHANS", "UMODE_HIDDEN", "UMODE_STRIPCOLOR", "UMODE_INVISIBLE_OPER", "UMODE_RESTRICTED", "UMODE_HIDEIDLE",
|
||||
@@ -228,7 +231,7 @@ class CoreExport ChannelModeList : public ChannelMode
|
||||
* @param e The entry to match against
|
||||
* @return true on match
|
||||
*/
|
||||
virtual bool Matches(User *u, const Entry *e) { return false; }
|
||||
virtual bool Matches(const User *u, const Entry *e) { return false; }
|
||||
|
||||
/** Called when a mask is added to a channel
|
||||
* @param chan The channel
|
||||
@@ -301,7 +304,7 @@ class CoreExport ChannelModeKey : public ChannelModeParam
|
||||
public:
|
||||
ChannelModeKey(char modeChar) : ChannelModeParam(CMODE_KEY, modeChar) { }
|
||||
|
||||
bool IsValid(const Anope::string &value) const;
|
||||
bool IsValid(const Anope::string &value) const anope_override;
|
||||
};
|
||||
|
||||
/** This class is used for channel mode +A (Admin only)
|
||||
@@ -313,7 +316,7 @@ class CoreExport ChannelModeAdmin : public ChannelMode
|
||||
ChannelModeAdmin(char modeChar) : ChannelMode(CMODE_ADMINONLY, modeChar) { }
|
||||
|
||||
/* Opers only */
|
||||
bool CanSet(User *u) const;
|
||||
bool CanSet(User *u) const anope_override;
|
||||
};
|
||||
|
||||
/** This class is used for channel mode +O (Opers only)
|
||||
@@ -325,7 +328,7 @@ class CoreExport ChannelModeOper : public ChannelMode
|
||||
ChannelModeOper(char modeChar) : ChannelMode(CMODE_OPERONLY, modeChar) { }
|
||||
|
||||
/* Opers only */
|
||||
bool CanSet(User *u) const;
|
||||
bool CanSet(User *u) const anope_override;
|
||||
};
|
||||
|
||||
/** This class is used for channel mode +r (registered channel)
|
||||
@@ -337,26 +340,18 @@ class CoreExport ChannelModeRegistered : public ChannelMode
|
||||
ChannelModeRegistered(char modeChar) : ChannelMode(CMODE_REGISTERED, modeChar) { }
|
||||
|
||||
/* No one mlocks +r */
|
||||
bool CanSet(User *u) const;
|
||||
};
|
||||
|
||||
enum StackerType
|
||||
{
|
||||
ST_CHANNEL,
|
||||
ST_USER
|
||||
bool CanSet(User *u) const anope_override;
|
||||
};
|
||||
|
||||
class StackerInfo
|
||||
{
|
||||
public:
|
||||
/* Modes to be added */
|
||||
std::list<std::pair<Base *, Anope::string> > AddModes;
|
||||
std::list<std::pair<Mode *, Anope::string> > AddModes;
|
||||
/* Modes to be deleted */
|
||||
std::list<std::pair<Base *, Anope::string> > DelModes;
|
||||
/* The type of object this stacker info is for */
|
||||
StackerType Type;
|
||||
std::list<std::pair<Mode *, Anope::string> > DelModes;
|
||||
/* Bot this is sent from */
|
||||
BotInfo *bi;
|
||||
const BotInfo *bi;
|
||||
|
||||
/** Add a mode to this object
|
||||
* @param mode The mode
|
||||
@@ -375,24 +370,9 @@ class StackerInfo
|
||||
class CoreExport ModeManager
|
||||
{
|
||||
protected:
|
||||
class ModePipe : public Pipe
|
||||
{
|
||||
public:
|
||||
/** Called when there are modes to be set
|
||||
*/
|
||||
void OnNotify();
|
||||
};
|
||||
|
||||
static ModePipe *mpipe;
|
||||
|
||||
/* List of pairs of user/channels and their stacker info */
|
||||
static std::list<std::pair<Base *, StackerInfo *> > StackerObjects;
|
||||
|
||||
/** Get the stacker info for an item, if one doesnt exist it is created
|
||||
* @param Item The user/channel etc
|
||||
* @return The stacker info
|
||||
*/
|
||||
static StackerInfo *GetInfo(Base *Item);
|
||||
static std::map<User *, StackerInfo *> UserStackerObjects;
|
||||
static std::map<Channel *, StackerInfo *> ChannelStackerObjects;
|
||||
|
||||
/** Build a list of mode strings to send to the IRCd from the mode stacker
|
||||
* @param info The stacker info for a channel or user
|
||||
@@ -400,16 +380,6 @@ class CoreExport ModeManager
|
||||
*/
|
||||
static std::list<Anope::string> BuildModeStrings(StackerInfo *info);
|
||||
|
||||
/** Really add a mode to the stacker, internal use only
|
||||
* @param bi The client to set the modes from
|
||||
* @param Object The object, user/channel
|
||||
* @param mode The mode
|
||||
* @param Set Adding or removing?
|
||||
* @param Param A param, if there is one
|
||||
* @param Type The type this is, user or channel
|
||||
*/
|
||||
static void StackerAddInternal(BotInfo *bi, Base *Object, Mode *mode, bool Set, const Anope::string &Param, StackerType Type);
|
||||
|
||||
public:
|
||||
/* List of all modes Anope knows about */
|
||||
static std::vector<ChannelMode *> ChannelModes;
|
||||
@@ -476,7 +446,7 @@ class CoreExport ModeManager
|
||||
* @param Set true for setting, false for removing
|
||||
* @param Param The param, if there is one
|
||||
*/
|
||||
static void StackerAdd(BotInfo *bi, Channel *c, ChannelMode *cm, bool Set, const Anope::string &Param = "");
|
||||
static void StackerAdd(const BotInfo *bi, Channel *c, ChannelMode *cm, bool Set, const Anope::string &Param = "");
|
||||
|
||||
/** Add a mode to the stacker to be set on a user
|
||||
* @param bi The client to set the modes from
|
||||
@@ -485,16 +455,60 @@ class CoreExport ModeManager
|
||||
* @param Set true for setting, false for removing
|
||||
* @param param The param, if there is one
|
||||
*/
|
||||
static void StackerAdd(BotInfo *bi, User *u, UserMode *um, bool Set, const Anope::string &Param = "");
|
||||
static void StackerAdd(const BotInfo *bi, User *u, UserMode *um, bool Set, const Anope::string &Param = "");
|
||||
|
||||
/** Process all of the modes in the stacker and send them to the IRCd to be set on channels/users
|
||||
*/
|
||||
static void ProcessModes();
|
||||
|
||||
/** Delete a user or channel from the stacker
|
||||
* @param b The user/channel
|
||||
*/
|
||||
static void StackerDel(Base *b);
|
||||
static void StackerDel(User *u);
|
||||
static void StackerDel(Channel *c);
|
||||
};
|
||||
|
||||
/** Entry flags
|
||||
*/
|
||||
enum EntryType
|
||||
{
|
||||
ENTRYTYPE_NONE,
|
||||
ENTRYTYPE_CIDR,
|
||||
ENTRYTYPE_NICK_WILD,
|
||||
ENTRYTYPE_NICK,
|
||||
ENTRYTYPE_USER_WILD,
|
||||
ENTRYTYPE_USER,
|
||||
ENTRYTYPE_HOST_WILD,
|
||||
ENTRYTYPE_HOST
|
||||
};
|
||||
|
||||
/** Represents a mask set on a channel (b/e/I)
|
||||
*/
|
||||
class CoreExport Entry : public Flags<EntryType>
|
||||
{
|
||||
ChannelModeName modename;
|
||||
|
||||
public:
|
||||
unsigned char cidr_len;
|
||||
Anope::string mask;
|
||||
Anope::string nick, user, host;
|
||||
|
||||
/** Constructor
|
||||
* @param _host A full nick!ident@host/cidr mask
|
||||
* @param mode What mode this host is for - can be CMODE_BEGIN for unknown/no mode
|
||||
*/
|
||||
Entry(ChannelModeName mode, const Anope::string &_host);
|
||||
|
||||
/** Get the banned mask for this entry
|
||||
* @return The mask
|
||||
*/
|
||||
const Anope::string GetMask();
|
||||
|
||||
/** Check if this entry matches a user
|
||||
* @param u The user
|
||||
* @param full True to match against a users real host and IP
|
||||
* @return true on match
|
||||
*/
|
||||
bool Matches(const User *u, bool full = false) const;
|
||||
};
|
||||
|
||||
#endif // MODES_H
|
||||
|
||||
+50
-2
@@ -1,9 +1,57 @@
|
||||
/*
|
||||
*
|
||||
* (C) 2003-2012 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.
|
||||
*/
|
||||
|
||||
#ifndef MODULE_H
|
||||
#define MODULE_H
|
||||
|
||||
#include "services.h"
|
||||
/* Just include everything for now */
|
||||
#include "access.h"
|
||||
#include "account.h"
|
||||
#include "anope.h"
|
||||
#include "base.h"
|
||||
#include "bots.h"
|
||||
#include "botserv.h"
|
||||
#include "channels.h"
|
||||
#include "commands.h"
|
||||
#include "config.h"
|
||||
#include "dns.h"
|
||||
#include "extensible.h"
|
||||
#include "extern.h"
|
||||
#include "hashcomp.h"
|
||||
#include "language.h"
|
||||
#include "lists.h"
|
||||
#include "logger.h"
|
||||
#include "mail.h"
|
||||
#include "memo.h"
|
||||
#include "modes.h"
|
||||
#include "modules.h"
|
||||
#include "oper.h"
|
||||
#include "commands.h"
|
||||
#include "opertype.h"
|
||||
#include "protocol.h"
|
||||
#include "regexpr.h"
|
||||
#include "regchannel.h"
|
||||
#include "serialize.h"
|
||||
#include "servers.h"
|
||||
#include "service.h"
|
||||
#include "services.h"
|
||||
#include "signals.h"
|
||||
#include "socketengine.h"
|
||||
#include "sockets.h"
|
||||
#include "threadengine.h"
|
||||
#include "timers.h"
|
||||
#include "uplink.h"
|
||||
#include "users.h"
|
||||
|
||||
#include "global.h"
|
||||
#include "memoserv.h"
|
||||
#include "nickserv.h"
|
||||
|
||||
#endif // MODULE_H
|
||||
|
||||
+114
-149
@@ -9,23 +9,48 @@
|
||||
* Based on the original code of Services by Andy Church.
|
||||
*/
|
||||
|
||||
#include "serialize.h"
|
||||
|
||||
#ifndef MODULES_H
|
||||
#define MODULES_H
|
||||
|
||||
#include <time.h>
|
||||
#include "services.h"
|
||||
#include <stdio.h>
|
||||
#include "base.h"
|
||||
#include "modes.h"
|
||||
#include "timers.h"
|
||||
#include "hashcomp.h"
|
||||
#include "logger.h"
|
||||
#include "extensible.h"
|
||||
|
||||
/** Possible return types from events.
|
||||
/** This definition is used as shorthand for the various classes
|
||||
* and functions needed to make a module loadable by the OS.
|
||||
* It defines the class factory and external AnopeInit and AnopeFini functions.
|
||||
*/
|
||||
enum EventReturn
|
||||
{
|
||||
EVENT_STOP,
|
||||
EVENT_CONTINUE,
|
||||
EVENT_ALLOW
|
||||
};
|
||||
#ifdef _WIN32
|
||||
# define MODULE_INIT(x) \
|
||||
extern "C" DllExport Module *AnopeInit(const Anope::string &, const Anope::string &); \
|
||||
extern "C" Module *AnopeInit(const Anope::string &modname, const Anope::string &creator) \
|
||||
{ \
|
||||
return new x(modname, creator); \
|
||||
} \
|
||||
BOOLEAN WINAPI DllMain(HINSTANCE, DWORD nReason, LPVOID) \
|
||||
{ \
|
||||
return TRUE; \
|
||||
} \
|
||||
extern "C" DllExport void AnopeFini(x *); \
|
||||
extern "C" void AnopeFini(x *m) \
|
||||
{ \
|
||||
delete m; \
|
||||
}
|
||||
#else
|
||||
# define MODULE_INIT(x) \
|
||||
extern "C" DllExport Module *AnopeInit(const Anope::string &modname, const Anope::string &creator) \
|
||||
{ \
|
||||
return new x(modname, creator); \
|
||||
} \
|
||||
extern "C" DllExport void AnopeFini(x *m) \
|
||||
{ \
|
||||
delete m; \
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This #define allows us to call a method in all
|
||||
@@ -35,8 +60,8 @@ enum EventReturn
|
||||
#define FOREACH_MOD(y, x) \
|
||||
if (true) \
|
||||
{ \
|
||||
std::vector<Module*>::iterator safei; \
|
||||
for (std::vector<Module*>::iterator _i = ModuleManager::EventHandlers[y].begin(); _i != ModuleManager::EventHandlers[y].end(); ) \
|
||||
std::vector<Module *>::iterator safei; \
|
||||
for (std::vector<Module *>::iterator _i = ModuleManager::EventHandlers[y].begin(); _i != ModuleManager::EventHandlers[y].end(); ) \
|
||||
{ \
|
||||
safei = _i; \
|
||||
++safei; \
|
||||
@@ -62,9 +87,9 @@ else \
|
||||
#define FOREACH_RESULT(y, x) \
|
||||
if (true) \
|
||||
{ \
|
||||
std::vector<Module*>::iterator safei; \
|
||||
std::vector<Module *>::iterator safei; \
|
||||
MOD_RESULT = EVENT_CONTINUE; \
|
||||
for (std::vector<Module*>::iterator _i = ModuleManager::EventHandlers[y].begin(); _i != ModuleManager::EventHandlers[y].end(); ) \
|
||||
for (std::vector<Module *>::iterator _i = ModuleManager::EventHandlers[y].begin(); _i != ModuleManager::EventHandlers[y].end(); ) \
|
||||
{ \
|
||||
safei = _i; \
|
||||
++safei; \
|
||||
@@ -86,24 +111,15 @@ if (true) \
|
||||
else \
|
||||
static_cast<void>(0)
|
||||
|
||||
#ifndef _WIN32
|
||||
# include <dlfcn.h>
|
||||
/* Define these for systems without them */
|
||||
# ifndef RTLD_NOW
|
||||
# define RTLD_NOW 0
|
||||
# endif
|
||||
# ifndef RTLD_LAZY
|
||||
# define RTLD_LAZY RTLD_NOW
|
||||
# endif
|
||||
# ifndef RTLD_GLOBAL
|
||||
# define RTLD_GLOBAL 0
|
||||
# endif
|
||||
# ifndef RTLD_LOCAL
|
||||
# define RTLD_LOCAL 0
|
||||
# endif
|
||||
#endif
|
||||
/** Possible return types from events.
|
||||
*/
|
||||
enum EventReturn
|
||||
{
|
||||
EVENT_STOP,
|
||||
EVENT_CONTINUE,
|
||||
EVENT_ALLOW
|
||||
};
|
||||
|
||||
class Message;
|
||||
|
||||
enum ModuleReturn
|
||||
{
|
||||
@@ -127,27 +143,27 @@ enum ModType { MT_BEGIN, THIRD, SUPPORTED, CORE, DATABASE, ENCRYPTION, PROTOCOL,
|
||||
|
||||
typedef std::multimap<Anope::string, Message *> message_map;
|
||||
extern CoreExport message_map MessageMap;
|
||||
class Module;
|
||||
|
||||
extern CoreExport std::list<Module *> Modules;
|
||||
|
||||
class Version
|
||||
class ModuleVersion
|
||||
{
|
||||
private:
|
||||
int Major;
|
||||
int Minor;
|
||||
int Build;
|
||||
int Patch;
|
||||
|
||||
public:
|
||||
/** Constructor
|
||||
* @param vMajor The major version numbber
|
||||
* @param vMinor The minor version numbber
|
||||
* @param vBuild The build version numbber
|
||||
* @param vPatch The patch version numbber
|
||||
*/
|
||||
Version(int vMajor, int vMinor, int vBuild);
|
||||
ModuleVersion(int vMajor, int vMinor, int vPatch);
|
||||
|
||||
/** Destructor
|
||||
*/
|
||||
virtual ~Version();
|
||||
virtual ~ModuleVersion();
|
||||
|
||||
/** Get the major version of Anope this was built against
|
||||
* @return The major version
|
||||
@@ -159,15 +175,12 @@ class Version
|
||||
*/
|
||||
int GetMinor() const;
|
||||
|
||||
/** Get the build version this was built against
|
||||
* @return The build version
|
||||
/** Get the patch version this was built against
|
||||
* @return The patch version
|
||||
*/
|
||||
int GetBuild() const;
|
||||
int GetPatch() const;
|
||||
};
|
||||
|
||||
class CallBack;
|
||||
class XLineManager;
|
||||
struct CommandSource;
|
||||
|
||||
/** Every module in Anope is actually a class.
|
||||
*/
|
||||
@@ -247,7 +260,7 @@ class CoreExport Module : public Extensible
|
||||
* compiled against
|
||||
* @return The version
|
||||
*/
|
||||
Version GetVersion() const;
|
||||
ModuleVersion GetVersion() const;
|
||||
|
||||
/** Called when the ircd notifies that a user has been kicked from a channel.
|
||||
* @param c The channel the user has been kicked from.
|
||||
@@ -370,18 +383,13 @@ class CoreExport Module : public Extensible
|
||||
* @param ci The channel
|
||||
* @param bw The badword
|
||||
*/
|
||||
virtual void OnBadWordAdd(ChannelInfo *ci, BadWord *bw) { }
|
||||
virtual void OnBadWordAdd(ChannelInfo *ci, const BadWord *bw) { }
|
||||
|
||||
/** Called before a badword is deleted from a channel
|
||||
* @param ci The channel
|
||||
* @param bw The badword
|
||||
*/
|
||||
virtual void OnBadWordDel(ChannelInfo *ci, BadWord *bw) { }
|
||||
|
||||
/** Called in findbot()
|
||||
* @param nick The nick being looked up
|
||||
*/
|
||||
virtual void OnFindBot(const Anope::string &nick) { }
|
||||
virtual void OnBadWordDel(ChannelInfo *ci, const BadWord *bw) { }
|
||||
|
||||
/** Called before a bot kicks a user
|
||||
* @param bi The bot sending the kick
|
||||
@@ -428,9 +436,10 @@ class CoreExport Module : public Extensible
|
||||
|
||||
/** Called when a new topic is set
|
||||
* @param c The channel
|
||||
* @param setter The user who set the new topic
|
||||
* @param topic The new topic
|
||||
*/
|
||||
virtual void OnTopicUpdated(Channel *c, const Anope::string &topic) { }
|
||||
virtual void OnTopicUpdated(Channel *c, User *setter, const Anope::string &topic) { }
|
||||
|
||||
/** Called before a channel expires
|
||||
* @param ci The channel
|
||||
@@ -490,25 +499,25 @@ class CoreExport Module : public Extensible
|
||||
virtual EventReturn OnExceptionAdd(Exception *ex) { return EVENT_CONTINUE; }
|
||||
|
||||
/** Called before an exception is deleted
|
||||
* @param u The user who is deleting it
|
||||
* @param source The source deleting it
|
||||
* @param ex The exceotion
|
||||
*/
|
||||
virtual void OnExceptionDel(User *u, Exception *ex) { }
|
||||
virtual void OnExceptionDel(CommandSource &source, Exception *ex) { }
|
||||
|
||||
/** Called before a XLine is added
|
||||
* @param u The user adding the XLine
|
||||
* @param source The source of the XLine
|
||||
* @param x The XLine
|
||||
* @param xlm The xline manager it was added to
|
||||
* @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, XLineManager *xlm) { return EVENT_CONTINUE; }
|
||||
virtual EventReturn OnAddXLine(CommandSource &source, const XLine *x, XLineManager *xlm) { return EVENT_CONTINUE; }
|
||||
|
||||
/** Called before a XLine is deleted
|
||||
* @param u The user deleting the XLine
|
||||
* @param x The XLine, can be NULL for all XLines
|
||||
* @param source The source of the XLine
|
||||
* @param x The XLine
|
||||
* @param xlm The xline manager it was deleted from
|
||||
*/
|
||||
virtual void OnDelXLine(User *u, XLine *x, XLineManager *xlm) { }
|
||||
virtual void OnDelXLine(CommandSource &source, const XLine *x, XLineManager *xlm) { }
|
||||
|
||||
/** Called when a user is checked for whether they are a services oper
|
||||
* @param u The user
|
||||
@@ -549,36 +558,36 @@ class CoreExport Module : public Extensible
|
||||
|
||||
/** Called when access is deleted from a channel
|
||||
* @param ci The channel
|
||||
* @param u The user who removed the access
|
||||
* @param source The source of the command
|
||||
* @param access The access entry being removed
|
||||
*/
|
||||
virtual void OnAccessDel(ChannelInfo *ci, User *u, ChanAccess *access) { }
|
||||
virtual void OnAccessDel(ChannelInfo *ci, CommandSource &source, ChanAccess *access) { }
|
||||
|
||||
/** Called when access is added
|
||||
* @param ci The channel
|
||||
* @param u The user who added the access
|
||||
* @param source The source of the command
|
||||
* @param access The access changed
|
||||
*/
|
||||
virtual void OnAccessAdd(ChannelInfo *ci, User *u, ChanAccess *access) { }
|
||||
virtual void OnAccessAdd(ChannelInfo *ci, CommandSource &source, ChanAccess *access) { }
|
||||
|
||||
/** Called when the access list is cleared
|
||||
* @param ci The channel
|
||||
* @param u The user who cleared the access
|
||||
*/
|
||||
virtual void OnAccessClear(ChannelInfo *ci, User *u) { }
|
||||
virtual void OnAccessClear(ChannelInfo *ci, CommandSource &source) { }
|
||||
|
||||
/** Called when a level for a channel is changed
|
||||
* @param u The user changing the level
|
||||
* @param source The source of the command
|
||||
* @param ci The channel the level was changed on
|
||||
* @param priv The privilege changed
|
||||
* @param what The new level
|
||||
*/
|
||||
virtual void OnLevelChange(User *u, ChannelInfo *ci, const Anope::string &priv, int16_t what) { }
|
||||
virtual void OnLevelChange(CommandSource &source, ChannelInfo *ci, const Anope::string &priv, int16_t what) { }
|
||||
|
||||
/** Called when a channel is dropped
|
||||
* @param chname The channel name
|
||||
/** Called right before a channel is dropped
|
||||
* @param ci The channel
|
||||
*/
|
||||
virtual void OnChanDrop(const Anope::string &chname) { }
|
||||
virtual void OnChanDrop(ChannelInfo *ci) { }
|
||||
|
||||
/** Called when a channel is registered
|
||||
* @param ci The channel
|
||||
@@ -616,18 +625,18 @@ class CoreExport Module : public Extensible
|
||||
virtual void OnChannelDelete(Channel *c) { }
|
||||
|
||||
/** Called after adding an akick to a channel
|
||||
* @param u The user adding the akick
|
||||
* @param source The source of the command
|
||||
* @param ci The channel
|
||||
* @param ak The akick
|
||||
*/
|
||||
virtual void OnAkickAdd(User *u, ChannelInfo *ci, AutoKick *ak) { }
|
||||
virtual void OnAkickAdd(CommandSource &source, ChannelInfo *ci, const AutoKick *ak) { }
|
||||
|
||||
/** Called before removing an akick from a channel
|
||||
* @param u The user removing the akick
|
||||
* @param source The source of the command
|
||||
* @param ci The channel
|
||||
* @param ak The akick
|
||||
*/
|
||||
virtual void OnAkickDel(User *u, ChannelInfo *ci, AutoKick *ak) { }
|
||||
virtual void OnAkickDel(CommandSource &source, ChannelInfo *ci, const AutoKick *ak) { }
|
||||
|
||||
/** Called after a user join a channel when we decide whether to kick them or not
|
||||
* @param u The user
|
||||
@@ -645,11 +654,6 @@ class CoreExport Module : public Extensible
|
||||
*/
|
||||
virtual void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool ShowHidden) { }
|
||||
|
||||
/** Called on cs_findchan()
|
||||
* @param chname The name being looked up
|
||||
*/
|
||||
virtual void OnFindChan(const Anope::string &chname) { }
|
||||
|
||||
/** Checks if access has the channel privilege 'priv'.
|
||||
* @param access THe access struct
|
||||
* @param priv The privilege being checked for
|
||||
@@ -665,10 +669,10 @@ class CoreExport Module : public Extensible
|
||||
virtual EventReturn OnGroupCheckPriv(const AccessGroup *group, const Anope::string &priv) { return EVENT_CONTINUE; }
|
||||
|
||||
/** Called when a nick is dropped
|
||||
* @param u The user dropping the nick
|
||||
* @param source The source of the command
|
||||
* @param na The nick
|
||||
*/
|
||||
virtual void OnNickDrop(User *u, NickAlias *na) { }
|
||||
virtual void OnNickDrop(CommandSource &source, NickAlias *na) { }
|
||||
|
||||
/** Called when a nick is forbidden
|
||||
* @param na The nick alias of the forbidden nick
|
||||
@@ -764,18 +768,6 @@ class CoreExport Module : public Extensible
|
||||
*/
|
||||
virtual void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool ShowHidden) { }
|
||||
|
||||
/** Called in findnick()
|
||||
* Useful to modify the na returned by findnick()
|
||||
* @param nick The nick being looked up
|
||||
*/
|
||||
virtual void OnFindNick(const Anope::string &nick) { }
|
||||
|
||||
/** Called in findcore()
|
||||
* Useful to modify the nc returned by findcore()
|
||||
* @param nick The nick being looked up
|
||||
*/
|
||||
virtual void OnFindCore(const Anope::string &nick) { }
|
||||
|
||||
/** Check whether a users password is correct.
|
||||
* @param u The user
|
||||
* @param command The command the user is doing
|
||||
@@ -824,33 +816,33 @@ class CoreExport Module : public Extensible
|
||||
* @param nc The nickcore of the memo being deleted
|
||||
* @param mi The memo info
|
||||
* @param m The memo
|
||||
* @param number What memo number is being deleted, can be 0 for all memos
|
||||
*/
|
||||
virtual void OnMemoDel(const NickCore *nc, MemoInfo *mi, Memo *m) { }
|
||||
virtual void OnMemoDel(NickCore *nc, MemoInfo *mi, const Memo *m) { }
|
||||
|
||||
/** Called when a memo is deleted
|
||||
* @param ci The channel of the memo being deleted
|
||||
* @param mi The memo info
|
||||
* @param m The memo
|
||||
* @param number What memo number is being deleted, can be 0 for all memos
|
||||
*/
|
||||
virtual void OnMemoDel(ChannelInfo *ci, MemoInfo *mi, Memo *m) { }
|
||||
virtual void OnMemoDel(ChannelInfo *ci, MemoInfo *mi, const Memo *m) { }
|
||||
|
||||
/** Called when a mode is set on a channel
|
||||
* @param c The channel
|
||||
* @param setter The user who is setting the mode
|
||||
* @param Name The mode name
|
||||
* @param param The mode param, if there is one
|
||||
* @return EVENT_STOP to make mlock/secureops etc checks not happen
|
||||
*/
|
||||
virtual EventReturn OnChannelModeSet(Channel *c, ChannelModeName Name, const Anope::string ¶m) { return EVENT_CONTINUE; }
|
||||
virtual EventReturn OnChannelModeSet(Channel *c, User *setter, ChannelModeName Name, const Anope::string ¶m) { return EVENT_CONTINUE; }
|
||||
|
||||
/** Called when a mode is unset on a channel
|
||||
* @param c The channel
|
||||
* @param setter the user who is unsetting the mode
|
||||
* @param Name The mode name
|
||||
* @param param The mode param, if there is one
|
||||
* @return EVENT_STOP to make mlock/secureops etc checks not happen
|
||||
*/
|
||||
virtual EventReturn OnChannelModeUnset(Channel *c, ChannelModeName Name, const Anope::string ¶m) { return EVENT_CONTINUE; }
|
||||
virtual EventReturn OnChannelModeUnset(Channel *c, User *setter, ChannelModeName Name, const Anope::string ¶m) { return EVENT_CONTINUE; }
|
||||
|
||||
/** Called when a mode is set on a user
|
||||
* @param u The user
|
||||
@@ -929,6 +921,19 @@ class CoreExport Module : public Extensible
|
||||
* @param l The log message
|
||||
*/
|
||||
virtual void OnLog(Log *l) { }
|
||||
|
||||
/** Called when a channels modes are being checked to see if they are allowed,
|
||||
* mostly to ensure mlock/+r are set.
|
||||
* @param c The channel
|
||||
* @return EVENT_STOP to stop checking modes
|
||||
*/
|
||||
virtual EventReturn OnCheckModes(Channel *c) { return EVENT_CONTINUE; }
|
||||
|
||||
virtual void OnSerializeCheck(SerializeType *) { }
|
||||
virtual void OnSerializableConstruct(Serializable *) { }
|
||||
virtual void OnSerializableDestruct(Serializable *) { }
|
||||
virtual void OnSerializePtrAssign(Serializable *) { }
|
||||
virtual void OnSerializableUpdate(Serializable *) { }
|
||||
};
|
||||
|
||||
/** Implementation-specific flags which may be set in ModuleManager::Attach()
|
||||
@@ -942,18 +947,18 @@ enum Implementation
|
||||
I_OnDelNick, I_OnDelCore, I_OnChangeCoreDisplay,
|
||||
I_OnNickClearAccess, I_OnNickAddAccess, I_OnNickEraseAccess,
|
||||
I_OnNickClearCert, I_OnNickAddCert, I_OnNickEraseCert,
|
||||
I_OnNickInfo, I_OnFindNick, I_OnFindCore, I_OnCheckAuthentication,
|
||||
I_OnNickInfo, I_OnCheckAuthentication,
|
||||
I_OnNickUpdate,
|
||||
|
||||
/* ChanServ */
|
||||
I_OnChanSuspend, I_OnChanDrop, I_OnPreChanExpire, I_OnChanExpire, I_OnAccessAdd,
|
||||
I_OnAccessDel, I_OnAccessClear, I_OnLevelChange, I_OnChanRegistered, I_OnChanUnsuspend, I_OnCreateChan, I_OnDelChan, I_OnChannelCreate,
|
||||
I_OnChannelDelete, I_OnAkickAdd, I_OnAkickDel, I_OnCheckKick,
|
||||
I_OnChanInfo, I_OnFindChan, I_OnCheckPriv, I_OnGroupCheckPriv,
|
||||
I_OnChannelDelete, I_OnAkickAdd, I_OnAkickDel, I_OnCheckKick, I_OnCheckModes,
|
||||
I_OnChanInfo, I_OnCheckPriv, I_OnGroupCheckPriv,
|
||||
|
||||
/* BotServ */
|
||||
I_OnBotJoin, I_OnBotKick, I_OnBotCreate, I_OnBotChange, I_OnBotDelete, I_OnBotAssign, I_OnBotUnAssign,
|
||||
I_OnUserKicked, I_OnBotFantasy, I_OnBotNoFantasyAccess, I_OnBotBan, I_OnBadWordAdd, I_OnBadWordDel, I_OnFindBot,
|
||||
I_OnUserKicked, I_OnBotFantasy, I_OnBotNoFantasyAccess, I_OnBotBan, I_OnBadWordAdd, I_OnBadWordDel,
|
||||
|
||||
/* HostServ */
|
||||
I_OnSetVhost, I_OnDeleteVhost,
|
||||
@@ -982,6 +987,8 @@ enum Implementation
|
||||
I_OnEncrypt, I_OnDecrypt,
|
||||
I_OnChannelModeSet, I_OnChannelModeUnset, I_OnUserModeSet, I_OnUserModeUnset, I_OnChannelModeAdd, I_OnUserModeAdd,
|
||||
I_OnMLock, I_OnUnMLock, I_OnServerSync, I_OnUplinkSync, I_OnBotPrivmsg, I_OnPrivmsg, I_OnLog,
|
||||
|
||||
I_OnSerializeCheck, I_OnSerializableConstruct, I_OnSerializableDestruct, I_OnSerializePtrAssign, I_OnSerializableUpdate,
|
||||
I_END
|
||||
};
|
||||
|
||||
@@ -1030,9 +1037,8 @@ class CoreExport ModuleManager
|
||||
* @param major The major version
|
||||
* @param minor The minor vesion
|
||||
* @param patch The patch version
|
||||
* @param build The build version
|
||||
*/
|
||||
static void RequireVersion(int major, int minor, int patch, int build);
|
||||
static void RequireVersion(int major, int minor, int patch);
|
||||
|
||||
/** Change the priority of one event in a module.
|
||||
* Each module event has a list of modules which are attached to that event type. If you wish to be called before or after other specific modules, you may use this
|
||||
@@ -1105,55 +1111,14 @@ class CoreExport ModuleManager
|
||||
|
||||
/** Class used for callbacks within modules
|
||||
*/
|
||||
class CallBack : public Timer
|
||||
class CoreExport CallBack : public Timer
|
||||
{
|
||||
private:
|
||||
Module *m;
|
||||
public:
|
||||
CallBack(Module *mod, long time_from_now, time_t now = Anope::CurTime, bool repeating = false) : Timer(time_from_now, now, repeating), m(mod)
|
||||
{
|
||||
m->CallBacks.push_back(this);
|
||||
}
|
||||
CallBack(Module *mod, long time_from_now, time_t now = Anope::CurTime, bool repeating = false);
|
||||
|
||||
virtual ~CallBack()
|
||||
{
|
||||
std::list<CallBack *>::iterator it = std::find(m->CallBacks.begin(), m->CallBacks.end(), this);
|
||||
if (it != m->CallBacks.end())
|
||||
m->CallBacks.erase(it);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class service_reference : public dynamic_reference<T>
|
||||
{
|
||||
Anope::string type;
|
||||
Anope::string name;
|
||||
|
||||
public:
|
||||
service_reference(const Anope::string &t, const Anope::string &n) : dynamic_reference<T>(NULL), type(t), name(n)
|
||||
{
|
||||
}
|
||||
|
||||
inline void operator=(const Anope::string &n)
|
||||
{
|
||||
this->name = n;
|
||||
}
|
||||
|
||||
operator bool()
|
||||
{
|
||||
if (this->invalid)
|
||||
{
|
||||
this->invalid = false;
|
||||
this->ref = NULL;
|
||||
}
|
||||
if (!this->ref)
|
||||
{
|
||||
this->ref = static_cast<T *>(Service::FindService(this->type, this->name));
|
||||
if (this->ref)
|
||||
this->ref->AddReference(this);
|
||||
}
|
||||
return this->ref;
|
||||
}
|
||||
virtual ~CallBack();
|
||||
};
|
||||
|
||||
class CoreExport Message
|
||||
|
||||
+35
-21
@@ -9,12 +9,15 @@
|
||||
#ifndef OPER_H
|
||||
#define OPER_H
|
||||
|
||||
class XLineManager;
|
||||
#include "serialize.h"
|
||||
#include "service.h"
|
||||
|
||||
class CoreExport XLine : public Serializable
|
||||
{
|
||||
void InitRegex();
|
||||
public:
|
||||
Anope::string Mask;
|
||||
Regex *regex;
|
||||
Anope::string By;
|
||||
time_t Created;
|
||||
time_t Expires;
|
||||
@@ -24,24 +27,31 @@ class CoreExport XLine : public Serializable
|
||||
|
||||
XLine(const Anope::string &mask, const Anope::string &reason = "", const Anope::string &uid = "");
|
||||
|
||||
XLine(const Anope::string &mask, const Anope::string &by, const time_t expires, const Anope::string &reason, const Anope::string &uid);
|
||||
XLine(const Anope::string &mask, const Anope::string &by, const time_t expires, const Anope::string &reason, const Anope::string &uid = "");
|
||||
~XLine();
|
||||
|
||||
Anope::string GetNick() const;
|
||||
Anope::string GetUser() const;
|
||||
Anope::string GetHost() const;
|
||||
sockaddrs GetIP() const;
|
||||
Anope::string GetReal() const;
|
||||
|
||||
Anope::string serialize_name() const;
|
||||
serialized_data serialize();
|
||||
static void unserialize(serialized_data &data);
|
||||
Anope::string GetReason() const;
|
||||
|
||||
bool HasNickOrReal() const;
|
||||
bool IsRegex() const;
|
||||
|
||||
const Anope::string serialize_name() const anope_override;
|
||||
Serialize::Data serialize() const anope_override;
|
||||
static Serializable* unserialize(Serializable *obj, Serialize::Data &data);
|
||||
};
|
||||
|
||||
class CoreExport XLineManager : public Service
|
||||
{
|
||||
char type;
|
||||
/* List of XLines in this XLineManager */
|
||||
std::vector<XLine *> XLines;
|
||||
static std::map<Anope::string, XLine *, ci::less> XLinesByUID;
|
||||
serialize_checker<std::vector<XLine *> > XLines;
|
||||
/* Akills can have the same IDs, sometimes */
|
||||
static serialize_checker<std::multimap<Anope::string, XLine *, ci::less> > XLinesByUID;
|
||||
public:
|
||||
/* List of XLine managers we check users against in XLineManager::CheckAll */
|
||||
static std::list<XLineManager *> XLineManagers;
|
||||
@@ -63,7 +73,7 @@ class CoreExport XLineManager : public Service
|
||||
* Wparam u The user
|
||||
* @return A pair of the XLineManager the user was found in and the XLine they matched, both may be NULL for no match
|
||||
*/
|
||||
static std::pair<XLineManager *, XLine *> CheckAll(User *u);
|
||||
static void CheckAll(User *u);
|
||||
|
||||
/** Generate a unique ID for this XLine
|
||||
* @return A unique ID
|
||||
@@ -108,7 +118,7 @@ class CoreExport XLineManager : public Service
|
||||
* @param index The index
|
||||
* @return The XLine, or NULL if the index is out of bounds
|
||||
*/
|
||||
XLine *GetEntry(unsigned index);
|
||||
XLine* GetEntry(unsigned index);
|
||||
|
||||
/** Clear the XLine vector
|
||||
* Note: This does not remove the XLines from the IRCd
|
||||
@@ -116,38 +126,42 @@ class CoreExport XLineManager : public Service
|
||||
void Clear();
|
||||
|
||||
/** Checks if a mask can/should be added to the XLineManager
|
||||
* @param source The source adding the mask.
|
||||
* @param mask The mask
|
||||
* @param expires When the mask would expire
|
||||
* @return A pair of int and XLine*.
|
||||
* 1 - Mask already exists
|
||||
* 2 - Mask already exists, but the expiry time was changed
|
||||
* 3 - Mask is already covered by another mask
|
||||
* In each case the XLine it matches/is covered by is returned in XLine*
|
||||
* @param reason the reason
|
||||
* @return true if the mask can be added
|
||||
*/
|
||||
std::pair<int, XLine *> CanAdd(const Anope::string &mask, time_t expires);
|
||||
bool CanAdd(CommandSource &source, const Anope::string &mask, time_t expires, const Anope::string &reason);
|
||||
|
||||
/** Checks if this list has an entry
|
||||
* @param mask The mask
|
||||
* @return The XLine the user matches, or NULL
|
||||
*/
|
||||
XLine *HasEntry(const Anope::string &mask);
|
||||
XLine* HasEntry(const Anope::string &mask);
|
||||
|
||||
/** Check a user against all of the xlines in this XLineManager
|
||||
* @param u The user
|
||||
* @return The xline the user marches, if any. Also calls OnMatch()
|
||||
* @return The xline the user marches, if any.
|
||||
*/
|
||||
virtual XLine *Check(User *u);
|
||||
XLine *CheckAllXLines(User *u);
|
||||
|
||||
/** Check a user against an xline
|
||||
* @param u The user
|
||||
* @param x The xline
|
||||
*/
|
||||
virtual bool Check(User *u, const XLine *x) = 0;
|
||||
|
||||
/** Called when a user matches a xline in this XLineManager
|
||||
* @param u The user
|
||||
* @param x The XLine they match
|
||||
*/
|
||||
virtual void OnMatch(User *u, XLine *x);
|
||||
virtual void OnMatch(User *u, XLine *x) = 0;
|
||||
|
||||
/** Called when an XLine expires
|
||||
* @param x The xline
|
||||
*/
|
||||
virtual void OnExpire(XLine *x);
|
||||
virtual void OnExpire(const XLine *x);
|
||||
|
||||
/** Called to send an XLine to the IRCd
|
||||
* @param u The user, if we know it
|
||||
|
||||
+2
-3
@@ -8,9 +8,8 @@
|
||||
#ifndef OPERTYPE_H
|
||||
#define OPERTYPE_H
|
||||
|
||||
#include "hashcomp.h"
|
||||
|
||||
class OperType;
|
||||
#include "services.h"
|
||||
#include "account.h"
|
||||
|
||||
struct CoreExport Oper
|
||||
{
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
*
|
||||
* (C) 2003-2012 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.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef PROTOCOL_H
|
||||
#define PROTOCOL_H
|
||||
|
||||
#include "services.h"
|
||||
#include "anope.h"
|
||||
|
||||
/* Protocol tweaks */
|
||||
|
||||
struct IRCDVar
|
||||
{
|
||||
const char *name; /* Name of the IRCd command */
|
||||
const char *pseudoclient_mode; /* Mode used by BotServ Bots */
|
||||
int svsnick; /* Supports SVSNICK */
|
||||
int vhost; /* Supports vhost */
|
||||
int snline; /* Supports SNline */
|
||||
int sqline; /* Supports SQline */
|
||||
int szline; /* Supports SZline */
|
||||
int join2msg; /* Join 2 Message */
|
||||
int chansqline; /* Supports Channel Sqlines */
|
||||
int quitonkill; /* IRCD sends QUIT when kill */
|
||||
int vident; /* Supports vidents */
|
||||
int svshold; /* Supports svshold */
|
||||
int tsonmode; /* Timestamp on mode changes */
|
||||
int omode; /* On the fly o:lines */
|
||||
int umode; /* change user modes */
|
||||
int knock_needs_i; /* Check if we needed +i when setting NOKNOCK */
|
||||
int svsmode_ucmode; /* Can remove User Channel Modes with SVSMODE */
|
||||
int sglineenforce;
|
||||
int ts6; /* ircd is TS6 */
|
||||
const char *globaltldprefix; /* TLD prefix used for Global */
|
||||
unsigned maxmodes; /* Max modes to send per line */
|
||||
int certfp; /* IRCd sends a SSL users certificate fingerprint */
|
||||
};
|
||||
|
||||
|
||||
class CoreExport IRCDProto
|
||||
{
|
||||
protected:
|
||||
virtual void SendSVSKillInternal(const BotInfo *, const User *, const Anope::string &);
|
||||
virtual void SendModeInternal(const BotInfo *, const Channel *, const Anope::string &);
|
||||
virtual void SendModeInternal(const BotInfo *, const User *, const Anope::string &) = 0;
|
||||
virtual void SendKickInternal(const BotInfo *, const Channel *, const User *, const Anope::string &);
|
||||
virtual void SendMessageInternal(const BotInfo *bi, const Anope::string &dest, const Anope::string &buf);
|
||||
virtual void SendNoticeInternal(const BotInfo *bi, const Anope::string &dest, const Anope::string &msg);
|
||||
virtual void SendPrivmsgInternal(const BotInfo *bi, const Anope::string &dest, const Anope::string &buf);
|
||||
virtual void SendQuitInternal(const User *u, const Anope::string &buf);
|
||||
virtual void SendPartInternal(const BotInfo *bi, const Channel *chan, const Anope::string &buf);
|
||||
virtual void SendGlobopsInternal(const BotInfo *source, const Anope::string &buf);
|
||||
virtual void SendCTCPInternal(const BotInfo *bi, const Anope::string &dest, const Anope::string &buf);
|
||||
virtual void SendNumericInternal(int numeric, const Anope::string &dest, const Anope::string &buf);
|
||||
public:
|
||||
virtual ~IRCDProto() { }
|
||||
|
||||
virtual void SendSVSNOOP(const Server *, bool) { }
|
||||
virtual void SendTopic(BotInfo *, Channel *);
|
||||
virtual void SendVhostDel(User *) { }
|
||||
virtual void SendAkill(User *, XLine *) = 0;
|
||||
virtual void SendAkillDel(const XLine *) = 0;
|
||||
virtual void SendSVSKill(const BotInfo *source, const User *user, const char *fmt, ...);
|
||||
virtual void SendMode(const BotInfo *bi, const Channel *dest, const char *fmt, ...);
|
||||
virtual void SendMode(const BotInfo *bi, const User *u, const char *fmt, ...);
|
||||
virtual void SendClientIntroduction(const User *u) = 0;
|
||||
virtual void SendKick(const BotInfo *bi, const Channel *chan, const User *user, const char *fmt, ...);
|
||||
virtual void SendMessage(const BotInfo *bi, const Anope::string &dest, const char *fmt, ...);
|
||||
virtual void SendNotice(const BotInfo *bi, const Anope::string &dest, const char *fmt, ...);
|
||||
virtual void SendAction(const BotInfo *bi, const Anope::string &dest, const char *fmt, ...);
|
||||
virtual void SendPrivmsg(const BotInfo *bi, const Anope::string &dest, const char *fmt, ...);
|
||||
virtual void SendGlobalNotice(const BotInfo *bi, const Server *dest, const Anope::string &msg);
|
||||
virtual void SendGlobalPrivmsg(const BotInfo *bi, const Server *desc, const Anope::string &msg);
|
||||
|
||||
virtual void SendQuit(const User *u, const char *fmt, ...);
|
||||
virtual void SendPing(const Anope::string &servname, const Anope::string &who);
|
||||
virtual void SendPong(const Anope::string &servname, const Anope::string &who);
|
||||
virtual void SendJoin(const User *, Channel *, const ChannelStatus *) = 0;
|
||||
virtual void SendSQLineDel(const XLine *x) { }
|
||||
virtual void SendInvite(const BotInfo *bi, const Channel *c, const User *u);
|
||||
virtual void SendPart(const BotInfo *bi, const Channel *chan, const char *fmt, ...);
|
||||
virtual void SendGlobops(const BotInfo *source, const char *fmt, ...);
|
||||
virtual void SendSQLine(User *, const XLine *x) { }
|
||||
virtual void SendSquit(Server *, const Anope::string &message);
|
||||
virtual void SendSVSO(const BotInfo *, const Anope::string &, const Anope::string &) { }
|
||||
virtual void SendChangeBotNick(const BotInfo *bi, const Anope::string &newnick);
|
||||
virtual void SendForceNickChange(const User *u, const Anope::string &newnick, time_t when);
|
||||
virtual void SendVhost(User *, const Anope::string &, const Anope::string &) { }
|
||||
virtual void SendConnect() = 0;
|
||||
virtual void SendSVSHold(const Anope::string &) { }
|
||||
virtual void SendSVSHoldDel(const Anope::string &) { }
|
||||
virtual void SendSGLineDel(const XLine *) { }
|
||||
virtual void SendSZLineDel(const XLine *) { }
|
||||
virtual void SendSZLine(User *u, const XLine *) { }
|
||||
virtual void SendSGLine(User *, const XLine *) { }
|
||||
virtual void SendCTCP(const BotInfo *bi, const Anope::string &dest, const char *fmt, ...);
|
||||
virtual void SendSVSJoin(const BotInfo *bi, const Anope::string &, const Anope::string &, const Anope::string &) { }
|
||||
virtual void SendSWhois(const BotInfo *bi, const Anope::string &, const Anope::string &) { }
|
||||
virtual void SendBOB() { }
|
||||
virtual void SendEOB() { }
|
||||
virtual void SendServer(const Server *) = 0;
|
||||
virtual bool IsNickValid(const Anope::string &) { return true; }
|
||||
virtual bool IsChannelValid(const Anope::string &);
|
||||
virtual void SendNumeric(int numeric, const Anope::string &dest, const char *fmt, ...);
|
||||
virtual void SendLogin(User *u) = 0;
|
||||
virtual void SendLogout(User *u) = 0;
|
||||
|
||||
/** Send a channel creation message to the uplink.
|
||||
* On most TS6 IRCds this is a SJOIN with no nick
|
||||
*/
|
||||
virtual void SendChannel(Channel *c) { }
|
||||
};
|
||||
|
||||
class CoreExport IRCdMessage
|
||||
{
|
||||
public:
|
||||
virtual bool On436(const Anope::string &, const std::vector<Anope::string> &);
|
||||
virtual bool OnAway(const Anope::string &, const std::vector<Anope::string> &);
|
||||
virtual bool OnJoin(const Anope::string &, const std::vector<Anope::string> &);
|
||||
virtual bool OnKick(const Anope::string &, const std::vector<Anope::string> &);
|
||||
virtual bool OnKill(const Anope::string &, const std::vector<Anope::string> &);
|
||||
virtual bool OnMode(const Anope::string &, const std::vector<Anope::string> &) = 0;
|
||||
virtual bool OnUID(const Anope::string &, const std::vector<Anope::string> &);
|
||||
virtual bool OnNick(const Anope::string &, const std::vector<Anope::string> &) = 0;
|
||||
virtual bool OnPart(const Anope::string &, const std::vector<Anope::string> &);
|
||||
virtual bool OnPing(const Anope::string &, const std::vector<Anope::string> &);
|
||||
virtual bool OnPrivmsg(const Anope::string &, const std::vector<Anope::string> &);
|
||||
virtual bool OnQuit(const Anope::string &, const std::vector<Anope::string> &);
|
||||
virtual bool OnServer(const Anope::string &, const std::vector<Anope::string> &) = 0;
|
||||
virtual bool OnSQuit(const Anope::string &, const std::vector<Anope::string> &);
|
||||
virtual bool OnTopic(const Anope::string &, const std::vector<Anope::string> &) = 0;
|
||||
virtual bool OnWhois(const Anope::string &, const std::vector<Anope::string> &);
|
||||
virtual bool OnCapab(const Anope::string &, const std::vector<Anope::string> &);
|
||||
virtual bool OnSJoin(const Anope::string &, const std::vector<Anope::string> &) = 0;
|
||||
virtual bool OnError(const Anope::string &, const std::vector<Anope::string> &);
|
||||
};
|
||||
|
||||
extern CoreExport IRCDVar *ircd;
|
||||
extern CoreExport IRCDProto *ircdproto;
|
||||
extern CoreExport IRCdMessage *ircdmessage;
|
||||
|
||||
extern CoreExport void pmodule_ircd_proto(IRCDProto *);
|
||||
extern CoreExport void pmodule_ircd_var(IRCDVar *ircdvar);
|
||||
extern CoreExport void pmodule_ircd_message(IRCdMessage *message);
|
||||
|
||||
#endif // PROTOCOL_H
|
||||
+62
-65
@@ -9,8 +9,18 @@
|
||||
#ifndef REGCHANNEL_H
|
||||
#define REGCHANNEL_H
|
||||
|
||||
#include "botserv.h"
|
||||
#include "memo.h"
|
||||
#include "modes.h"
|
||||
#include "extensible.h"
|
||||
#include "logger.h"
|
||||
#include "modules.h"
|
||||
#include "serialize.h"
|
||||
#include "bots.h"
|
||||
|
||||
typedef Anope::insensitive_map<ChannelInfo *> registered_channel_map;
|
||||
extern CoreExport registered_channel_map RegisteredChannelList;
|
||||
|
||||
extern CoreExport serialize_checker<registered_channel_map> RegisteredChannelList;
|
||||
|
||||
/** Flags used for the ChannelInfo class
|
||||
*/
|
||||
@@ -50,6 +60,8 @@ enum ChannelInfoFlag
|
||||
* is set or not
|
||||
*/
|
||||
CI_PERSIST,
|
||||
/* Chanstats are enabled */
|
||||
CI_STATS,
|
||||
|
||||
CI_END
|
||||
};
|
||||
@@ -57,7 +69,7 @@ enum ChannelInfoFlag
|
||||
const Anope::string ChannelInfoFlagStrings[] = {
|
||||
"BEGIN", "KEEPTOPIC", "SECUREOPS", "PRIVATE", "TOPICLOCK", "RESTRICTED",
|
||||
"PEACE", "SECURE", "NO_EXPIRE", "MEMO_HARDMAX", "SECUREFOUNDER",
|
||||
"SIGNKICK", "SIGNKICK_LEVEL", "SUSPENDED", "PERSIST", ""
|
||||
"SIGNKICK", "SIGNKICK_LEVEL", "SUSPENDED", "PERSIST", "STATS", ""
|
||||
};
|
||||
|
||||
/** Flags for badwords
|
||||
@@ -81,9 +93,9 @@ struct CoreExport BadWord : Serializable
|
||||
Anope::string word;
|
||||
BadWordType type;
|
||||
|
||||
Anope::string serialize_name() const;
|
||||
serialized_data serialize();
|
||||
static void unserialize(serialized_data &);
|
||||
const Anope::string serialize_name() const anope_override;
|
||||
Serialize::Data serialize() const anope_override;
|
||||
static Serializable* unserialize(Serializable *obj, Serialize::Data &);
|
||||
};
|
||||
|
||||
/** Flags for auto kick
|
||||
@@ -101,25 +113,25 @@ class CoreExport AutoKick : public Flags<AutoKickFlag>, public Serializable
|
||||
{
|
||||
public:
|
||||
AutoKick();
|
||||
ChannelInfo *ci;
|
||||
serialize_obj<ChannelInfo> ci;
|
||||
/* Only one of these can be in use */
|
||||
Anope::string mask;
|
||||
NickCore *nc;
|
||||
serialize_obj<NickCore> nc;
|
||||
|
||||
Anope::string reason;
|
||||
Anope::string creator;
|
||||
time_t addtime;
|
||||
time_t last_used;
|
||||
|
||||
Anope::string serialize_name() const;
|
||||
serialized_data serialize();
|
||||
static void unserialize(serialized_data &);
|
||||
const Anope::string serialize_name() const anope_override;
|
||||
Serialize::Data serialize() const anope_override;
|
||||
static Serializable* unserialize(Serializable *obj, Serialize::Data &);
|
||||
};
|
||||
|
||||
struct CoreExport ModeLock : Serializable
|
||||
{
|
||||
public:
|
||||
ChannelInfo *ci;
|
||||
serialize_obj<ChannelInfo> ci;
|
||||
bool set;
|
||||
ChannelModeName name;
|
||||
Anope::string param;
|
||||
@@ -128,14 +140,14 @@ struct CoreExport ModeLock : Serializable
|
||||
|
||||
ModeLock(ChannelInfo *ch, bool s, ChannelModeName n, const Anope::string &p, const Anope::string &se = "", time_t c = Anope::CurTime);
|
||||
|
||||
Anope::string serialize_name() const;
|
||||
serialized_data serialize();
|
||||
static void unserialize(serialized_data &);
|
||||
const Anope::string serialize_name() const anope_override;
|
||||
Serialize::Data serialize() const anope_override;
|
||||
static Serializable* unserialize(Serializable *obj, Serialize::Data &);
|
||||
};
|
||||
|
||||
struct CoreExport LogSetting : Serializable
|
||||
{
|
||||
ChannelInfo *ci;
|
||||
serialize_obj<ChannelInfo> ci;
|
||||
/* Our service name of the command */
|
||||
Anope::string service_name;
|
||||
/* The name of the client the command is on */
|
||||
@@ -146,24 +158,24 @@ struct CoreExport LogSetting : Serializable
|
||||
Anope::string creator;
|
||||
time_t created;
|
||||
|
||||
Anope::string serialize_name() const;
|
||||
serialized_data serialize();
|
||||
static void unserialize(serialized_data &);
|
||||
const Anope::string serialize_name() const anope_override;
|
||||
Serialize::Data serialize() const anope_override;
|
||||
static Serializable* unserialize(Serializable *obj, Serialize::Data &);
|
||||
};
|
||||
|
||||
class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag, CI_END>, public Serializable
|
||||
{
|
||||
private:
|
||||
NickCore *founder; /* Channel founder */
|
||||
std::vector<ChanAccess *> access; /* List of authorized users */
|
||||
std::vector<AutoKick *> akick; /* List of users to kickban */
|
||||
std::vector<BadWord *> badwords; /* List of badwords */
|
||||
serialize_obj<NickCore> founder; /* Channel founder */
|
||||
serialize_checker<std::vector<ChanAccess *> > access; /* List of authorized users */
|
||||
serialize_checker<std::vector<AutoKick *> > akick; /* List of users to kickban */
|
||||
serialize_checker<std::vector<BadWord *> > badwords; /* List of badwords */
|
||||
std::map<Anope::string, int16_t> levels;
|
||||
|
||||
public:
|
||||
typedef std::multimap<ChannelModeName, ModeLock> ModeList;
|
||||
ModeList mode_locks;
|
||||
std::vector<LogSetting> log_settings;
|
||||
typedef std::multimap<ChannelModeName, ModeLock *> ModeList;
|
||||
serialize_checker<ModeList> mode_locks;
|
||||
serialize_checker<std::vector<LogSetting *> > log_settings;
|
||||
|
||||
/** Default constructor
|
||||
* @param chname The channel name
|
||||
@@ -173,14 +185,14 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag,
|
||||
/** Copy constructor
|
||||
* @param ci The ChannelInfo to copy settings to
|
||||
*/
|
||||
ChannelInfo(ChannelInfo &ci);
|
||||
ChannelInfo(const ChannelInfo &ci);
|
||||
|
||||
/** Default destructor
|
||||
*/
|
||||
~ChannelInfo();
|
||||
|
||||
Anope::string name; /* Channel name */
|
||||
NickCore *successor; /* Who gets the channel if the founder nick is dropped or expires */
|
||||
serialize_obj<NickCore> successor; /* Who gets the channel if the founder nick is dropped or expires */
|
||||
Anope::string desc;
|
||||
|
||||
time_t time_registered;
|
||||
@@ -197,7 +209,7 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag,
|
||||
Channel *c; /* Pointer to channel record (if channel is currently in use) */
|
||||
|
||||
/* For BotServ */
|
||||
BotInfo *bi; /* Bot used on this channel */
|
||||
serialize_obj<BotInfo> bi; /* Bot used on this channel */
|
||||
Flags<BotServFlag> botflags;
|
||||
int16_t ttb[TTB_SIZE]; /* Times to ban for each kicker */
|
||||
|
||||
@@ -205,9 +217,9 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag,
|
||||
int16_t floodlines, floodsecs; /* For FLOOD kicker */
|
||||
int16_t repeattimes; /* For REPEAT kicker */
|
||||
|
||||
Anope::string serialize_name() const;
|
||||
serialized_data serialize();
|
||||
static void unserialize(serialized_data &);
|
||||
const Anope::string serialize_name() const anope_override;
|
||||
Serialize::Data serialize() const anope_override;
|
||||
static Serializable* unserialize(Serializable *obj, Serialize::Data &);
|
||||
|
||||
/** Change the founder of the channek
|
||||
* @params nc The new founder
|
||||
@@ -222,7 +234,7 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag,
|
||||
/** Find which bot should send mode/topic/etc changes for this channel
|
||||
* @return The bot
|
||||
*/
|
||||
BotInfo *WhoSends();
|
||||
BotInfo *WhoSends() const;
|
||||
|
||||
/** Add an entry to the channel access list
|
||||
* @param access The entry
|
||||
@@ -236,13 +248,13 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag,
|
||||
*
|
||||
* Retrieves an entry from the access list that matches the given index.
|
||||
*/
|
||||
ChanAccess *GetAccess(unsigned index);
|
||||
ChanAccess *GetAccess(unsigned index) const;
|
||||
|
||||
/** Retrieve the access for a user or group in the form of a vector of access entries
|
||||
* (as multiple entries can affect a single user).
|
||||
*/
|
||||
AccessGroup AccessFor(User *u);
|
||||
AccessGroup AccessFor(NickCore *nc);
|
||||
AccessGroup AccessFor(const User *u);
|
||||
AccessGroup AccessFor(const NickCore *nc);
|
||||
|
||||
/** Get the size of the accss vector for this channel
|
||||
* @return The access vector size
|
||||
@@ -263,7 +275,7 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag,
|
||||
*
|
||||
* Clears the memory used by the given access entry and removes it from the vector.
|
||||
*/
|
||||
void EraseAccess(ChanAccess *taccess);
|
||||
void EraseAccess(const ChanAccess *taccess);
|
||||
|
||||
/** Clear the entire channel access list
|
||||
*
|
||||
@@ -278,7 +290,7 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag,
|
||||
* @param t The time the akick was added, defaults to now
|
||||
* @param lu The time the akick was last used, defaults to never
|
||||
*/
|
||||
AutoKick *AddAkick(const Anope::string &user, NickCore *akicknc, const Anope::string &reason, time_t t = Anope::CurTime, time_t lu = 0);
|
||||
AutoKick* AddAkick(const Anope::string &user, NickCore *akicknc, const Anope::string &reason, time_t t = Anope::CurTime, time_t lu = 0);
|
||||
|
||||
/** Add an akick entry to the channel by reason
|
||||
* @param user The user who added the akick
|
||||
@@ -287,13 +299,13 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag,
|
||||
* @param t The time the akick was added, defaults to now
|
||||
* @param lu The time the akick was last used, defaults to never
|
||||
*/
|
||||
AutoKick *AddAkick(const Anope::string &user, const Anope::string &mask, const Anope::string &reason, time_t t = Anope::CurTime, time_t lu = 0);
|
||||
AutoKick* AddAkick(const Anope::string &user, const Anope::string &mask, const Anope::string &reason, time_t t = Anope::CurTime, time_t lu = 0);
|
||||
|
||||
/** Get an entry from the channel akick list
|
||||
* @param index The index in the akick vector
|
||||
* @return The akick structure, or NULL if not found
|
||||
*/
|
||||
AutoKick *GetAkick(unsigned index);
|
||||
AutoKick* GetAkick(unsigned index) const;
|
||||
|
||||
/** Get the size of the akick vector for this channel
|
||||
* @return The akick vector size
|
||||
@@ -314,13 +326,13 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag,
|
||||
* @param type The type (SINGLE START END)
|
||||
* @return The badword
|
||||
*/
|
||||
BadWord *AddBadWord(const Anope::string &word, BadWordType type);
|
||||
BadWord* AddBadWord(const Anope::string &word, BadWordType type);
|
||||
|
||||
/** Get a badword structure by index
|
||||
* @param index The index
|
||||
* @return The badword
|
||||
*/
|
||||
BadWord *GetBadWord(unsigned index);
|
||||
BadWord* GetBadWord(unsigned index) const;
|
||||
|
||||
/** Get how many badwords are on this channel
|
||||
* @return The number of badwords in the vector
|
||||
@@ -356,10 +368,11 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag,
|
||||
|
||||
/** Remove a mlock
|
||||
* @param mode The mode
|
||||
* @param status True for mlock on, false for mlock off
|
||||
* @param param The param of the mode, required if it is a list or status mode
|
||||
* @return true on success, false on failure
|
||||
*/
|
||||
bool RemoveMLock(ChannelMode *mode, const Anope::string ¶m = "");
|
||||
bool RemoveMLock(ChannelMode *mode, bool status, const Anope::string ¶m = "");
|
||||
|
||||
/** Clear all mlocks on the channel
|
||||
*/
|
||||
@@ -368,7 +381,7 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag,
|
||||
/** Get all of the mlocks for this channel
|
||||
* @return The mlocks
|
||||
*/
|
||||
const std::multimap<ChannelModeName, ModeLock> &GetMLock() const;
|
||||
const ModeList &GetMLock() const;
|
||||
|
||||
/** Get a list of modes on a channel
|
||||
* @param Name The mode name to get a list of
|
||||
@@ -381,7 +394,7 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag,
|
||||
* @param An optional param to match with
|
||||
* @return The MLock, if any
|
||||
*/
|
||||
ModeLock *GetMLock(ChannelModeName mname, const Anope::string ¶m = "");
|
||||
const ModeLock *GetMLock(ChannelModeName mname, const Anope::string ¶m = "");
|
||||
|
||||
/** Get the current mode locks as a string
|
||||
* @param complete True to show mlock parameters aswell
|
||||
@@ -411,7 +424,7 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag,
|
||||
* @return the level
|
||||
* @throws CoreException if priv is not a valid privilege
|
||||
*/
|
||||
int16_t GetLevel(const Anope::string &priv);
|
||||
int16_t GetLevel(const Anope::string &priv) const;
|
||||
|
||||
/** Set the level for a privilege
|
||||
* @param priv The privilege priv
|
||||
@@ -429,25 +442,9 @@ class CoreExport ChannelInfo : public Extensible, public Flags<ChannelInfoFlag,
|
||||
void ClearLevels();
|
||||
};
|
||||
|
||||
/** A timer used to keep the BotServ bot/ChanServ in the channel
|
||||
* after kicking the last user in a channel
|
||||
*/
|
||||
class CoreExport ChanServTimer : public Timer
|
||||
{
|
||||
private:
|
||||
dynamic_reference<Channel> c;
|
||||
|
||||
public:
|
||||
/** Default constructor
|
||||
* @param chan The channel
|
||||
*/
|
||||
ChanServTimer(Channel *chan);
|
||||
|
||||
/** Called when the delay is up
|
||||
* @param The current time
|
||||
*/
|
||||
void Tick(time_t);
|
||||
};
|
||||
|
||||
extern CoreExport ChannelInfo *cs_findchan(const Anope::string &chan);
|
||||
extern CoreExport bool IsFounder(const User *user, const ChannelInfo *ci);
|
||||
extern CoreExport void update_cs_lastseen(User *user, ChannelInfo *ci);
|
||||
extern CoreExport int get_idealban(const ChannelInfo *ci, User *u, Anope::string &ret);
|
||||
|
||||
#endif // REGCHANNEL_H
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
*
|
||||
* (C) 2003-2012 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef REGEXPR_H
|
||||
#define REGEXPR_H
|
||||
|
||||
#include "services.h"
|
||||
#include "anope.h"
|
||||
#include "service.h"
|
||||
|
||||
class RegexException : public CoreException
|
||||
{
|
||||
public:
|
||||
RegexException(const Anope::string &reason = "") : CoreException(reason) { }
|
||||
|
||||
virtual ~RegexException() throw() { }
|
||||
};
|
||||
|
||||
class CoreExport Regex
|
||||
{
|
||||
Anope::string expression;
|
||||
protected:
|
||||
Regex(const Anope::string &expr) : expression(expr) { }
|
||||
public:
|
||||
virtual ~Regex() { }
|
||||
const Anope::string &GetExpression() { return expression; }
|
||||
virtual bool Matches(const Anope::string &str) = 0;
|
||||
};
|
||||
|
||||
class CoreExport RegexProvider : public Service
|
||||
{
|
||||
public:
|
||||
RegexProvider(Module *o, const Anope::string &n) : Service(o, "Regex", n) { }
|
||||
virtual Regex *Compile(const Anope::string &) = 0;
|
||||
};
|
||||
|
||||
#endif // REGEXPR_H
|
||||
|
||||
+219
-97
@@ -1,6 +1,23 @@
|
||||
/*
|
||||
*
|
||||
* (C) 2003-2012 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SERIALIZE_H
|
||||
#define SERIALIZE_H
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "anope.h"
|
||||
#include "base.h"
|
||||
|
||||
namespace Serialize
|
||||
{
|
||||
enum DataType
|
||||
@@ -8,151 +25,256 @@ namespace Serialize
|
||||
DT_TEXT,
|
||||
DT_INT
|
||||
};
|
||||
}
|
||||
|
||||
class stringstream : public std::stringstream
|
||||
class CoreExport stringstream : public std::stringstream
|
||||
{
|
||||
private:
|
||||
Serialize::DataType type;
|
||||
unsigned _max;
|
||||
|
||||
public:
|
||||
stringstream();
|
||||
stringstream(const stringstream &ss);
|
||||
Anope::string astr() const;
|
||||
|
||||
template<typename T> std::istream &operator>>(T &val)
|
||||
{
|
||||
private:
|
||||
DataType type;
|
||||
bool key;
|
||||
unsigned _max;
|
||||
std::istringstream is(this->str());
|
||||
is >> val;
|
||||
return *this;
|
||||
}
|
||||
std::istream &operator>>(Anope::string &val);
|
||||
|
||||
public:
|
||||
stringstream() : std::stringstream(), type(DT_TEXT), key(false), _max(0) { }
|
||||
stringstream(const stringstream &ss) : std::stringstream(ss.str()), type(DT_TEXT), key(false), _max(0) { }
|
||||
Anope::string astr() const { return this->str(); }
|
||||
template<typename T> std::istream &operator>>(T &val)
|
||||
{
|
||||
std::istringstream is(this->str());
|
||||
is >> val;
|
||||
return *this;
|
||||
}
|
||||
std::istream &operator>>(Anope::string &val)
|
||||
{
|
||||
val = this->str();
|
||||
return *this;
|
||||
}
|
||||
stringstream &setType(DataType t)
|
||||
{
|
||||
this->type = t;
|
||||
return *this;
|
||||
}
|
||||
DataType getType() const
|
||||
{
|
||||
return this->type;
|
||||
}
|
||||
stringstream &setKey()
|
||||
{
|
||||
this->key = true;
|
||||
return *this;
|
||||
}
|
||||
bool getKey() const
|
||||
{
|
||||
return this->key;
|
||||
}
|
||||
stringstream &setMax(unsigned m)
|
||||
{
|
||||
this->_max = m;
|
||||
return *this;
|
||||
}
|
||||
unsigned getMax() const
|
||||
{
|
||||
return this->_max;
|
||||
}
|
||||
};
|
||||
bool operator==(const stringstream &other) const;
|
||||
bool operator!=(const stringstream &other) const;
|
||||
|
||||
stringstream &setType(Serialize::DataType t);
|
||||
Serialize::DataType getType() const;
|
||||
stringstream &setMax(unsigned m);
|
||||
unsigned getMax() const;
|
||||
};
|
||||
|
||||
namespace Serialize
|
||||
{
|
||||
typedef std::map<Anope::string, stringstream> Data;
|
||||
}
|
||||
|
||||
extern void RegisterTypes();
|
||||
|
||||
class CoreExport Serializable
|
||||
class CoreExport Serializable : public virtual Base
|
||||
{
|
||||
private:
|
||||
static std::list<Serializable *> *serizliable_items;
|
||||
static std::list<Serializable *> *serializable_items;
|
||||
|
||||
private:
|
||||
std::list<Serializable *>::iterator s_iter;
|
||||
Serialize::Data last_commit;
|
||||
time_t last_commit_time;
|
||||
|
||||
protected:
|
||||
Serializable()
|
||||
{
|
||||
if (serizliable_items == NULL)
|
||||
serizliable_items = new std::list<Serializable *>();
|
||||
serizliable_items->push_front(this);
|
||||
this->s_iter = serizliable_items->begin();
|
||||
}
|
||||
Serializable();
|
||||
Serializable(const Serializable &);
|
||||
|
||||
Serializable(const Serializable &)
|
||||
{
|
||||
serizliable_items->push_front(this);
|
||||
this->s_iter = serizliable_items->begin();
|
||||
}
|
||||
virtual ~Serializable();
|
||||
|
||||
virtual ~Serializable()
|
||||
{
|
||||
serizliable_items->erase(this->s_iter);
|
||||
}
|
||||
|
||||
Serializable &operator=(const Serializable &)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
Serializable &operator=(const Serializable &);
|
||||
|
||||
public:
|
||||
typedef std::map<Anope::string, Serialize::stringstream> serialized_data;
|
||||
unsigned int id;
|
||||
|
||||
virtual Anope::string serialize_name() const = 0;
|
||||
virtual serialized_data serialize() = 0;
|
||||
void destroy();
|
||||
|
||||
static const std::list<Serializable *> &GetItems()
|
||||
{
|
||||
return *serizliable_items;
|
||||
}
|
||||
void QueueUpdate();
|
||||
|
||||
bool IsCached();
|
||||
void UpdateCache();
|
||||
|
||||
bool IsTSCached();
|
||||
void UpdateTS();
|
||||
|
||||
virtual const Anope::string serialize_name() const = 0;
|
||||
virtual Serialize::Data serialize() const = 0;
|
||||
|
||||
static const std::list<Serializable *> &GetItems();
|
||||
};
|
||||
|
||||
class CoreExport SerializeType
|
||||
{
|
||||
typedef void (*unserialize_func)(Serializable::serialized_data &);
|
||||
typedef Serializable* (*unserialize_func)(Serializable *obj, Serialize::Data &);
|
||||
|
||||
static std::vector<Anope::string> type_order;
|
||||
static Anope::map<SerializeType *> types;
|
||||
|
||||
Anope::string name;
|
||||
unserialize_func unserialize;
|
||||
time_t timestamp;
|
||||
|
||||
public:
|
||||
SerializeType(const Anope::string &n, unserialize_func f) : name(n), unserialize(f)
|
||||
std::map<unsigned int, Serializable *> objects;
|
||||
|
||||
SerializeType(const Anope::string &n, unserialize_func f);
|
||||
~SerializeType();
|
||||
|
||||
const Anope::string &GetName();
|
||||
|
||||
Serializable *Unserialize(Serializable *obj, Serialize::Data &data);
|
||||
|
||||
void Check();
|
||||
|
||||
time_t GetTimestamp() const;
|
||||
void UpdateTimestamp();
|
||||
|
||||
static SerializeType *Find(const Anope::string &name);
|
||||
|
||||
static const std::vector<Anope::string> &GetTypeOrder();
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class serialize_checker
|
||||
{
|
||||
Anope::string name;
|
||||
T obj;
|
||||
|
||||
public:
|
||||
serialize_checker(const Anope::string &n) : name(n) { }
|
||||
|
||||
inline const T* operator->() const
|
||||
{
|
||||
type_order.push_back(this->name);
|
||||
types[this->name] = this;
|
||||
static SerializeType *type = SerializeType::Find(this->name);
|
||||
if (type)
|
||||
type->Check();
|
||||
return &this->obj;
|
||||
}
|
||||
inline T* operator->()
|
||||
{
|
||||
static SerializeType *type = SerializeType::Find(this->name);
|
||||
if (type)
|
||||
type->Check();
|
||||
return &this->obj;
|
||||
}
|
||||
|
||||
~SerializeType()
|
||||
inline const T& operator*() const
|
||||
{
|
||||
std::vector<Anope::string>::iterator it = std::find(type_order.begin(), type_order.end(), this->name);
|
||||
if (it != type_order.end())
|
||||
type_order.erase(it);
|
||||
types.erase(this->name);
|
||||
static SerializeType *type = SerializeType::Find(this->name);
|
||||
if (type)
|
||||
type->Check();
|
||||
return this->obj;
|
||||
}
|
||||
inline T& operator*()
|
||||
{
|
||||
static SerializeType *type = SerializeType::Find(this->name);
|
||||
if (type)
|
||||
type->Check();
|
||||
return this->obj;
|
||||
}
|
||||
|
||||
const Anope::string &GetName()
|
||||
inline operator const T&() const
|
||||
{
|
||||
static SerializeType *type = SerializeType::Find(this->name);
|
||||
if (type)
|
||||
type->Check();
|
||||
return this->obj;
|
||||
}
|
||||
inline operator T&()
|
||||
{
|
||||
static SerializeType *type = SerializeType::Find(this->name);
|
||||
if (type)
|
||||
type->Check();
|
||||
return this->obj;
|
||||
}
|
||||
};
|
||||
|
||||
#include "modules.h"
|
||||
|
||||
template<typename T>
|
||||
class serialize_obj : public dynamic_reference_base
|
||||
{
|
||||
protected:
|
||||
T *ref;
|
||||
|
||||
public:
|
||||
serialize_obj() : ref(NULL)
|
||||
{
|
||||
return this->name;
|
||||
}
|
||||
|
||||
void Create(Serializable::serialized_data &data)
|
||||
serialize_obj(T *obj) : ref(obj)
|
||||
{
|
||||
this->unserialize(data);
|
||||
if (obj)
|
||||
obj->AddReference(this);
|
||||
}
|
||||
|
||||
static SerializeType *Find(const Anope::string &name)
|
||||
serialize_obj(const serialize_obj<T> &other) : ref(other.ref)
|
||||
{
|
||||
Anope::map<SerializeType *>::iterator it = types.find(name);
|
||||
if (it != types.end())
|
||||
return it->second;
|
||||
if (*this)
|
||||
this->ref->AddReference(this);
|
||||
}
|
||||
|
||||
~serialize_obj()
|
||||
{
|
||||
if (*this)
|
||||
this->ref->DelReference(this);
|
||||
}
|
||||
|
||||
inline operator bool() const
|
||||
{
|
||||
if (!this->invalid)
|
||||
return this->ref != NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const std::vector<Anope::string> &GetTypeOrder()
|
||||
inline void operator=(T *newref)
|
||||
{
|
||||
return type_order;
|
||||
if (*this)
|
||||
this->ref->DelReference(this);
|
||||
|
||||
this->ref = newref;
|
||||
this->invalid = false;
|
||||
|
||||
if (newref)
|
||||
this->ref->AddReference(this);
|
||||
}
|
||||
|
||||
inline operator T*() const
|
||||
{
|
||||
if (!this->invalid)
|
||||
{
|
||||
if (this->ref)
|
||||
{
|
||||
FOREACH_MOD(I_OnSerializePtrAssign, OnSerializePtrAssign(this->ref));
|
||||
this->ref->QueueUpdate();
|
||||
}
|
||||
return this->ref;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
inline T* operator*() const
|
||||
{
|
||||
if (!this->invalid)
|
||||
{
|
||||
if (this->ref)
|
||||
{
|
||||
FOREACH_MOD(I_OnSerializePtrAssign, OnSerializePtrAssign(this->ref));
|
||||
this->ref->QueueUpdate();
|
||||
}
|
||||
return this->ref;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
inline T* operator->() const
|
||||
{
|
||||
if (!this->invalid)
|
||||
{
|
||||
if (this->ref)
|
||||
{
|
||||
FOREACH_MOD(I_OnSerializePtrAssign, OnSerializePtrAssign(this->ref));
|
||||
this->ref->QueueUpdate();
|
||||
}
|
||||
return this->ref;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+4
-1
@@ -1,6 +1,9 @@
|
||||
#ifndef SERVERS_H
|
||||
#define SERVERS_H
|
||||
|
||||
#include "services.h"
|
||||
#include "anope.h"
|
||||
|
||||
/* Anope */
|
||||
extern CoreExport Server *Me;
|
||||
|
||||
@@ -134,7 +137,7 @@ class CoreExport Server : public Flags<ServerFlag>
|
||||
* @param source The source of the message
|
||||
* @param message The message
|
||||
*/
|
||||
void Notice(BotInfo *source, const Anope::string &message);
|
||||
void Notice(const BotInfo *source, const Anope::string &message);
|
||||
|
||||
/** Find a server
|
||||
* @param name The name or SID/numeric
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* (C) 2003-2012 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.
|
||||
*/
|
||||
|
||||
#ifndef SERVICE_H
|
||||
#define SERVICE_H
|
||||
|
||||
#include "services.h"
|
||||
#include "anope.h"
|
||||
#include "modules.h"
|
||||
|
||||
class CoreExport Service : public virtual Base
|
||||
{
|
||||
static Anope::map<Anope::map<Service *> > services;
|
||||
public:
|
||||
static Service *FindService(const Anope::string &t, const Anope::string &n)
|
||||
{
|
||||
Anope::map<Anope::map<Service *> >::iterator it = services.find(t);
|
||||
if (it != services.end())
|
||||
{
|
||||
Anope::map<Service *>::iterator it2 = it->second.find(n);
|
||||
if (it2 != it->second.end())
|
||||
return it2->second;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static std::vector<Anope::string> GetServiceKeys(const Anope::string &t)
|
||||
{
|
||||
std::vector<Anope::string> keys;
|
||||
Anope::map<Anope::map<Service *> >::iterator it = services.find(t);
|
||||
if (it != services.end())
|
||||
for (Anope::map<Service *>::iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2)
|
||||
keys.push_back(it2->first);
|
||||
return keys;
|
||||
}
|
||||
|
||||
Module *owner;
|
||||
Anope::string type;
|
||||
Anope::string name;
|
||||
|
||||
Service(Module *o, const Anope::string &t, const Anope::string &n) : owner(o), type(t), name(n)
|
||||
{
|
||||
this->Register();
|
||||
}
|
||||
|
||||
virtual ~Service()
|
||||
{
|
||||
this->Unregister();
|
||||
}
|
||||
|
||||
void Register()
|
||||
{
|
||||
Anope::map<Service *> &smap = services[this->type];
|
||||
if (smap.find(this->name) != smap.end())
|
||||
throw ModuleException("Service " + this->type + " with name " + this->name + " already exists");
|
||||
smap[this->name] = this;
|
||||
}
|
||||
|
||||
void Unregister()
|
||||
{
|
||||
Anope::map<Service *> &smap = services[this->type];
|
||||
smap.erase(this->name);
|
||||
if (smap.empty())
|
||||
services.erase(this->type);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class service_reference : public dynamic_reference<T>
|
||||
{
|
||||
Anope::string type;
|
||||
Anope::string name;
|
||||
|
||||
public:
|
||||
service_reference(const Anope::string &t, const Anope::string &n) : dynamic_reference<T>(NULL), type(t), name(n)
|
||||
{
|
||||
}
|
||||
|
||||
inline void operator=(const Anope::string &n)
|
||||
{
|
||||
this->name = n;
|
||||
}
|
||||
|
||||
operator bool() anope_override
|
||||
{
|
||||
if (this->invalid)
|
||||
{
|
||||
this->invalid = false;
|
||||
this->ref = NULL;
|
||||
}
|
||||
if (!this->ref)
|
||||
{
|
||||
this->ref = static_cast<T *>(Service::FindService(this->type, this->name));
|
||||
if (this->ref)
|
||||
this->ref->AddReference(this);
|
||||
}
|
||||
return this->ref;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // SERVICE_H
|
||||
|
||||
+22
-896
@@ -14,103 +14,28 @@
|
||||
#ifndef SERVICES_H
|
||||
#define SERVICES_H
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
#include "sysconf.h"
|
||||
|
||||
#define BUFSIZE 1024
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstdarg>
|
||||
#include <stdexcept>
|
||||
#include <string.h>
|
||||
|
||||
#include <string.h>
|
||||
#if HAVE_STRINGS_H
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
#include <signal.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include <sys/stat.h> /* for umask() on some systems */
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <typeinfo>
|
||||
#include <ctype.h>
|
||||
|
||||
#if GETTEXT_FOUND
|
||||
# include <libintl.h>
|
||||
#endif
|
||||
#define _(x) x
|
||||
|
||||
#ifndef _WIN32
|
||||
# include <unistd.h>
|
||||
# include <grp.h>
|
||||
# include <netdb.h>
|
||||
# include <netinet/in.h>
|
||||
# include <arpa/inet.h>
|
||||
# include <sys/socket.h>
|
||||
# include <sys/time.h>
|
||||
# include <sys/wait.h>
|
||||
# include <dirent.h>
|
||||
# include <pthread.h>
|
||||
# define DllExport
|
||||
# define CoreExport
|
||||
# define MARK_DEPRECATED __attribute((deprecated))
|
||||
#else
|
||||
# include "anope_windows.h"
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
/* Telling compilers about printf()-like functions: */
|
||||
#ifdef __GNUC__
|
||||
# define FORMAT(type, fmt, start) __attribute__((format(type, fmt, start)))
|
||||
#else
|
||||
# define FORMAT(type, fmt, start)
|
||||
#endif
|
||||
|
||||
/** This definition is used as shorthand for the various classes
|
||||
* and functions needed to make a module loadable by the OS.
|
||||
* It defines the class factory and external AnopeInit and AnopeFini functions.
|
||||
*/
|
||||
#ifdef _WIN32
|
||||
# define MODULE_INIT(x) \
|
||||
extern "C" DllExport Module *AnopeInit(const Anope::string &, const Anope::string &); \
|
||||
extern "C" Module *AnopeInit(const Anope::string &modname, const Anope::string &creator) \
|
||||
{ \
|
||||
return new x(modname, creator); \
|
||||
} \
|
||||
BOOLEAN WINAPI DllMain(HINSTANCE, DWORD nReason, LPVOID) \
|
||||
{ \
|
||||
return TRUE; \
|
||||
} \
|
||||
extern "C" DllExport void AnopeFini(x *); \
|
||||
extern "C" void AnopeFini(x *m) \
|
||||
{ \
|
||||
delete m; \
|
||||
}
|
||||
#else
|
||||
# define MODULE_INIT(x) \
|
||||
extern "C" DllExport Module *AnopeInit(const Anope::string &modname, const Anope::string &creator) \
|
||||
{ \
|
||||
return new x(modname, creator); \
|
||||
} \
|
||||
extern "C" DllExport void AnopeFini(x *m) \
|
||||
{ \
|
||||
delete m; \
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Miscellaneous definitions. */
|
||||
#include "hashcomp.h"
|
||||
|
||||
/* Pull in the various bits of STL */
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <exception>
|
||||
#include <list>
|
||||
@@ -118,616 +43,28 @@
|
||||
#include <deque>
|
||||
#include <bitset>
|
||||
#include <set>
|
||||
#include <algorithm>
|
||||
|
||||
#include "anope.h"
|
||||
#include "defs.h"
|
||||
|
||||
/** This class can be used on its own to represent an exception, or derived to represent a module-specific exception.
|
||||
* When a module whishes to abort, e.g. within a constructor, it should throw an exception using ModuleException or
|
||||
* a class derived from ModuleException. If a module throws an exception during its constructor, the module will not
|
||||
* be loaded. If this happens, the error message returned by ModuleException::GetReason will be displayed to the user
|
||||
* attempting to load the module, or dumped to the console if the ircd is currently loading for the first time.
|
||||
*/
|
||||
class CoreException : public std::exception
|
||||
{
|
||||
protected:
|
||||
/** Holds the error message to be displayed
|
||||
*/
|
||||
Anope::string err;
|
||||
/** Source of the exception
|
||||
*/
|
||||
Anope::string source;
|
||||
public:
|
||||
/** Default constructor, just uses the error mesage 'Core threw an exception'.
|
||||
*/
|
||||
CoreException() : err("Core threw an exception"), source("The core") { }
|
||||
/** This constructor can be used to specify an error message before throwing.
|
||||
*/
|
||||
CoreException(const Anope::string &message) : err(message), source("The core") { }
|
||||
/** This constructor can be used to specify an error message before throwing,
|
||||
* and to specify the source of the exception.
|
||||
*/
|
||||
CoreException(const Anope::string &message, const Anope::string &src) : err(message), source(src) { }
|
||||
/** This destructor solves world hunger, cancels the world debt, and causes the world to end.
|
||||
* Actually no, it does nothing. Never mind.
|
||||
* @throws Nothing!
|
||||
*/
|
||||
virtual ~CoreException() throw() { }
|
||||
/** Returns the reason for the exception.
|
||||
* The module should probably put something informative here as the user will see this upon failure.
|
||||
*/
|
||||
virtual const Anope::string &GetReason() const
|
||||
{
|
||||
return err;
|
||||
}
|
||||
#define _(x) x
|
||||
|
||||
virtual const Anope::string &GetSource() const
|
||||
{
|
||||
return source;
|
||||
}
|
||||
};
|
||||
|
||||
class FatalException : public CoreException
|
||||
{
|
||||
public:
|
||||
FatalException(const Anope::string &reason = "") : CoreException(reason) { }
|
||||
|
||||
virtual ~FatalException() throw() { }
|
||||
};
|
||||
|
||||
class ModuleException : public CoreException
|
||||
{
|
||||
public:
|
||||
/** Default constructor, just uses the error mesage 'Module threw an exception'.
|
||||
*/
|
||||
ModuleException() : CoreException("Module threw an exception", "A Module") { }
|
||||
|
||||
/** This constructor can be used to specify an error message before throwing.
|
||||
*/
|
||||
ModuleException(const Anope::string &message) : CoreException(message, "A Module") { }
|
||||
/** This destructor solves world hunger, cancels the world debt, and causes the world to end.
|
||||
* Actually no, it does nothing. Never mind.
|
||||
* @throws Nothing!
|
||||
*/
|
||||
virtual ~ModuleException() throw() { }
|
||||
};
|
||||
|
||||
/** Debug cast to be used instead of dynamic_cast, this uses dynamic_cast
|
||||
* for debug builds and static_cast on releass builds to speed up the program
|
||||
* because dynamic_cast relies on RTTI.
|
||||
*/
|
||||
template<typename T, typename O> inline T debug_cast(O ptr)
|
||||
{
|
||||
#ifdef DEBUG_BUILD
|
||||
T ret = dynamic_cast<T>(ptr);
|
||||
if (ptr != NULL && ret == NULL)
|
||||
throw CoreException(Anope::string("debug_cast<") + typeid(T).name() + ">(" + typeid(O).name() + ") fail");
|
||||
return ret;
|
||||
#ifdef __GXX_EXPERIMENTAL_CXX0X__
|
||||
# define anope_override override
|
||||
# define anope_final final
|
||||
#else
|
||||
return static_cast<T>(ptr);
|
||||
# define anope_override
|
||||
# define anope_final
|
||||
#endif
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/** Class with the ability to keep flags on items, they should extend from this
|
||||
* where T is an enum.
|
||||
*/
|
||||
template<typename T, size_t Size = 32> class Flags
|
||||
{
|
||||
protected:
|
||||
std::bitset<Size> Flag_Values;
|
||||
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
|
||||
* @param Value The flag
|
||||
*/
|
||||
void SetFlag(T Value)
|
||||
{
|
||||
Flag_Values[Value] = true;
|
||||
}
|
||||
|
||||
/** Remove a flag from this item
|
||||
* @param Value The flag
|
||||
*/
|
||||
void UnsetFlag(T Value)
|
||||
{
|
||||
Flag_Values[Value] = false;
|
||||
}
|
||||
|
||||
/** Check if this item has a flag
|
||||
* @param Value The flag
|
||||
* @return true or false
|
||||
*/
|
||||
bool HasFlag(T Value) const
|
||||
{
|
||||
return Flag_Values.test(Value);
|
||||
}
|
||||
|
||||
/** Check how many flags are set
|
||||
* @return The number of flags set
|
||||
*/
|
||||
size_t FlagCount() const
|
||||
{
|
||||
return Flag_Values.count();
|
||||
}
|
||||
|
||||
/** Unset all of the flags
|
||||
*/
|
||||
void ClearFlags()
|
||||
{
|
||||
Flag_Values.reset();
|
||||
}
|
||||
|
||||
Anope::string ToString()
|
||||
{
|
||||
std::vector<Anope::string> v = ToVector();
|
||||
Anope::string flag_buf;
|
||||
for (unsigned i = 0; i < v.size(); ++i)
|
||||
flag_buf += v[i] + " ";
|
||||
flag_buf.trim();
|
||||
return flag_buf;
|
||||
}
|
||||
|
||||
void FromString(const Anope::string &str)
|
||||
{
|
||||
spacesepstream sep(str);
|
||||
Anope::string buf;
|
||||
std::vector<Anope::string> v;
|
||||
|
||||
while (sep.GetToken(buf))
|
||||
v.push_back(buf);
|
||||
|
||||
FromVector(v);
|
||||
}
|
||||
|
||||
std::vector<Anope::string> ToVector()
|
||||
{
|
||||
std::vector<Anope::string> ret;
|
||||
for (unsigned i = 0; this->Flag_Strings && !this->Flag_Strings[i].empty(); ++i)
|
||||
if (this->HasFlag(static_cast<T>(i)))
|
||||
ret.push_back(this->Flag_Strings[i]);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void FromVector(const std::vector<Anope::string> &strings)
|
||||
{
|
||||
this->ClearFlags();
|
||||
|
||||
for (unsigned i = 0; this->Flag_Strings && !this->Flag_Strings[i].empty(); ++i)
|
||||
for (unsigned j = 0; j < strings.size(); ++j)
|
||||
if (this->Flag_Strings[i] == strings[j])
|
||||
this->SetFlag(static_cast<T>(i));
|
||||
}
|
||||
};
|
||||
|
||||
class Module;
|
||||
|
||||
class CoreExport Service : public Base
|
||||
{
|
||||
static Anope::map<Anope::map<Service *> > services;
|
||||
public:
|
||||
static Service *FindService(const Anope::string &t, const Anope::string &n)
|
||||
{
|
||||
Anope::map<Anope::map<Service *> >::iterator it = services.find(t);
|
||||
if (it != services.end())
|
||||
{
|
||||
Anope::map<Service *>::iterator it2 = it->second.find(n);
|
||||
if (it2 != it->second.end())
|
||||
return it2->second;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static std::vector<Anope::string> GetServiceKeys(const Anope::string &t)
|
||||
{
|
||||
std::vector<Anope::string> keys;
|
||||
Anope::map<Anope::map<Service *> >::iterator it = services.find(t);
|
||||
if (it != services.end())
|
||||
for (Anope::map<Service *>::iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2)
|
||||
keys.push_back(it2->first);
|
||||
return keys;
|
||||
}
|
||||
|
||||
Module *owner;
|
||||
Anope::string type;
|
||||
Anope::string name;
|
||||
|
||||
Service(Module *o, const Anope::string &t, const Anope::string &n) : owner(o), type(t), name(n)
|
||||
{
|
||||
this->Register();
|
||||
}
|
||||
|
||||
virtual ~Service()
|
||||
{
|
||||
this->Unregister();
|
||||
}
|
||||
|
||||
void Register()
|
||||
{
|
||||
Anope::map<Service *> &smap = services[this->type];
|
||||
if (smap.find(this->name) != smap.end())
|
||||
throw ModuleException("Service " + this->type + " with name " + this->name + " already exists");
|
||||
smap[this->name] = this;
|
||||
}
|
||||
|
||||
void Unregister()
|
||||
{
|
||||
Anope::map<Service *> &smap = services[this->type];
|
||||
smap.erase(this->name);
|
||||
if (smap.empty())
|
||||
services.erase(this->type);
|
||||
}
|
||||
};
|
||||
|
||||
#include "sockets.h"
|
||||
#include "socketengine.h"
|
||||
#include "extensible.h"
|
||||
#include "timers.h"
|
||||
#include "dns.h"
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
class Signal : public Pipe
|
||||
{
|
||||
static std::vector<Signal *> SignalHandlers;
|
||||
static void SignalHandler(int signal);
|
||||
|
||||
struct sigaction action, old;
|
||||
public:
|
||||
int signal;
|
||||
|
||||
Signal(int s);
|
||||
~Signal();
|
||||
|
||||
virtual void OnNotify() = 0;
|
||||
};
|
||||
|
||||
class ConvertException : public CoreException
|
||||
{
|
||||
public:
|
||||
ConvertException(const Anope::string &reason = "") : CoreException(reason) { }
|
||||
|
||||
virtual ~ConvertException() throw() { }
|
||||
};
|
||||
|
||||
template<typename T> inline Anope::string stringify(const T &x)
|
||||
{
|
||||
std::ostringstream stream;
|
||||
|
||||
if (!(stream << x))
|
||||
throw ConvertException("Stringify fail");
|
||||
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
template<typename T> inline void convert(const Anope::string &s, T &x, Anope::string &leftover, bool failIfLeftoverChars = true)
|
||||
{
|
||||
leftover.clear();
|
||||
std::istringstream i(s.str());
|
||||
char c;
|
||||
bool res = i >> x;
|
||||
if (!res)
|
||||
throw ConvertException("Convert fail");
|
||||
if (failIfLeftoverChars)
|
||||
{
|
||||
if (i.get(c))
|
||||
throw ConvertException("Convert fail");
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string left;
|
||||
getline(i, left);
|
||||
leftover = left;
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T> inline void convert(const Anope::string &s, T &x, bool failIfLeftoverChars = true)
|
||||
{
|
||||
Anope::string Unused;
|
||||
convert(s, x, Unused, failIfLeftoverChars);
|
||||
}
|
||||
|
||||
template<typename T> inline T convertTo(const Anope::string &s, Anope::string &leftover, bool failIfLeftoverChars = true)
|
||||
{
|
||||
T x;
|
||||
convert(s, x, leftover, failIfLeftoverChars);
|
||||
return x;
|
||||
}
|
||||
|
||||
template<typename T> inline T convertTo(const Anope::string &s, bool failIfLeftoverChars = true)
|
||||
{
|
||||
T x;
|
||||
convert(s, x, failIfLeftoverChars);
|
||||
return x;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
class User;
|
||||
class NickCore;
|
||||
class NickAlias;
|
||||
class BotInfo;
|
||||
class ChannelInfo;
|
||||
class Channel;
|
||||
class Server;
|
||||
class Entry;
|
||||
|
||||
#include "threadengine.h"
|
||||
#include "opertype.h"
|
||||
#include "modes.h"
|
||||
#include "serialize.h"
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/* Protocol tweaks */
|
||||
|
||||
struct IRCDVar
|
||||
{
|
||||
const char *name; /* Name of the IRCd command */
|
||||
const char *pseudoclient_mode; /* Mode used by BotServ Bots */
|
||||
int svsnick; /* Supports SVSNICK */
|
||||
int vhost; /* Supports vhost */
|
||||
int snline; /* Supports SNline */
|
||||
int sqline; /* Supports SQline */
|
||||
int szline; /* Supports SZline */
|
||||
int join2msg; /* Join 2 Message */
|
||||
int chansqline; /* Supports Channel Sqlines */
|
||||
int quitonkill; /* IRCD sends QUIT when kill */
|
||||
int vident; /* Supports vidents */
|
||||
int svshold; /* Supports svshold */
|
||||
int tsonmode; /* Timestamp on mode changes */
|
||||
int omode; /* On the fly o:lines */
|
||||
int umode; /* change user modes */
|
||||
int knock_needs_i; /* Check if we needed +i when setting NOKNOCK */
|
||||
int svsmode_ucmode; /* Can remove User Channel Modes with SVSMODE */
|
||||
int sglineenforce;
|
||||
int ts6; /* ircd is TS6 */
|
||||
const char *globaltldprefix; /* TLD prefix used for Global */
|
||||
unsigned maxmodes; /* Max modes to send per line */
|
||||
int certfp; /* IRCd sends a SSL users certificate fingerprint */
|
||||
};
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/** Memo Flags
|
||||
*/
|
||||
enum MemoFlag
|
||||
{
|
||||
/* Memo is unread */
|
||||
MF_UNREAD,
|
||||
/* Sender requests a receipt */
|
||||
MF_RECEIPT
|
||||
};
|
||||
|
||||
const Anope::string MemoFlagStrings[] = {
|
||||
"MF_UNREAD", "MF_RECEIPT", ""
|
||||
};
|
||||
|
||||
/* Memo info structures. Since both nicknames and channels can have memos,
|
||||
* we encapsulate memo data in a MemoList to make it easier to handle. */
|
||||
class CoreExport Memo : public Flags<MemoFlag>, public Serializable
|
||||
{
|
||||
public:
|
||||
Memo();
|
||||
|
||||
Anope::string serialize_name() const;
|
||||
serialized_data serialize();
|
||||
static void unserialize(serialized_data &);
|
||||
|
||||
Anope::string owner;
|
||||
time_t time; /* When it was sent */
|
||||
Anope::string sender;
|
||||
Anope::string text;
|
||||
};
|
||||
|
||||
struct CoreExport MemoInfo
|
||||
{
|
||||
int16_t memomax;
|
||||
std::vector<Memo *> memos;
|
||||
std::vector<Anope::string> ignores;
|
||||
|
||||
unsigned GetIndex(Memo *m) const;
|
||||
void Del(unsigned index);
|
||||
void Del(Memo *m);
|
||||
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;
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
class CoreExport HostInfo
|
||||
{
|
||||
private:
|
||||
Anope::string Ident;
|
||||
Anope::string Host;
|
||||
Anope::string Creator;
|
||||
time_t Time;
|
||||
|
||||
public:
|
||||
/** Set a vhost for the user
|
||||
* @param ident The ident
|
||||
* @param host The host
|
||||
* @param creator Who created the vhost
|
||||
* @param time When the vhost was craated
|
||||
*/
|
||||
void SetVhost(const Anope::string &ident, const Anope::string &host, const Anope::string &creator, time_t created = Anope::CurTime);
|
||||
|
||||
/** Remove a users vhost
|
||||
**/
|
||||
void RemoveVhost();
|
||||
|
||||
/** Check if the user has a vhost
|
||||
* @return true or false
|
||||
*/
|
||||
bool HasVhost() const;
|
||||
|
||||
/** Retrieve the vhost ident
|
||||
* @return the ident
|
||||
*/
|
||||
const Anope::string &GetIdent() const;
|
||||
|
||||
/** Retrieve the vhost host
|
||||
* @return the host
|
||||
*/
|
||||
const Anope::string &GetHost() const;
|
||||
|
||||
/** Retrieve the vhost creator
|
||||
* @return the creator
|
||||
*/
|
||||
const Anope::string &GetCreator() const;
|
||||
|
||||
/** Retrieve when the vhost was crated
|
||||
* @return the time it was created
|
||||
*/
|
||||
time_t GetTime() const;
|
||||
};
|
||||
|
||||
/* BotServ SET flags */
|
||||
enum BotServFlag
|
||||
{
|
||||
BS_BEGIN,
|
||||
/* BotServ won't kick ops */
|
||||
BS_DONTKICKOPS,
|
||||
/* BotServ won't kick voices */
|
||||
BS_DONTKICKVOICES,
|
||||
/* BotServ bot accepts fantasy commands */
|
||||
BS_FANTASY,
|
||||
/* BotServ should show greets */
|
||||
BS_GREET,
|
||||
/* BotServ bots are not allowed to be in this channel */
|
||||
BS_NOBOT,
|
||||
/* BotServ kicks for bolds */
|
||||
BS_KICK_BOLDS,
|
||||
/* BotServ kicks for colors */
|
||||
BS_KICK_COLORS,
|
||||
/* BOtServ kicks for reverses */
|
||||
BS_KICK_REVERSES,
|
||||
/* BotServ kicks for underlines */
|
||||
BS_KICK_UNDERLINES,
|
||||
/* BotServ kicks for badwords */
|
||||
BS_KICK_BADWORDS,
|
||||
/* BotServ kicks for caps */
|
||||
BS_KICK_CAPS,
|
||||
/* BotServ kicks for flood */
|
||||
BS_KICK_FLOOD,
|
||||
/* BotServ kicks for repeating */
|
||||
BS_KICK_REPEAT,
|
||||
/* BotServ kicks for italics */
|
||||
BS_KICK_ITALICS,
|
||||
/* BotServ kicks for amsgs */
|
||||
BS_KICK_AMSGS,
|
||||
BS_END
|
||||
};
|
||||
|
||||
const Anope::string BotServFlagStrings[] = {
|
||||
"BEGIN", "DONTKICKOPS", "DONTKICKVOICES", "FANTASY", "GREET", "NOBOT",
|
||||
"KICK_BOLDs", "KICK_COLORS", "KICK_REVERSES", "KICK_UNDERLINES", "KICK_BADWORDS", "KICK_CAPS",
|
||||
"KICK_FLOOD", "KICK_REPEAT", "KICK_ITALICS", "KICK_AMSGS", "MSG_PRIVMSG", "MSG_NOTICE",
|
||||
"MSG_NOTICEOPS", ""
|
||||
};
|
||||
|
||||
/* Indices for TTB (Times To Ban) */
|
||||
enum
|
||||
{
|
||||
TTB_BOLDS,
|
||||
TTB_COLORS,
|
||||
TTB_REVERSES,
|
||||
TTB_UNDERLINES,
|
||||
TTB_BADWORDS,
|
||||
TTB_CAPS,
|
||||
TTB_FLOOD,
|
||||
TTB_REPEAT,
|
||||
TTB_ITALICS,
|
||||
TTB_AMSGS,
|
||||
TTB_SIZE
|
||||
};
|
||||
|
||||
#include "access.h"
|
||||
#include "regchannel.h"
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/* This structure stocks ban data since it must not be removed when
|
||||
* user is kicked.
|
||||
*/
|
||||
|
||||
#include "users.h"
|
||||
#include "account.h"
|
||||
#include "commands.h"
|
||||
#include "bots.h"
|
||||
#include "channels.h"
|
||||
|
||||
/** Channelban type flags
|
||||
*/
|
||||
enum EntryType
|
||||
{
|
||||
ENTRYTYPE_NONE,
|
||||
ENTRYTYPE_CIDR,
|
||||
ENTRYTYPE_NICK_WILD,
|
||||
ENTRYTYPE_NICK,
|
||||
ENTRYTYPE_USER_WILD,
|
||||
ENTRYTYPE_USER,
|
||||
ENTRYTYPE_HOST_WILD,
|
||||
ENTRYTYPE_HOST
|
||||
};
|
||||
|
||||
class CoreExport Entry : public Flags<EntryType>
|
||||
{
|
||||
ChannelModeName modename;
|
||||
|
||||
public:
|
||||
unsigned char cidr_len;
|
||||
Anope::string mask;
|
||||
Anope::string nick, user, host;
|
||||
|
||||
/** Constructor
|
||||
* @param _host A full nick!ident@host/cidr mask
|
||||
* @param mode What mode this host is for - can be CMODE_BEGIN for unknown/no mode
|
||||
*/
|
||||
Entry(ChannelModeName mode, const Anope::string &_host);
|
||||
|
||||
/** Get the banned mask for this entry
|
||||
* @return The mask
|
||||
*/
|
||||
const Anope::string GetMask();
|
||||
|
||||
/** Check if this entry matches a user
|
||||
* @param u The user
|
||||
* @param full True to match against a users real host and IP
|
||||
* @return true on match
|
||||
*/
|
||||
bool Matches(User *u, bool full = false) const;
|
||||
};
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/* Mail data */
|
||||
|
||||
struct MailInfo
|
||||
{
|
||||
FILE *pipe;
|
||||
User *sender;
|
||||
NickCore *recipient;
|
||||
};
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/* Defcon */
|
||||
|
||||
/*************************************************************************/
|
||||
#ifndef _WIN32
|
||||
# define DllExport
|
||||
# define CoreExport
|
||||
# define MARK_DEPRECATED __attribute((deprecated))
|
||||
# define anope_close close
|
||||
#else
|
||||
# include "anope_windows.h"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* RFC: defination of a valid nick
|
||||
@@ -738,215 +75,4 @@ struct MailInfo
|
||||
**/
|
||||
#define isvalidnick(c) (isalnum(c) || ((c) >= '\x5B' && (c) <= '\x60') || ((c) >= '\x7B' && (c) <= '\x7D') || (c) == '-')
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/*
|
||||
* Forward declaration reqired, because the base IRCDProto class uses some crap from in here.
|
||||
*/
|
||||
class IRCDProto;
|
||||
class IRCdMessage;
|
||||
struct Uplink;
|
||||
class ServerConfig;
|
||||
class ConfigurationFile;
|
||||
class XLine;
|
||||
|
||||
#include "extern.h"
|
||||
#include "language.h"
|
||||
#include "mail.h"
|
||||
#include "servers.h"
|
||||
#include "logger.h"
|
||||
#include "config.h"
|
||||
|
||||
class CoreExport IRCDProto
|
||||
{
|
||||
private:
|
||||
virtual void SendSVSKillInternal(const BotInfo *, const User *, const Anope::string &) = 0;
|
||||
virtual void SendModeInternal(const BotInfo *, const Channel *, const Anope::string &) = 0;
|
||||
virtual void SendModeInternal(const BotInfo *, const User *, const Anope::string &) = 0;
|
||||
virtual void SendKickInternal(const BotInfo *, const Channel *, const User *, const Anope::string &) = 0;
|
||||
virtual void SendMessageInternal(const BotInfo *bi, const Anope::string &dest, const Anope::string &buf);
|
||||
virtual void SendNoticeInternal(const BotInfo *bi, const Anope::string &dest, const Anope::string &msg);
|
||||
virtual void SendPrivmsgInternal(const BotInfo *bi, const Anope::string &dest, const Anope::string &buf);
|
||||
virtual void SendQuitInternal(const User *u, const Anope::string &buf);
|
||||
virtual void SendPartInternal(const BotInfo *bi, const Channel *chan, const Anope::string &buf);
|
||||
virtual void SendGlobopsInternal(const BotInfo *source, const Anope::string &buf);
|
||||
virtual void SendCTCPInternal(const BotInfo *bi, const Anope::string &dest, const Anope::string &buf);
|
||||
virtual void SendNumericInternal(const Anope::string &source, int numeric, const Anope::string &dest, const Anope::string &buf);
|
||||
public:
|
||||
virtual ~IRCDProto() { }
|
||||
|
||||
virtual void SendSVSNOOP(const Server *, bool) { }
|
||||
virtual void SendTopic(BotInfo *, Channel *) = 0;
|
||||
virtual void SendVhostDel(User *) { }
|
||||
virtual void SendAkill(User *, const XLine *) = 0;
|
||||
virtual void SendAkillDel(const XLine *) = 0;
|
||||
virtual void SendSVSKill(const BotInfo *source, const User *user, const char *fmt, ...);
|
||||
virtual void SendMode(const BotInfo *bi, const Channel *dest, const char *fmt, ...);
|
||||
virtual void SendMode(const BotInfo *bi, const User *u, const char *fmt, ...);
|
||||
virtual void SendClientIntroduction(const User *u) = 0;
|
||||
virtual void SendKick(const BotInfo *bi, const Channel *chan, const User *user, const char *fmt, ...);
|
||||
virtual void SendMessage(const BotInfo *bi, const Anope::string &dest, const char *fmt, ...);
|
||||
virtual void SendNotice(const BotInfo *bi, const Anope::string &dest, const char *fmt, ...);
|
||||
virtual void SendAction(const BotInfo *bi, const Anope::string &dest, const char *fmt, ...);
|
||||
virtual void SendPrivmsg(const BotInfo *bi, const Anope::string &dest, const char *fmt, ...);
|
||||
virtual void SendGlobalNotice(const BotInfo *bi, const Server *dest, const Anope::string &msg);
|
||||
virtual void SendGlobalPrivmsg(const BotInfo *bi, const Server *desc, const Anope::string &msg);
|
||||
|
||||
virtual void SendQuit(const User *u, const char *fmt, ...);
|
||||
virtual void SendPing(const Anope::string &servname, const Anope::string &who);
|
||||
virtual void SendPong(const Anope::string &servname, const Anope::string &who);
|
||||
virtual void SendJoin(User *, Channel *, const ChannelStatus *) = 0;
|
||||
virtual void SendSQLineDel(const XLine *x) { }
|
||||
virtual void SendInvite(const BotInfo *bi, const Anope::string &chan, const Anope::string &nick);
|
||||
virtual void SendPart(const BotInfo *bi, const Channel *chan, const char *fmt, ...);
|
||||
virtual void SendGlobops(const BotInfo *source, const char *fmt, ...);
|
||||
virtual void SendSQLine(User *, const XLine *x) { }
|
||||
virtual void SendSquit(Server *, const Anope::string &message);
|
||||
virtual void SendSVSO(const Anope::string &, const Anope::string &, const Anope::string &) { }
|
||||
virtual void SendChangeBotNick(const BotInfo *bi, const Anope::string &newnick);
|
||||
virtual void SendForceNickChange(const User *u, const Anope::string &newnick, time_t when);
|
||||
virtual void SendVhost(User *, const Anope::string &, const Anope::string &) { }
|
||||
virtual void SendConnect() = 0;
|
||||
virtual void SendSVSHold(const Anope::string &) { }
|
||||
virtual void SendSVSHoldDel(const Anope::string &) { }
|
||||
virtual void SendSGLineDel(const XLine *) { }
|
||||
virtual void SendSZLineDel(const XLine *) { }
|
||||
virtual void SendSZLine(User *u, const XLine *) { }
|
||||
virtual void SendSGLine(User *, const XLine *) { }
|
||||
virtual void SendCTCP(const BotInfo *bi, const Anope::string &dest, const char *fmt, ...);
|
||||
virtual void SendSVSJoin(const Anope::string &, const Anope::string &, const Anope::string &, const Anope::string &) { }
|
||||
virtual void SendSWhois(const Anope::string &, const Anope::string &, const Anope::string &) { }
|
||||
virtual void SendBOB() { }
|
||||
virtual void SendEOB() { }
|
||||
virtual void SendServer(const Server *) = 0;
|
||||
virtual bool IsNickValid(const Anope::string &) { return true; }
|
||||
virtual bool IsChannelValid(const Anope::string &);
|
||||
virtual void SendNumeric(const Anope::string &source, int numeric, const Anope::string &dest, const char *fmt, ...);
|
||||
virtual void SendLogin(User *u) = 0;
|
||||
virtual void SendLogout(User *u) = 0;
|
||||
|
||||
/** Send a channel creation message to the uplink.
|
||||
* On most TS6 IRCds this is a SJOIN with no nick
|
||||
*/
|
||||
virtual void SendChannel(Channel *c) { }
|
||||
};
|
||||
|
||||
class CoreExport IRCdMessage
|
||||
{
|
||||
public:
|
||||
virtual bool On436(const Anope::string &, const std::vector<Anope::string> &);
|
||||
virtual bool OnAway(const Anope::string &, const std::vector<Anope::string> &);
|
||||
virtual bool OnJoin(const Anope::string &, const std::vector<Anope::string> &);
|
||||
virtual bool OnKick(const Anope::string &, const std::vector<Anope::string> &);
|
||||
virtual bool OnKill(const Anope::string &, const std::vector<Anope::string> &);
|
||||
virtual bool OnMode(const Anope::string &, const std::vector<Anope::string> &) = 0;
|
||||
virtual bool OnUID(const Anope::string &, const std::vector<Anope::string> &);
|
||||
virtual bool OnNick(const Anope::string &, const std::vector<Anope::string> &) = 0;
|
||||
virtual bool OnPart(const Anope::string &, const std::vector<Anope::string> &);
|
||||
virtual bool OnPing(const Anope::string &, const std::vector<Anope::string> &);
|
||||
virtual bool OnPrivmsg(const Anope::string &, const std::vector<Anope::string> &);
|
||||
virtual bool OnQuit(const Anope::string &, const std::vector<Anope::string> &);
|
||||
virtual bool OnServer(const Anope::string &, const std::vector<Anope::string> &) = 0;
|
||||
virtual bool OnSQuit(const Anope::string &, const std::vector<Anope::string> &);
|
||||
virtual bool OnTopic(const Anope::string &, const std::vector<Anope::string> &) = 0;
|
||||
virtual bool OnWhois(const Anope::string &, const std::vector<Anope::string> &);
|
||||
virtual bool OnCapab(const Anope::string &, const std::vector<Anope::string> &);
|
||||
virtual bool OnSJoin(const Anope::string &, const std::vector<Anope::string> &) = 0;
|
||||
virtual bool OnError(const Anope::string &, const std::vector<Anope::string> &);
|
||||
};
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
struct Uplink
|
||||
{
|
||||
Anope::string host;
|
||||
unsigned port;
|
||||
Anope::string password;
|
||||
bool ipv6;
|
||||
|
||||
Uplink(const Anope::string &_host, int _port, const Anope::string &_password, bool _ipv6) : host(_host), port(_port), password(_password), ipv6(_ipv6) { }
|
||||
bool operator==(const Uplink &other) const
|
||||
{
|
||||
if (this->host != other.host)
|
||||
return false;
|
||||
if (this->port != other.port)
|
||||
return false;
|
||||
if (this->password != other.password)
|
||||
return false;
|
||||
if (this->ipv6 != other.ipv6)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
inline bool operator!=(const Uplink &other) const { return !(*this == other); }
|
||||
};
|
||||
|
||||
/** A class to process numbered lists (passed to most DEL/LIST/VIEW commands).
|
||||
* The function HandleNumber is called for every number in the list. Note that
|
||||
* if descending is true it gets called in descending order. This is so deleting
|
||||
* the index passed to the function from an array will not cause the other indexes
|
||||
* passed to the function to be incorrect. This keeps us from having to have an
|
||||
* 'in use' flag on everything.
|
||||
*/
|
||||
class CoreExport NumberList
|
||||
{
|
||||
private:
|
||||
bool is_valid;
|
||||
|
||||
std::set<unsigned> numbers;
|
||||
|
||||
bool desc;
|
||||
public:
|
||||
/** Processes a numbered list
|
||||
* @param list The list
|
||||
* @param descending True to make HandleNumber get called with numbers in descending order
|
||||
*/
|
||||
NumberList(const Anope::string &list, bool descending);
|
||||
|
||||
/** Destructor, does nothing
|
||||
*/
|
||||
virtual ~NumberList();
|
||||
|
||||
/** Should be called after the constructors are done running. This calls the callbacks.
|
||||
*/
|
||||
void Process();
|
||||
|
||||
/** Called with a number from the list
|
||||
* @param Number The number
|
||||
*/
|
||||
virtual void HandleNumber(unsigned Number);
|
||||
|
||||
/** Called when there is an error with the numbered list
|
||||
* Return false to immediatly stop processing the list and return
|
||||
* This is all done before we start calling HandleNumber, so no numbers will have been processed yet
|
||||
* @param list The list
|
||||
* @return false to stop processing
|
||||
*/
|
||||
virtual bool InvalidRange(const Anope::string &list);
|
||||
};
|
||||
|
||||
class CoreExport ListFormatter
|
||||
{
|
||||
public:
|
||||
typedef std::map<Anope::string, Anope::string> ListEntry;
|
||||
private:
|
||||
std::vector<Anope::string> columns;
|
||||
std::vector<ListEntry> entries;
|
||||
public:
|
||||
ListFormatter &addColumn(const Anope::string &name);
|
||||
void addEntry(const ListEntry &entry);
|
||||
bool isEmpty() const;
|
||||
void Process(std::vector<Anope::string> &);
|
||||
};
|
||||
|
||||
class CoreExport InfoFormatter
|
||||
{
|
||||
User *user;
|
||||
std::vector<std::pair<Anope::string, Anope::string> > replies;
|
||||
unsigned longest;
|
||||
public:
|
||||
InfoFormatter(User *u);
|
||||
void Process(std::vector<Anope::string> &);
|
||||
Anope::string &operator[](const Anope::string &key);
|
||||
};
|
||||
|
||||
#endif /* SERVICES_H */
|
||||
#endif // SERVICES_H
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
*
|
||||
* (C) 2003-2012 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.
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SIGNAL_H
|
||||
#define SIGNAL_H
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
#include "sockets.h"
|
||||
|
||||
/** Represents a signal handler
|
||||
*/
|
||||
class Signal : public Pipe
|
||||
{
|
||||
static std::vector<Signal *> SignalHandlers;
|
||||
static void SignalHandler(int signal);
|
||||
|
||||
struct sigaction action, old;
|
||||
public:
|
||||
int signal;
|
||||
|
||||
/** Constructor
|
||||
* @param s The signal to listen for
|
||||
*/
|
||||
Signal(int s);
|
||||
~Signal();
|
||||
|
||||
/**
|
||||
* Called when the signal is received.
|
||||
* Note this is not *immediatly* called when the signal is received,
|
||||
* but it is saved and called at a later time when we are not doing something
|
||||
* important. This is always called on the main thread, even on systems that
|
||||
* spawn threads for signals, like Windows.
|
||||
*/
|
||||
virtual void OnNotify() anope_override = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
#ifndef SOCKETENGINE_H
|
||||
#define SOCKETENGINE_H
|
||||
|
||||
#include "services.h"
|
||||
|
||||
class CoreExport SocketEngine
|
||||
{
|
||||
public:
|
||||
|
||||
+30
-17
@@ -12,6 +12,12 @@
|
||||
#ifndef SOCKETS_H
|
||||
#define SOCKETS_H
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <netinet/in.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
#include "anope.h"
|
||||
|
||||
#define NET_BUFSIZE 65535
|
||||
@@ -26,7 +32,7 @@ union CoreExport sockaddrs
|
||||
|
||||
/** Construct the object, sets everything to 0
|
||||
*/
|
||||
sockaddrs();
|
||||
sockaddrs(const Anope::string &address = "");
|
||||
|
||||
/** Memset the object to 0
|
||||
*/
|
||||
@@ -112,10 +118,6 @@ enum SocketFlag
|
||||
|
||||
static const Anope::string SocketFlagStrings[] = { "SF_DEAD", "SF_WRITABLE", "SF_CONNECTING", "SF_CONNECTED", "SF_ACCEPTING", "SF_ACCEPTED", "" };
|
||||
|
||||
class Socket;
|
||||
class ClientSocket;
|
||||
class ListenSocket;
|
||||
class ConnectionSocket;
|
||||
|
||||
class CoreExport SocketIO
|
||||
{
|
||||
@@ -272,12 +274,12 @@ class CoreExport BufferedSocket : public virtual Socket
|
||||
/** Called when there is something to be received for this socket
|
||||
* @return true on success, false to drop this socket
|
||||
*/
|
||||
bool ProcessRead();
|
||||
bool ProcessRead() anope_override;
|
||||
|
||||
/** Called when the socket is ready to be written to
|
||||
* @return true on success, false to drop this socket
|
||||
*/
|
||||
bool ProcessWrite();
|
||||
bool ProcessWrite() anope_override;
|
||||
|
||||
/** Called with a line received from the socket
|
||||
* @param buf The line
|
||||
@@ -288,6 +290,9 @@ class CoreExport BufferedSocket : public virtual Socket
|
||||
/** Write to the socket
|
||||
* @param message The message
|
||||
*/
|
||||
protected:
|
||||
virtual void Write(const char *buffer, size_t l);
|
||||
public:
|
||||
void Write(const char *message, ...);
|
||||
void Write(const Anope::string &message);
|
||||
|
||||
@@ -304,8 +309,10 @@ class CoreExport BufferedSocket : public virtual Socket
|
||||
|
||||
class CoreExport BinarySocket : public virtual Socket
|
||||
{
|
||||
protected:
|
||||
struct DataBlock
|
||||
{
|
||||
char *orig;
|
||||
char *buf;
|
||||
size_t len;
|
||||
|
||||
@@ -327,18 +334,20 @@ class CoreExport BinarySocket : public virtual Socket
|
||||
/** Called when there is something to be received for this socket
|
||||
* @return true on success, false to drop this socket
|
||||
*/
|
||||
bool ProcessRead();
|
||||
bool ProcessRead() anope_override;
|
||||
|
||||
/** Called when the socket is ready to be written to
|
||||
* @return true on success, false to drop this socket
|
||||
*/
|
||||
bool ProcessWrite();
|
||||
bool ProcessWrite() anope_override;
|
||||
|
||||
/** Write data to the socket
|
||||
* @param buffer The data to write
|
||||
* @param l The length of the data
|
||||
*/
|
||||
void Write(const char *buffer, size_t l);
|
||||
virtual void Write(const char *buffer, size_t l);
|
||||
void Write(const char *message, ...);
|
||||
void Write(const Anope::string &message);
|
||||
|
||||
/** Called with data from the socket
|
||||
* @param buffer The data
|
||||
@@ -395,12 +404,12 @@ class CoreExport ConnectionSocket : public virtual Socket
|
||||
* Used to determine whether or not this socket is connected yet.
|
||||
* @return true to continue to call ProcessRead/ProcessWrite, false to not continue
|
||||
*/
|
||||
bool Process();
|
||||
bool Process() anope_override;
|
||||
|
||||
/** Called when there is an error for this socket
|
||||
* @return true on success, false to drop this socket
|
||||
*/
|
||||
void ProcessError();
|
||||
void ProcessError() anope_override;
|
||||
|
||||
/** Called on a successful connect
|
||||
*/
|
||||
@@ -430,12 +439,12 @@ class CoreExport ClientSocket : public virtual Socket
|
||||
* Used to determine whether or not this socket is connected yet.
|
||||
* @return true to continue to call ProcessRead/ProcessWrite, false to not continue
|
||||
*/
|
||||
bool Process();
|
||||
bool Process() anope_override;
|
||||
|
||||
/** Called when there is an error for this socket
|
||||
* @return true on success, false to drop this socket
|
||||
*/
|
||||
void ProcessError();
|
||||
void ProcessError() anope_override;
|
||||
|
||||
/** Called when a client has been accepted() successfully.
|
||||
*/
|
||||
@@ -464,15 +473,19 @@ class CoreExport Pipe : public Socket
|
||||
|
||||
/** Called when data is to be read
|
||||
*/
|
||||
bool ProcessRead();
|
||||
bool ProcessRead() anope_override;
|
||||
|
||||
/** Called when this pipe needs to be woken up
|
||||
*/
|
||||
void Notify();
|
||||
|
||||
/** Should be overloaded to do something useful
|
||||
/** Overload to do something useful
|
||||
*/
|
||||
virtual void OnNotify();
|
||||
virtual void OnNotify() = 0;
|
||||
};
|
||||
|
||||
extern CoreExport uint32_t TotalRead;
|
||||
extern CoreExport uint32_t TotalWritten;
|
||||
extern CoreExport SocketIO normalSocketIO;
|
||||
|
||||
#endif // SOCKET_H
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
#ifndef THREADENGINE_H
|
||||
#define THREADENGINE_H
|
||||
|
||||
class Thread;
|
||||
#include "sockets.h"
|
||||
#include "extensible.h"
|
||||
|
||||
class CoreExport Thread : public Pipe, public Extensible
|
||||
{
|
||||
|
||||
+3
-7
@@ -11,13 +11,9 @@
|
||||
#ifndef TIMERS_H
|
||||
#define TIMERS_H
|
||||
|
||||
#include "services.h"
|
||||
#include <time.h>
|
||||
#include <algorithm>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "anope.h"
|
||||
|
||||
class CoreExport Timer : public Extensible
|
||||
class CoreExport Timer
|
||||
{
|
||||
private:
|
||||
/** The time this was created
|
||||
@@ -88,7 +84,7 @@ class CoreExport Timer : public Extensible
|
||||
* This will ensure timers are not missed, as well as removing timers that have
|
||||
* expired and allowing the addition of new ones.
|
||||
*/
|
||||
class CoreExport TimerManager : public Extensible
|
||||
class CoreExport TimerManager
|
||||
{
|
||||
/** A list of timers
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
*
|
||||
* (C) 2003-2012 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.
|
||||
*/
|
||||
|
||||
#ifndef UPLINK_H
|
||||
#define UPLINK_H
|
||||
|
||||
#include "sockets.h"
|
||||
|
||||
class UplinkSocket : public ConnectionSocket, public BufferedSocket
|
||||
{
|
||||
public:
|
||||
UplinkSocket();
|
||||
~UplinkSocket();
|
||||
bool Read(const Anope::string &);
|
||||
void OnConnect();
|
||||
void OnError(const Anope::string &);
|
||||
|
||||
class CoreExport Message
|
||||
{
|
||||
private:
|
||||
const Server *server;
|
||||
const User *user;
|
||||
std::stringstream buffer;
|
||||
|
||||
public:
|
||||
Message();
|
||||
explicit Message(const Server *);
|
||||
explicit Message(const User *);
|
||||
~Message();
|
||||
template<typename T> Message &operator<<(const T &val)
|
||||
{
|
||||
this->buffer << val;
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
};
|
||||
extern CoreExport UplinkSocket *UplinkSock;
|
||||
|
||||
#endif // UPLINK_H
|
||||
|
||||
+37
-14
@@ -8,6 +8,13 @@
|
||||
#ifndef USERS_H
|
||||
#define USERS_H
|
||||
|
||||
#include "anope.h"
|
||||
#include "modes.h"
|
||||
#include "extensible.h"
|
||||
#include "serialize.h"
|
||||
#include "commands.h"
|
||||
#include "account.h"
|
||||
|
||||
extern CoreExport Anope::insensitive_map<User *> UserListByNick;
|
||||
extern CoreExport Anope::map<User *> UserListByUID;
|
||||
|
||||
@@ -30,8 +37,9 @@ struct ChannelContainer
|
||||
|
||||
typedef std::list<ChannelContainer *> UChannelList;
|
||||
|
||||
|
||||
/* Online user and channel data. */
|
||||
class CoreExport User : public Extensible
|
||||
class CoreExport User : public virtual Base, public Extensible, public CommandReply
|
||||
{
|
||||
protected:
|
||||
Anope::string vident;
|
||||
@@ -40,7 +48,7 @@ class CoreExport User : public Extensible
|
||||
bool OnAccess; /* If the user is on the access list of the nick theyre on */
|
||||
Flags<UserModeName, UMODE_END * 2> modes; /* Bitset of mode names the user has set on them */
|
||||
std::map<UserModeName, Anope::string> Params; /* Map of user modes and the params this user has */
|
||||
NickCore *nc; /* NickCore account the user is currently loggged in as */
|
||||
serialize_obj<NickCore> nc; /* NickCore account the user is currently loggged in as */
|
||||
|
||||
public: // XXX: exposing a tiny bit too much
|
||||
Anope::string nick; /* User's current nick */
|
||||
@@ -50,7 +58,7 @@ class CoreExport User : public Extensible
|
||||
Anope::string chost; /* User's cloaked hostname */
|
||||
Anope::string realname; /* Realname */
|
||||
Anope::string fingerprint; /* SSL Fingerprint */
|
||||
sockaddrs ip; /* User's IP */
|
||||
Anope::string ip; /* User's IP */
|
||||
Server *server; /* Server user is connected to */
|
||||
time_t timestamp; /* Timestamp of the nick */
|
||||
time_t my_signon; /* When did _we_ see the user? */
|
||||
@@ -154,8 +162,8 @@ class CoreExport User : public Extensible
|
||||
* @param fmt Format of the Message
|
||||
* @param ... any number of parameters
|
||||
*/
|
||||
void SendMessage(BotInfo *source, const char *fmt, ...);
|
||||
virtual void SendMessage(BotInfo *source, Anope::string msg);
|
||||
void SendMessage(const BotInfo *source, const char *fmt, ...);
|
||||
void SendMessage(const BotInfo *source, const Anope::string &msg) anope_override;
|
||||
|
||||
/** Collide a nick
|
||||
* See the comment in users.cpp
|
||||
@@ -182,19 +190,19 @@ class CoreExport User : public Extensible
|
||||
/** Get the account the user is logged in using
|
||||
* @return The account or NULL
|
||||
*/
|
||||
virtual NickCore *Account();
|
||||
virtual NickCore *Account() const;
|
||||
|
||||
/** Check if the user is identified for their nick
|
||||
* @param CheckNick True to check if the user is identified to the nickname they are on too
|
||||
* @return true or false
|
||||
*/
|
||||
virtual bool IsIdentified(bool CheckNick = false);
|
||||
bool IsIdentified(bool CheckNick = false) const;
|
||||
|
||||
/** Check if the user is recognized for their nick (on the nicks access list)
|
||||
* @param CheckSecure Only returns true if the user has secure off
|
||||
* @return true or false
|
||||
*/
|
||||
virtual bool IsRecognized(bool CheckSecure = true);
|
||||
bool IsRecognized(bool CheckSecure = true) const;
|
||||
|
||||
/** Check if the user is a services oper
|
||||
* @return true if they are an oper
|
||||
@@ -239,32 +247,32 @@ class CoreExport User : public Extensible
|
||||
* @param um The user mode
|
||||
* @param Param Optional param for the mode
|
||||
*/
|
||||
void SetMode(BotInfo *bi, UserMode *um, const Anope::string &Param = "");
|
||||
void SetMode(const BotInfo *bi, UserMode *um, const Anope::string &Param = "");
|
||||
|
||||
/** Set a mode on the user
|
||||
* @param bi The client setting the mode
|
||||
* @param Name The mode name
|
||||
* @param Param Optional param for the mode
|
||||
*/
|
||||
void SetMode(BotInfo *bi, UserModeName Name, const Anope::string &Param = "");
|
||||
void SetMode(const BotInfo *bi, UserModeName Name, const Anope::string &Param = "");
|
||||
|
||||
/** Remove a mode on the user
|
||||
* @param bi The client setting the mode
|
||||
* @param um The user mode
|
||||
*/
|
||||
void RemoveMode(BotInfo *bi, UserMode *um);
|
||||
void RemoveMode(const BotInfo *bi, UserMode *um);
|
||||
|
||||
/** Remove a mode from the user
|
||||
* @param bi The client setting the mode
|
||||
* @param Name The mode name
|
||||
*/
|
||||
void RemoveMode(BotInfo *bi, UserModeName Name);
|
||||
void RemoveMode(const BotInfo *bi, UserModeName Name);
|
||||
|
||||
/** Set a string of modes on a user
|
||||
* @param bi The client setting the modes
|
||||
* @param umodes The modes
|
||||
*/
|
||||
void SetModes(BotInfo *bi, const char *umodes, ...);
|
||||
void SetModes(const BotInfo *bi, const char *umodes, ...);
|
||||
|
||||
/** Set a string of modes on a user internally
|
||||
* @param umodes The modes
|
||||
@@ -282,7 +290,7 @@ class CoreExport User : public Extensible
|
||||
* @param c The channel
|
||||
* @return The channel container, or NULL
|
||||
*/
|
||||
ChannelContainer *FindChannel(const Channel *c);
|
||||
ChannelContainer *FindChannel(const Channel *c) const;
|
||||
|
||||
/** Check if the user is protected from kicks and negative mode changes
|
||||
* @return true or false
|
||||
@@ -296,4 +304,19 @@ class CoreExport User : public Extensible
|
||||
void Kill(const Anope::string &source, const Anope::string &reason);
|
||||
};
|
||||
|
||||
extern CoreExport int32_t opcnt;
|
||||
extern CoreExport uint32_t maxusercnt, usercnt;
|
||||
extern CoreExport time_t maxusertime;
|
||||
|
||||
extern CoreExport User *finduser(const Anope::string &nick);
|
||||
|
||||
extern CoreExport 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);
|
||||
|
||||
extern CoreExport void do_umode(const Anope::string &user, const Anope::string &modes);
|
||||
extern CoreExport void do_kill(User *user, const Anope::string &reason);
|
||||
|
||||
extern CoreExport bool matches_list(Channel *c, User *user, ChannelModeName mode);
|
||||
|
||||
extern CoreExport Anope::string create_mask(User *u);
|
||||
|
||||
#endif // USERS_H
|
||||
|
||||
+46
-20
@@ -15,21 +15,54 @@
|
||||
#include <sstream>
|
||||
#include <list>
|
||||
|
||||
static std::string get_git_hash(const std::string &git_dir)
|
||||
{
|
||||
std::fstream fd;
|
||||
std::string filebuf;
|
||||
|
||||
fd.open((git_dir + "/HEAD").c_str(), std::ios::in);
|
||||
if (!fd.is_open())
|
||||
return "";
|
||||
if (!getline(fd, filebuf) || filebuf.find("ref: ") != 0)
|
||||
{
|
||||
fd.close();
|
||||
return "";
|
||||
}
|
||||
|
||||
fd.close();
|
||||
|
||||
filebuf = filebuf.substr(5);
|
||||
fd.open((git_dir + "/" + filebuf).c_str(), std::ios::in);
|
||||
if (!fd.is_open())
|
||||
return "";
|
||||
if (!getline(fd, filebuf))
|
||||
{
|
||||
fd.close();
|
||||
return "";
|
||||
}
|
||||
fd.close();
|
||||
|
||||
return "g" + filebuf.substr(0, 7);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc < 3)
|
||||
{
|
||||
std::cout << "Syntax: " << argv[0] << " <src/version.sh> <version.h>" << std::endl;
|
||||
std::cerr << "Syntax: " << argv[0] << " <base> <version.h>" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::string version_sh = std::string(argv[1]) + "/src/version.sh";
|
||||
std::string git_dir = std::string(argv[1]) + "/.git";
|
||||
|
||||
std::fstream fd;
|
||||
|
||||
fd.clear();
|
||||
fd.open(argv[1], std::ios::in);
|
||||
fd.open(version_sh.c_str(), std::ios::in);
|
||||
if (!fd.is_open())
|
||||
{
|
||||
std::cout << "Error: Unable to open src/version.sh for reading: " << argv[1] << std::endl;
|
||||
std::cerr << "Error: Unable to open src/version.sh for reading: " << version_sh << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -41,7 +74,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
size_t eq = filebuf.find('=');
|
||||
|
||||
std::string type = filebuf.substr(8, 5);
|
||||
std::string type = filebuf.substr(0, eq);
|
||||
std::string value = filebuf.substr(eq + 2, filebuf.length() - eq - 3);
|
||||
versions.push_back(std::make_pair(type, value));
|
||||
}
|
||||
@@ -49,25 +82,19 @@ int main(int argc, char *argv[])
|
||||
|
||||
fd.close();
|
||||
|
||||
std::string git_version = get_git_hash(git_dir);
|
||||
if (!git_version.empty())
|
||||
versions.push_back(std::make_pair("VERSION_GIT", git_version));
|
||||
|
||||
fd.clear();
|
||||
fd.open(argv[2], std::ios::in);
|
||||
|
||||
std::string version_build = "#define VERSION_BUILD 1";
|
||||
std::string build = "#define BUILD 1";
|
||||
std::string version_extra;
|
||||
if (fd.is_open())
|
||||
{
|
||||
while (getline(fd, filebuf))
|
||||
{
|
||||
if (!filebuf.find("#define VERSION_BUILD"))
|
||||
version_build = filebuf;
|
||||
else if (!filebuf.find("#define VERSION_EXTRA"))
|
||||
{
|
||||
size_t q = filebuf.find('"');
|
||||
|
||||
version_extra = filebuf.substr(q + 1, filebuf.length() - q - 2);
|
||||
}
|
||||
else if (!filebuf.find("#define BUILD"))
|
||||
if (!filebuf.find("#define BUILD"))
|
||||
{
|
||||
size_t tab = filebuf.find(' ');
|
||||
|
||||
@@ -87,7 +114,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (!fd.is_open())
|
||||
{
|
||||
std::cout << "Error: Unable to include/version.h for writing: " << argv[2] << std::endl;
|
||||
std::cerr << "Error: Unable to include/version.h for writing: " << argv[2] << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -95,13 +122,12 @@ int main(int argc, char *argv[])
|
||||
|
||||
for (std::list<std::pair<std::string, std::string> >::iterator it = versions.begin(), it_end = versions.end(); it != it_end; ++it)
|
||||
{
|
||||
if (it->first == "EXTRA")
|
||||
fd << "#define VERSION_EXTRA \"" << (!version_extra.empty() ? version_extra : "") << (version_extra.find(it->second) == std::string::npos ? it->second : "") << "\"" << std::endl;
|
||||
if (it->first == "VERSION_EXTRA" || it->first == "VERSION_GIT")
|
||||
fd << "#define " << it->first << " \"" << it->second << "\"" << std::endl;
|
||||
else
|
||||
fd << "#define VERSION_" << it->first << " " << it->second << std::endl;
|
||||
fd << "#define " << it->first << " " << it->second << std::endl;
|
||||
}
|
||||
|
||||
fd << version_build << std::endl;
|
||||
fd << build << std::endl;
|
||||
|
||||
fd.close();
|
||||
|
||||
@@ -29,8 +29,8 @@ if(GETTEXT_FOUND)
|
||||
endif(NOT WIN32)
|
||||
|
||||
# Install the new language file
|
||||
install(CODE "FILE(MAKE_DIRECTORY \${CMAKE_INSTALL_PREFIX}/data/languages/${LANG_LANG}/LC_MESSAGES/)")
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${LANG_MO} DESTINATION data/languages/${LANG_LANG}/LC_MESSAGES RENAME ${LANG_DOMAIN}.mo PERMISSIONS ${PERMS})
|
||||
install(CODE "FILE(MAKE_DIRECTORY \"${LOCALE_DIR}/${LANG_LANG}/LC_MESSAGES/\")")
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${LANG_MO} DESTINATION ${LOCALE_DIR}/${LANG_LANG}/LC_MESSAGES RENAME ${LANG_DOMAIN}.mo PERMISSIONS ${PERMS})
|
||||
endforeach(LANG_PO)
|
||||
|
||||
# Generate languages, depends on the mo files
|
||||
|
||||
+1602
-1326
File diff suppressed because it is too large
Load Diff
+2254
-2397
File diff suppressed because it is too large
Load Diff
+1586
-1321
File diff suppressed because it is too large
Load Diff
+1600
-1326
File diff suppressed because it is too large
Load Diff
+1604
-1321
File diff suppressed because it is too large
Load Diff
+1587
-1311
File diff suppressed because it is too large
Load Diff
+1599
-1321
File diff suppressed because it is too large
Load Diff
+1594
-1319
File diff suppressed because it is too large
Load Diff
+1590
-1317
File diff suppressed because it is too large
Load Diff
+1591
-1315
File diff suppressed because it is too large
Load Diff
+1620
-1346
File diff suppressed because it is too large
Load Diff
+1588
-1317
File diff suppressed because it is too large
Load Diff
@@ -90,7 +90,7 @@ foreach(MODULE_FOLDER ${MODULES_FOLDERS})
|
||||
endif(WIN32)
|
||||
# Set the module to be installed to the module directory under the data directory
|
||||
install(TARGETS ${SO}
|
||||
DESTINATION data/modules
|
||||
DESTINATION ${LIB_DIR}/modules
|
||||
)
|
||||
endif(HAS_FUNCTION)
|
||||
else(NOT SKIP_DEPENDS AND NOT SKIP_LIBRARIES)
|
||||
@@ -105,7 +105,7 @@ foreach(MODULE_FOLDER ${MODULES_FOLDERS})
|
||||
|
||||
foreach(SUBDIR ${SUBMODULE_DIRS})
|
||||
if(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIR}")
|
||||
file(GLOB MODULES_SUBDIR_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${SUBDIR}/*.cpp")
|
||||
file(GLOB_RECURSE MODULES_SUBDIR_SRCS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${SUBDIR}/*.cpp")
|
||||
sort_list(MODULES_SUBDIR_SRCS)
|
||||
|
||||
# Set all the files to use C++ as well as set their compile flags (use the module-specific compile flags, though)
|
||||
@@ -190,11 +190,16 @@ foreach(MODULE_FOLDER ${MODULES_FOLDERS})
|
||||
endif(WIN32)
|
||||
# Set the module to be installed to the module directory under the data directory
|
||||
install(TARGETS ${SO}
|
||||
DESTINATION data/modules
|
||||
DESTINATION ${LIB_DIR}/modules
|
||||
)
|
||||
else(NOT SKIP_DEPENDS AND NOT SKIP_LIBRARIES AND HAS_FUNCTION)
|
||||
message(" This is not a fatal error - ${SUBDIR} will not be built.")
|
||||
endif(NOT SKIP_DEPENDS AND NOT SKIP_LIBRARIES AND HAS_FUNCTION)
|
||||
|
||||
# Run the directories CMakeLists.txt if there is one
|
||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIR}/CMakeLists.txt")
|
||||
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIR}")
|
||||
endif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIR}/CMakeLists.txt")
|
||||
endif(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIR}")
|
||||
endforeach(SUBDIR)
|
||||
endif(IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${MODULE_FOLDER}")
|
||||
|
||||
@@ -22,13 +22,11 @@ class CommandBSAssign : public Command
|
||||
this->SetSyntax(_("\037channel\037 \037nick\037"));
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms)
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
|
||||
{
|
||||
const Anope::string &chan = params[0];
|
||||
const Anope::string &nick = params[1];
|
||||
|
||||
User *u = source.u;
|
||||
|
||||
if (readonly)
|
||||
{
|
||||
source.Reply(BOT_ASSIGN_READONLY);
|
||||
@@ -49,13 +47,14 @@ class CommandBSAssign : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
if (ci->botflags.HasFlag(BS_NOBOT) || (!ci->AccessFor(u).HasPriv("ASSIGN") && !u->HasPriv("botserv/administration")))
|
||||
AccessGroup access = source.AccessFor(ci);
|
||||
if (ci->botflags.HasFlag(BS_NOBOT) || (!access.HasPriv("ASSIGN") && !source.HasPriv("botserv/administration")))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
}
|
||||
|
||||
if (bi->HasFlag(BI_PRIVATE) && !u->HasCommand("botserv/assign/private"))
|
||||
if (bi->HasFlag(BI_PRIVATE) && !source.HasCommand("botserv/assign/private"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
@@ -67,14 +66,14 @@ class CommandBSAssign : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
bool override = !ci->AccessFor(u).HasPriv("ASSIGN");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "for " << bi->nick;
|
||||
bool override = !access.HasPriv("ASSIGN");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "for " << bi->nick;
|
||||
|
||||
bi->Assign(u, ci);
|
||||
bi->Assign(source.GetUser(), ci);
|
||||
source.Reply(_("Bot \002%s\002 has been assigned to %s."), bi->nick.c_str(), ci->name.c_str());
|
||||
}
|
||||
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand)
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
|
||||
{
|
||||
this->SendSyntax(source);
|
||||
source.Reply(" ");
|
||||
@@ -94,10 +93,8 @@ class CommandBSUnassign : public Command
|
||||
this->SetSyntax(_("\037channel\037"));
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms)
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
|
||||
{
|
||||
User *u = source.u;
|
||||
|
||||
if (readonly)
|
||||
{
|
||||
source.Reply(BOT_ASSIGN_READONLY);
|
||||
@@ -111,7 +108,8 @@ class CommandBSUnassign : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
if (!u->HasPriv("botserv/administration") && !ci->AccessFor(u).HasPriv("ASSIGN"))
|
||||
AccessGroup access = source.AccessFor(ci);
|
||||
if (!source.HasPriv("botserv/administration") && !access.HasPriv("ASSIGN"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
@@ -129,14 +127,14 @@ class CommandBSUnassign : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
bool override = !ci->AccessFor(u).HasPriv("ASSIGN");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "for " << ci->bi->nick;
|
||||
bool override = !access.HasPriv("ASSIGN");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "for " << ci->bi->nick;
|
||||
|
||||
ci->bi->UnAssign(u, ci);
|
||||
ci->bi->UnAssign(source.GetUser(), ci);
|
||||
source.Reply(_("There is no bot assigned to %s anymore."), ci->name.c_str());
|
||||
}
|
||||
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand)
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
|
||||
{
|
||||
this->SendSyntax(source);
|
||||
source.Reply(" ");
|
||||
|
||||
@@ -24,7 +24,7 @@ class BadwordsDelCallback : public NumberList
|
||||
public:
|
||||
BadwordsDelCallback(CommandSource &_source, ChannelInfo *_ci, Command *_c, const Anope::string &list) : NumberList(list, true), source(_source), ci(_ci), c(_c), Deleted(0), override(false)
|
||||
{
|
||||
if (!ci->AccessFor(source.u).HasPriv("BADWORDS") && source.u->HasPriv("botserv/administration"))
|
||||
if (!source.AccessFor(ci).HasPriv("BADWORDS") && source.HasPriv("botserv/administration"))
|
||||
this->override = true;
|
||||
}
|
||||
|
||||
@@ -38,12 +38,12 @@ class BadwordsDelCallback : public NumberList
|
||||
source.Reply(_("Deleted %d entries from %s bad words list."), Deleted, ci->name.c_str());
|
||||
}
|
||||
|
||||
void HandleNumber(unsigned Number)
|
||||
void HandleNumber(unsigned Number) anope_override
|
||||
{
|
||||
if (!Number || Number > ci->GetBadWordCount())
|
||||
return;
|
||||
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source.u, c, ci) << "DEL " << ci->GetBadWord(Number - 1)->word;
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, c, ci) << "DEL " << ci->GetBadWord(Number - 1)->word;
|
||||
++Deleted;
|
||||
ci->EraseBadWord(Number - 1);
|
||||
}
|
||||
@@ -54,8 +54,8 @@ class CommandBSBadwords : public Command
|
||||
private:
|
||||
void DoList(CommandSource &source, ChannelInfo *ci, const Anope::string &word)
|
||||
{
|
||||
bool override = !ci->AccessFor(source.u).HasPriv("BADWORDS");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source.u, this, ci) << "LIST";
|
||||
bool override = !source.AccessFor(ci).HasPriv("BADWORDS");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "LIST";
|
||||
ListFormatter list;
|
||||
|
||||
list.addColumn("Number").addColumn("Word").addColumn("Type");
|
||||
@@ -76,12 +76,12 @@ class CommandBSBadwords : public Command
|
||||
{
|
||||
}
|
||||
|
||||
void HandleNumber(unsigned Number)
|
||||
void HandleNumber(unsigned Number) anope_override
|
||||
{
|
||||
if (!Number || Number > ci->GetBadWordCount())
|
||||
return;
|
||||
|
||||
BadWord *bw = ci->GetBadWord(Number - 1);
|
||||
const BadWord *bw = ci->GetBadWord(Number - 1);
|
||||
ListFormatter::ListEntry entry;
|
||||
entry["Number"] = stringify(Number);
|
||||
entry["Word"] = bw->word;
|
||||
@@ -96,7 +96,7 @@ class CommandBSBadwords : public Command
|
||||
{
|
||||
for (unsigned i = 0, end = ci->GetBadWordCount(); i < end; ++i)
|
||||
{
|
||||
BadWord *bw = ci->GetBadWord(i);
|
||||
const BadWord *bw = ci->GetBadWord(i);
|
||||
|
||||
if (!word.empty() && !Anope::Match(bw->word, word))
|
||||
continue;
|
||||
@@ -154,7 +154,7 @@ class CommandBSBadwords : public Command
|
||||
|
||||
for (unsigned i = 0, end = ci->GetBadWordCount(); i < end; ++i)
|
||||
{
|
||||
BadWord *bw = ci->GetBadWord(i);
|
||||
const BadWord *bw = ci->GetBadWord(i);
|
||||
|
||||
if (!bw->word.empty() && ((Config->BSCaseSensitive && realword.equals_cs(bw->word)) || (!Config->BSCaseSensitive && realword.equals_ci(bw->word))))
|
||||
{
|
||||
@@ -163,8 +163,8 @@ class CommandBSBadwords : public Command
|
||||
}
|
||||
}
|
||||
|
||||
bool override = !ci->AccessFor(source.u).HasPriv("BADWORDS");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source.u, this, ci) << "ADD " << realword;
|
||||
bool override = !source.AccessFor(ci).HasPriv("BADWORDS");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "ADD " << realword;
|
||||
ci->AddBadWord(realword, bwtype);
|
||||
|
||||
source.Reply(_("\002%s\002 added to %s bad words list."), realword.c_str(), ci->name.c_str());
|
||||
@@ -183,7 +183,7 @@ class CommandBSBadwords : public Command
|
||||
else
|
||||
{
|
||||
unsigned i, end;
|
||||
BadWord *badword;
|
||||
const BadWord *badword;
|
||||
|
||||
for (i = 0, end = ci->GetBadWordCount(); i < end; ++i)
|
||||
{
|
||||
@@ -199,8 +199,8 @@ class CommandBSBadwords : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
bool override = !ci->AccessFor(source.u).HasPriv("BADWORDS");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source.u, this, ci) << "DEL " << badword->word;
|
||||
bool override = !source.AccessFor(ci).HasPriv("BADWORDS");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "DEL " << badword->word;
|
||||
|
||||
source.Reply(_("\002%s\002 deleted from %s bad words list."), badword->word.c_str(), ci->name.c_str());
|
||||
|
||||
@@ -212,8 +212,8 @@ class CommandBSBadwords : public Command
|
||||
|
||||
void DoClear(CommandSource &source, ChannelInfo *ci)
|
||||
{
|
||||
bool override = !ci->AccessFor(source.u).HasPriv("BADWORDS");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source.u, this, ci) << "CLEAR";
|
||||
bool override = !source.AccessFor(ci).HasPriv("BADWORDS");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "CLEAR";
|
||||
|
||||
ci->ClearBadWords();
|
||||
source.Reply(_("Bad words list is now empty."));
|
||||
@@ -229,11 +229,10 @@ class CommandBSBadwords : public Command
|
||||
this->SetSyntax(_("\037channel\037 CLEAR"));
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms)
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
|
||||
{
|
||||
const Anope::string &cmd = params[1];
|
||||
const Anope::string &word = params.size() > 2 ? params[2] : "";
|
||||
User *u = source.u;
|
||||
bool need_args = cmd.equals_ci("LIST") || cmd.equals_ci("CLEAR");
|
||||
|
||||
if (!need_args && word.empty())
|
||||
@@ -249,8 +248,7 @@ class CommandBSBadwords : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!ci->AccessFor(u).HasPriv("BADWORDS") && (!need_args || !u->HasPriv("botserv/administration")))
|
||||
if (!source.AccessFor(ci).HasPriv("BADWORDS") && (!need_args || !source.HasPriv("botserv/administration")))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
@@ -274,7 +272,7 @@ class CommandBSBadwords : public Command
|
||||
this->OnSyntaxError(source, "");
|
||||
}
|
||||
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand)
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
|
||||
{
|
||||
this->SendSyntax(source);
|
||||
source.Reply(" ");
|
||||
|
||||
+14
-16
@@ -22,7 +22,6 @@ class CommandBSBot : public Command
|
||||
const Anope::string &user = params[2];
|
||||
const Anope::string &host = params[3];
|
||||
const Anope::string &real = params[4];
|
||||
BotInfo *bi;
|
||||
|
||||
if (findbot(nick))
|
||||
{
|
||||
@@ -93,9 +92,9 @@ class CommandBSBot : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
bi = new BotInfo(nick, user, host, real);
|
||||
BotInfo *bi = new BotInfo(nick, user, host, real);
|
||||
|
||||
Log(LOG_ADMIN, source.u, this) << "ADD " << bi->GetMask() << " " << bi->realname;
|
||||
Log(LOG_ADMIN, source, this) << "ADD " << bi->GetMask() << " " << bi->realname;
|
||||
|
||||
source.Reply(_("%s!%s@%s (%s) added to the bot list."), bi->nick.c_str(), bi->GetIdent().c_str(), bi->host.c_str(), bi->realname.c_str());
|
||||
|
||||
@@ -110,7 +109,6 @@ class CommandBSBot : public Command
|
||||
const Anope::string &user = params.size() > 3 ? params[3] : "";
|
||||
const Anope::string &host = params.size() > 4 ? params[4] : "";
|
||||
const Anope::string &real = params.size() > 5 ? params[5] : "";
|
||||
BotInfo *bi;
|
||||
|
||||
if (oldnick.empty() || nick.empty())
|
||||
{
|
||||
@@ -118,7 +116,8 @@ class CommandBSBot : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(bi = findbot(oldnick)))
|
||||
BotInfo *bi = findbot(oldnick);
|
||||
if (!bi)
|
||||
{
|
||||
source.Reply(BOT_DOES_NOT_EXIST, oldnick.c_str());
|
||||
return;
|
||||
@@ -254,7 +253,7 @@ class CommandBSBot : public Command
|
||||
}
|
||||
|
||||
source.Reply(_("Bot \002%s\002 has been changed to %s!%s@%s (%s)"), oldnick.c_str(), bi->nick.c_str(), bi->GetIdent().c_str(), bi->host.c_str(), bi->realname.c_str());
|
||||
Log(LOG_ADMIN, source.u, this) << "CHANGE " << oldnick << " to " << bi->GetMask() << " " << bi->realname;
|
||||
Log(LOG_ADMIN, source, this) << "CHANGE " << oldnick << " to " << bi->GetMask() << " " << bi->realname;
|
||||
|
||||
FOREACH_MOD(I_OnBotChange, OnBotChange(bi));
|
||||
return;
|
||||
@@ -263,7 +262,6 @@ class CommandBSBot : public Command
|
||||
void DoDel(CommandSource &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
const Anope::string &nick = params[1];
|
||||
BotInfo *bi;
|
||||
|
||||
if (nick.empty())
|
||||
{
|
||||
@@ -271,7 +269,8 @@ class CommandBSBot : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(bi = findbot(nick)))
|
||||
BotInfo *bi = findbot(nick);
|
||||
if (!bi)
|
||||
{
|
||||
source.Reply(BOT_DOES_NOT_EXIST, nick.c_str());
|
||||
return;
|
||||
@@ -285,10 +284,10 @@ class CommandBSBot : public Command
|
||||
|
||||
FOREACH_MOD(I_OnBotDelete, OnBotDelete(bi));
|
||||
|
||||
Log(LOG_ADMIN, source.u, this) << "DEL " << bi->nick;
|
||||
Log(LOG_ADMIN, source, this) << "DEL " << bi->nick;
|
||||
|
||||
source.Reply(_("Bot \002%s\002 has been deleted."), nick.c_str());
|
||||
delete bi;
|
||||
bi->destroy();
|
||||
return;
|
||||
}
|
||||
public:
|
||||
@@ -300,10 +299,9 @@ class CommandBSBot : public Command
|
||||
this->SetSyntax(_("\002DEL \037nick\037\002"));
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms)
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
|
||||
{
|
||||
const Anope::string &cmd = params[0];
|
||||
User *u = source.u;
|
||||
|
||||
if (readonly)
|
||||
{
|
||||
@@ -314,7 +312,7 @@ class CommandBSBot : public Command
|
||||
if (cmd.equals_ci("ADD"))
|
||||
{
|
||||
// ADD nick user host real - 5
|
||||
if (!u->HasCommand("botserv/bot/add"))
|
||||
if (!source.HasCommand("botserv/bot/add"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
@@ -337,7 +335,7 @@ class CommandBSBot : public Command
|
||||
{
|
||||
// CHANGE oldn newn user host real - 6
|
||||
// but only oldn and newn are required
|
||||
if (!u->HasCommand("botserv/bot/change"))
|
||||
if (!source.HasCommand("botserv/bot/change"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
@@ -354,7 +352,7 @@ class CommandBSBot : public Command
|
||||
else if (cmd.equals_ci("DEL"))
|
||||
{
|
||||
// DEL nick
|
||||
if (!u->HasCommand("botserv/bot/del"))
|
||||
if (!source.HasCommand("botserv/bot/del"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
@@ -374,7 +372,7 @@ class CommandBSBot : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand)
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
|
||||
{
|
||||
this->SendSyntax(source);
|
||||
source.Reply(" ");
|
||||
|
||||
@@ -22,19 +22,18 @@ class CommandBSBotList : public Command
|
||||
this->SetSyntax("");
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms)
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
|
||||
{
|
||||
User *u = source.u;
|
||||
unsigned count = 0;
|
||||
ListFormatter list;
|
||||
|
||||
list.addColumn("Nick").addColumn("Mask");
|
||||
|
||||
for (Anope::insensitive_map<BotInfo *>::const_iterator it = BotListByNick.begin(), it_end = BotListByNick.end(); it != it_end; ++it)
|
||||
for (Anope::insensitive_map<BotInfo *>::const_iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it)
|
||||
{
|
||||
BotInfo *bi = it->second;
|
||||
|
||||
if (u->HasCommand("botserv/botlist") || !bi->HasFlag(BI_PRIVATE))
|
||||
if (source.HasCommand("botserv/botlist") || !bi->HasFlag(BI_PRIVATE))
|
||||
{
|
||||
++count;
|
||||
ListFormatter::ListEntry entry;
|
||||
@@ -61,12 +60,12 @@ class CommandBSBotList : public Command
|
||||
}
|
||||
}
|
||||
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand)
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
|
||||
{
|
||||
this->SendSyntax(source);
|
||||
source.Reply(" ");
|
||||
source.Reply(_("Lists all available bots on this network. Bots prefixed"
|
||||
"by a * are reserved for IRC operators."));
|
||||
source.Reply(_("Lists all available bots on this network.\n"
|
||||
"Bots prefixed by a * are reserved for IRC operators."));
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -22,12 +22,10 @@ class CommandBSSay : public Command
|
||||
this->SetSyntax(_("\037channel\037 \037text\037"));
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms)
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
|
||||
{
|
||||
const Anope::string &text = params[1];
|
||||
|
||||
User *u = source.u;
|
||||
|
||||
ChannelInfo *ci = cs_findchan(params[0]);
|
||||
if (ci == NULL)
|
||||
{
|
||||
@@ -35,7 +33,7 @@ class CommandBSSay : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ci->AccessFor(u).HasPriv("SAY"))
|
||||
if (!source.AccessFor(ci).HasPriv("SAY"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
@@ -63,12 +61,12 @@ class CommandBSSay : public Command
|
||||
ci->bi->lastmsg = Anope::CurTime;
|
||||
|
||||
// XXX need a way to find if someone is overriding this
|
||||
Log(LOG_COMMAND, u, this, ci) << text;
|
||||
Log(LOG_COMMAND, source, this, ci) << text;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand)
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
|
||||
{
|
||||
this->SendSyntax(source);
|
||||
source.Reply(" ");
|
||||
@@ -86,9 +84,8 @@ class CommandBSAct : public Command
|
||||
this->SetSyntax(_("\037channel\037 \037text\037"));
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms)
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
|
||||
{
|
||||
User *u = source.u;
|
||||
Anope::string message = params[1];
|
||||
|
||||
ChannelInfo *ci = cs_findchan(params[0]);
|
||||
@@ -98,7 +95,7 @@ class CommandBSAct : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ci->AccessFor(u).HasPriv("SAY"))
|
||||
if (!source.AccessFor(ci).HasPriv("SAY"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
@@ -124,12 +121,12 @@ class CommandBSAct : public Command
|
||||
ci->bi->lastmsg = Anope::CurTime;
|
||||
|
||||
// XXX Need to be able to find if someone is overriding this.
|
||||
Log(LOG_COMMAND, u, this, ci) << message;
|
||||
Log(LOG_COMMAND, source, this, ci) << message;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand)
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
|
||||
{
|
||||
this->SendSyntax(source);
|
||||
source.Reply(" ");
|
||||
|
||||
@@ -17,12 +17,12 @@
|
||||
class CommandBSInfo : public Command
|
||||
{
|
||||
private:
|
||||
void send_bot_channels(std::vector<Anope::string> &buffers, BotInfo *bi)
|
||||
void send_bot_channels(std::vector<Anope::string> &buffers, const BotInfo *bi)
|
||||
{
|
||||
Anope::string buf;
|
||||
for (registered_channel_map::const_iterator it = RegisteredChannelList.begin(), it_end = RegisteredChannelList.end(); it != it_end; ++it)
|
||||
for (registered_channel_map::const_iterator it = RegisteredChannelList->begin(), it_end = RegisteredChannelList->end(); it != it_end; ++it)
|
||||
{
|
||||
ChannelInfo *ci = it->second;
|
||||
const ChannelInfo *ci = it->second;
|
||||
|
||||
if (ci->bi == bi)
|
||||
{
|
||||
@@ -38,7 +38,7 @@ class CommandBSInfo : public Command
|
||||
buffers.push_back(buf);
|
||||
}
|
||||
|
||||
void CheckOptStr(Anope::string &buf, BotServFlag flag, const char *option, Flags<BotServFlag> &flags, NickCore *nc)
|
||||
void CheckOptStr(Anope::string &buf, BotServFlag flag, const char *option, Flags<BotServFlag> &flags, const NickCore *nc)
|
||||
{
|
||||
if (flags.HasFlag(flag))
|
||||
{
|
||||
@@ -55,14 +55,13 @@ class CommandBSInfo : public Command
|
||||
this->SetSyntax(_("\002INFO {\037chan\037 | \037nick\037}\002"));
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms)
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
|
||||
{
|
||||
const Anope::string &query = params[0];
|
||||
|
||||
User *u = source.u;
|
||||
BotInfo *bi = findbot(query);
|
||||
const BotInfo *bi = findbot(query);
|
||||
ChannelInfo *ci;
|
||||
InfoFormatter info(u);
|
||||
InfoFormatter info(source.nc);
|
||||
|
||||
if (bi)
|
||||
{
|
||||
@@ -71,7 +70,7 @@ class CommandBSInfo : public Command
|
||||
info[_("Real name")] = bi->realname;
|
||||
info[_("Created")] = do_strftime(bi->created);
|
||||
info[_("Options")] = bi->HasFlag(BI_PRIVATE) ? _("Private") : _("None");
|
||||
info[_("Used on")] = stringify(bi->chancount) + " channel(s)";
|
||||
info[_("Used on")] = stringify(bi->GetChannelCount()) + " channel(s)";
|
||||
|
||||
std::vector<Anope::string> replies;
|
||||
info.Process(replies);
|
||||
@@ -79,7 +78,7 @@ class CommandBSInfo : public Command
|
||||
for (unsigned i = 0; i < replies.size(); ++i)
|
||||
source.Reply(replies[i]);
|
||||
|
||||
if (u->HasPriv("botserv/administration"))
|
||||
if (source.HasPriv("botserv/administration"))
|
||||
{
|
||||
std::vector<Anope::string> buf;
|
||||
this->send_bot_channels(buf, bi);
|
||||
@@ -90,7 +89,7 @@ class CommandBSInfo : public Command
|
||||
}
|
||||
else if ((ci = cs_findchan(query)))
|
||||
{
|
||||
if (!ci->AccessFor(u).HasPriv("FOUNDER") && !u->HasPriv("botserv/administration"))
|
||||
if (!source.AccessFor(ci).HasPriv("FOUNDER") && !source.HasPriv("botserv/administration"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
@@ -99,8 +98,8 @@ class CommandBSInfo : public Command
|
||||
source.Reply(CHAN_INFO_HEADER, ci->name.c_str());
|
||||
info[_("Bot nick")] = ci->bi ? ci->bi->nick : "not assigned yet";
|
||||
|
||||
Anope::string enabled = translate(u, _("Enabled"));
|
||||
Anope::string disabled = translate(u, _("Disabled"));
|
||||
Anope::string enabled = translate(source.nc, _("Enabled"));
|
||||
Anope::string disabled = translate(source.nc, _("Disabled"));
|
||||
|
||||
if (ci->botflags.HasFlag(BS_KICK_BADWORDS))
|
||||
{
|
||||
@@ -203,11 +202,11 @@ class CommandBSInfo : public Command
|
||||
info[_("AMSG kicker")] = disabled;
|
||||
|
||||
Anope::string flags;
|
||||
CheckOptStr(flags, BS_DONTKICKOPS, _("Ops protection"), ci->botflags, u->Account());
|
||||
CheckOptStr(flags, BS_DONTKICKVOICES, _("Voices protection"), ci->botflags, u->Account());
|
||||
CheckOptStr(flags, BS_FANTASY, _("Fantasy"), ci->botflags, u->Account());
|
||||
CheckOptStr(flags, BS_GREET, _("Greet"), ci->botflags, u->Account());
|
||||
CheckOptStr(flags, BS_NOBOT, _("No bot"), ci->botflags, u->Account());
|
||||
CheckOptStr(flags, BS_DONTKICKOPS, _("Ops protection"), ci->botflags, source.nc);
|
||||
CheckOptStr(flags, BS_DONTKICKVOICES, _("Voices protection"), ci->botflags, source.nc);
|
||||
CheckOptStr(flags, BS_FANTASY, _("Fantasy"), ci->botflags, source.nc);
|
||||
CheckOptStr(flags, BS_GREET, _("Greet"), ci->botflags, source.nc);
|
||||
CheckOptStr(flags, BS_NOBOT, _("No bot"), ci->botflags, source.nc);
|
||||
|
||||
info[_("Options")] = flags.empty() ? _("None") : flags;
|
||||
|
||||
@@ -221,7 +220,7 @@ class CommandBSInfo : public Command
|
||||
source.Reply(_("\002%s\002 is not a valid bot or registered channel."), query.c_str());
|
||||
}
|
||||
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand)
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
|
||||
{
|
||||
this->SendSyntax(source);
|
||||
source.Reply(" ");
|
||||
|
||||
@@ -20,17 +20,16 @@ class CommandBSKick : public Command
|
||||
CommandBSKick(Module *creator) : Command(creator, "botserv/kick", 3, 6)
|
||||
{
|
||||
this->SetDesc(_("Configures kickers"));
|
||||
this->SetSyntax(_("\037channel\037 \037option\037 {\037ON|\037} [\037settings\037]"));
|
||||
this->SetSyntax(_("\037channel\037 \037option\037 {\037ON|OFF\037} [\037settings\037]"));
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms)
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
|
||||
{
|
||||
const Anope::string &chan = params[0];
|
||||
const Anope::string &option = params[1];
|
||||
const Anope::string &value = params[2];
|
||||
const Anope::string &ttb = params.size() > 3 ? params[3] : "";
|
||||
|
||||
User *u = source.u;
|
||||
ChannelInfo *ci = cs_findchan(params[0]);
|
||||
|
||||
if (readonly)
|
||||
@@ -41,14 +40,14 @@ class CommandBSKick : public Command
|
||||
this->OnSyntaxError(source, "");
|
||||
else if (!value.equals_ci("ON") && !value.equals_ci("OFF"))
|
||||
this->OnSyntaxError(source, "");
|
||||
else if (!ci->AccessFor(u).HasPriv("SET") && !u->HasPriv("botserv/administration"))
|
||||
else if (!source.AccessFor(ci).HasPriv("SET") && !source.HasPriv("botserv/administration"))
|
||||
source.Reply(ACCESS_DENIED);
|
||||
else if (!ci->bi)
|
||||
source.Reply(BOT_NOT_ASSIGNED);
|
||||
else
|
||||
{
|
||||
bool override = !ci->AccessFor(u).HasPriv("SET");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << option << " " << value;
|
||||
bool override = !source.AccessFor(ci).HasPriv("SET");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << option << " " << value;
|
||||
|
||||
if (option.equals_ci("BADWORDS"))
|
||||
{
|
||||
@@ -459,7 +458,7 @@ class CommandBSKick : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand)
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
|
||||
{
|
||||
if (subcommand.empty())
|
||||
{
|
||||
@@ -626,7 +625,7 @@ struct BanData : public ExtensibleItem
|
||||
}
|
||||
}
|
||||
|
||||
void OnDelete()
|
||||
void OnDelete() anope_override
|
||||
{
|
||||
delete this;
|
||||
}
|
||||
@@ -659,7 +658,7 @@ struct UserData : public ExtensibleItem
|
||||
|
||||
Anope::string lastline;
|
||||
|
||||
void OnDelete()
|
||||
void OnDelete() anope_override
|
||||
{
|
||||
delete this;
|
||||
}
|
||||
@@ -671,7 +670,7 @@ class BanDataPurger : public CallBack
|
||||
public:
|
||||
BanDataPurger(Module *owner) : CallBack(owner, 300, Anope::CurTime, true) { }
|
||||
|
||||
void Tick(time_t)
|
||||
void Tick(time_t) anope_override
|
||||
{
|
||||
Log(LOG_DEBUG) << "bs_main: Running bandata purger";
|
||||
|
||||
@@ -785,7 +784,7 @@ class BSKick : public Module
|
||||
}
|
||||
}
|
||||
|
||||
void OnPrivmsg(User *u, Channel *c, Anope::string &msg)
|
||||
void OnPrivmsg(User *u, Channel *c, Anope::string &msg) anope_override
|
||||
{
|
||||
/* Now we can make kicker stuff. We try to order the checks
|
||||
* from the fastest one to the slowest one, since there's
|
||||
@@ -900,7 +899,7 @@ class BSKick : public Module
|
||||
|
||||
for (unsigned i = 0, end = ci->GetBadWordCount(); i < end; ++i)
|
||||
{
|
||||
BadWord *bw = ci->GetBadWord(i);
|
||||
const 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;
|
||||
@@ -1012,7 +1011,7 @@ class BSKick : public Module
|
||||
Channel *chan = (*it)->chan;
|
||||
++it;
|
||||
|
||||
if (chan->ci != NULL && chan->ci->botflags.HasFlag(BS_KICK_AMSGS) && !chan->ci->AccessFor(u).HasPriv("NOKICK"))
|
||||
if (chan->ci && chan->ci->botflags.HasFlag(BS_KICK_AMSGS) && !chan->ci->AccessFor(u).HasPriv("NOKICK"))
|
||||
{
|
||||
check_ban(chan->ci, u, TTB_AMSGS);
|
||||
bot_kick(chan->ci, u, _("Don't use AMSGs!"));
|
||||
|
||||
+24
-215
@@ -19,232 +19,41 @@ class CommandBSSet : public Command
|
||||
CommandBSSet(Module *creator) : Command(creator, "botserv/set", 3, 3)
|
||||
{
|
||||
this->SetDesc(_("Configures bot options"));
|
||||
this->SetSyntax(_("\037(channel | bot)\037 \037option\037 \037settings\037"));
|
||||
this->SetSyntax(_("\037option\037 \037(channel | bot)\037 \037settings\037"));
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms)
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
|
||||
{
|
||||
const Anope::string &chan = params[0];
|
||||
const Anope::string &option = params[1];
|
||||
const Anope::string &value = params[2];
|
||||
|
||||
User *u = source.u;
|
||||
ChannelInfo *ci;
|
||||
|
||||
if (readonly)
|
||||
source.Reply(_("Sorry, bot option setting is temporarily disabled."));
|
||||
else if (u->HasCommand("botserv/set/private") && option.equals_ci("PRIVATE"))
|
||||
{
|
||||
BotInfo *bi;
|
||||
|
||||
if (!(bi = findbot(chan)))
|
||||
{
|
||||
source.Reply(BOT_DOES_NOT_EXIST, chan.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
if (value.equals_ci("ON"))
|
||||
{
|
||||
bi->SetFlag(BI_PRIVATE);
|
||||
source.Reply(_("Private mode of bot %s is now \002on\002."), bi->nick.c_str());
|
||||
}
|
||||
else if (value.equals_ci("OFF"))
|
||||
{
|
||||
bi->UnsetFlag(BI_PRIVATE);
|
||||
source.Reply(_("Private mode of bot %s is now \002off\002."), bi->nick.c_str());
|
||||
}
|
||||
else
|
||||
this->OnSyntaxError(source, "PRIVATE");
|
||||
return;
|
||||
}
|
||||
else if (!(ci = cs_findchan(chan)))
|
||||
source.Reply(CHAN_X_NOT_REGISTERED, chan.c_str());
|
||||
else if (!u->HasPriv("botserv/administration") && !ci->AccessFor(u).HasPriv("SET"))
|
||||
source.Reply(ACCESS_DENIED);
|
||||
else
|
||||
{
|
||||
bool override = !ci->AccessFor(u).HasPriv("SET");
|
||||
Log(override ? LOG_ADMIN : LOG_COMMAND, u, this, ci) << option << " " << value;
|
||||
|
||||
if (option.equals_ci("DONTKICKOPS"))
|
||||
{
|
||||
if (value.equals_ci("ON"))
|
||||
{
|
||||
ci->botflags.SetFlag(BS_DONTKICKOPS);
|
||||
source.Reply(_("Bot \002won't kick ops\002 on channel %s."), ci->name.c_str());
|
||||
}
|
||||
else if (value.equals_ci("OFF"))
|
||||
{
|
||||
ci->botflags.UnsetFlag(BS_DONTKICKOPS);
|
||||
source.Reply(_("Bot \002will kick ops\002 on channel %s."), ci->name.c_str());
|
||||
}
|
||||
else
|
||||
this->OnSyntaxError(source, "DONTKICKOPS");
|
||||
}
|
||||
else if (option.equals_ci("DONTKICKVOICES"))
|
||||
{
|
||||
if (value.equals_ci("ON"))
|
||||
{
|
||||
ci->botflags.SetFlag(BS_DONTKICKVOICES);
|
||||
source.Reply(_("Bot \002won't kick voices\002 on channel %s."), ci->name.c_str());
|
||||
}
|
||||
else if (value.equals_ci("OFF"))
|
||||
{
|
||||
ci->botflags.UnsetFlag(BS_DONTKICKVOICES);
|
||||
source.Reply(_("Bot \002will kick voices\002 on channel %s."), ci->name.c_str());
|
||||
}
|
||||
else
|
||||
this->OnSyntaxError(source, "DONTKICKVOICE");
|
||||
}
|
||||
else if (option.equals_ci("FANTASY"))
|
||||
{
|
||||
if (value.equals_ci("ON"))
|
||||
{
|
||||
ci->botflags.SetFlag(BS_FANTASY);
|
||||
source.Reply(_("Fantasy mode is now \002on\002 on channel %s."), ci->name.c_str());
|
||||
}
|
||||
else if (value.equals_ci("OFF"))
|
||||
{
|
||||
ci->botflags.UnsetFlag(BS_FANTASY);
|
||||
source.Reply(_("Fantasy mode is now \002off\002 on channel %s."), ci->name.c_str());
|
||||
}
|
||||
else
|
||||
this->OnSyntaxError(source, "FANTASY");
|
||||
}
|
||||
else if (option.equals_ci("GREET"))
|
||||
{
|
||||
if (value.equals_ci("ON"))
|
||||
{
|
||||
ci->botflags.SetFlag(BS_GREET);
|
||||
source.Reply(_("Greet mode is now \002on\002 on channel %s."), ci->name.c_str());
|
||||
}
|
||||
else if (value.equals_ci("OFF"))
|
||||
{
|
||||
ci->botflags.UnsetFlag(BS_GREET);
|
||||
source.Reply(_("Greet mode is now \002off\002 on channel %s."), ci->name.c_str());
|
||||
}
|
||||
else
|
||||
this->OnSyntaxError(source, "GREET");
|
||||
}
|
||||
else if (u->HasCommand("botserv/set/nobot") && option.equals_ci("NOBOT"))
|
||||
{
|
||||
if (value.equals_ci("ON"))
|
||||
{
|
||||
ci->botflags.SetFlag(BS_NOBOT);
|
||||
if (ci->bi)
|
||||
ci->bi->UnAssign(u, ci);
|
||||
source.Reply(_("No Bot mode is now \002on\002 on channel %s."), ci->name.c_str());
|
||||
}
|
||||
else if (value.equals_ci("OFF"))
|
||||
{
|
||||
ci->botflags.UnsetFlag(BS_NOBOT);
|
||||
source.Reply(_("No Bot mode is now \002off\002 on channel %s."), ci->name.c_str());
|
||||
}
|
||||
else
|
||||
this->OnSyntaxError(source, "NOBOT");
|
||||
}
|
||||
else
|
||||
this->OnSyntaxError(source, "");
|
||||
}
|
||||
|
||||
return;
|
||||
this->OnSyntaxError(source, "");
|
||||
}
|
||||
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand)
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
|
||||
{
|
||||
if (subcommand.empty())
|
||||
this->SendSyntax(source);
|
||||
source.Reply(" ");
|
||||
source.Reply(_("Configures bot options.\n"
|
||||
" \n"
|
||||
"Available options:"));
|
||||
Anope::string this_name = source.command;
|
||||
for (BotInfo::command_map::const_iterator it = source.owner->commands.begin(), it_end = source.owner->commands.end(); it != it_end; ++it)
|
||||
{
|
||||
this->SendSyntax(source);
|
||||
source.Reply(" ");
|
||||
source.Reply(_("Configures bot options. \037option\037 can be one of:\n"
|
||||
" \n"
|
||||
" DONTKICKOPS To protect ops against bot kicks\n"
|
||||
" DONTKICKVOICES To protect voices against bot kicks\n"
|
||||
" GREET Enable greet messages\n"
|
||||
" FANTASY Enable fantaisist commands\n"
|
||||
" \n"
|
||||
"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(), source.owner->nick.c_str());
|
||||
User *u = source.u;
|
||||
if (u->IsServicesOper())
|
||||
source.Reply(_("These options are reserved to Services Operators:\n"
|
||||
" \n"
|
||||
" NOBOT Prevent a bot from being assigned to \n"
|
||||
" a channel\n"
|
||||
" PRIVATE Prevent a bot from being assigned by\n"
|
||||
" non IRC operators"));
|
||||
const Anope::string &c_name = it->first;
|
||||
const CommandInfo &info = it->second;
|
||||
if (c_name.find_ci(this_name + " ") == 0)
|
||||
{
|
||||
service_reference<Command> command("Command", info.name);
|
||||
if (command)
|
||||
{
|
||||
source.command = it->first;
|
||||
command->OnServHelp(source);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (subcommand.equals_ci("DONTKICKOPS"))
|
||||
source.Reply(_("Syntax: \002SET \037channel\037 DONTKICKOPS {\037ON|OFF\037}\n"
|
||||
" \n"
|
||||
"Enables or disables \002ops protection\002 mode on a channel.\n"
|
||||
"When it is enabled, ops won't be kicked by the bot\n"
|
||||
"even if they don't match the NOKICK level."));
|
||||
else if (subcommand.equals_ci("DONTKICKVOICES"))
|
||||
source.Reply(_("Syntax: \002SET \037channel\037 DONTKICKVOICES {\037ON|OFF\037}\n"
|
||||
" \n"
|
||||
"Enables or disables \002voices protection\002 mode on a channel.\n"
|
||||
"When it is enabled, voices won't be kicked by the bot\n"
|
||||
"even if they don't match the NOKICK level."));
|
||||
else if (subcommand.equals_ci("FANTASY"))
|
||||
source.Reply(_("Syntax: \002SET \037channel\037 FANTASY {\037ON|OFF\037}\n"
|
||||
"Enables or disables \002fantasy\002 mode on a channel.\n"
|
||||
"When it is enabled, users will be able to use\n"
|
||||
"commands !op, !deop, !voice, !devoice,\n"
|
||||
"!kick, !kb, !unban, !seen on a channel (find how \n"
|
||||
"to use them; try with or without nick for each, \n"
|
||||
"and with a reason for some?).\n"
|
||||
" \n"
|
||||
"Note that users wanting to use fantaisist\n"
|
||||
"commands MUST have enough level for both\n"
|
||||
"the FANTASIA and another level depending\n"
|
||||
"of the command if required (for example, to use \n"
|
||||
"!op, user must have enough access for the OPDEOP\n"
|
||||
"level)."));
|
||||
else if (subcommand.equals_ci("GREET"))
|
||||
source.Reply(_("Syntax: \002SET \037channel\037 GREET {\037ON|OFF\037}\n"
|
||||
" \n"
|
||||
"Enables or disables \002greet\002 mode on a channel.\n"
|
||||
"When it is enabled, the bot will display greet\n"
|
||||
"messages of users joining the channel, provided\n"
|
||||
"they have enough access to the channel."));
|
||||
else if (subcommand.equals_ci("NOBOT"))
|
||||
source.Reply(_("Syntax: \002SET \037channel\037 NOBOT {\037ON|OFF\037}\002\n"
|
||||
" \n"
|
||||
"This option makes a channel be unassignable. If a bot \n"
|
||||
"is already assigned to the channel, it is unassigned\n"
|
||||
"automatically when you enable the option."));
|
||||
else if (subcommand.equals_ci("PRIVATE"))
|
||||
source.Reply(_("Syntax: \002SET \037bot-nick\037 PRIVATE {\037ON|OFF\037}\002\n"
|
||||
"This option prevents a bot from being assigned to a\n"
|
||||
"channel by users that aren't IRC operators."));
|
||||
else
|
||||
return false;
|
||||
source.Reply(_("Type \002%s%s HELP SET \037option\037\002 for more information on a\n"
|
||||
"particular option."), Config->UseStrictPrivMsgString.c_str(), source.owner->nick.c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void OnSyntaxError(CommandSource &source, const Anope::string &subcommand)
|
||||
{
|
||||
if (subcommand.empty())
|
||||
Command::OnSyntaxError(source, "");
|
||||
else if (subcommand.equals_ci("PRIVATE"))
|
||||
this->SendSyntax(source, "\037botname\037 PRIVATE {\037ON|OFF\037}");
|
||||
else if (subcommand.equals_ci("DONTKICKOPS"))
|
||||
this->SendSyntax(source, "\037channel\037 DONTKICKOPS {\037ON|OFF\037}");
|
||||
else if (subcommand.equals_ci("DONTKICKVOICES"))
|
||||
this->SendSyntax(source, "\037channel\037 DONTKICKVOICES {\037ON|OFF\037}");
|
||||
else if (subcommand.equals_ci("FANTASY"))
|
||||
this->SendSyntax(source, "\037channel\037 FANTASY {\037ON|OFF\037}");
|
||||
else if (subcommand.equals_ci("GREET"))
|
||||
this->SendSyntax(source, "\037channel\037 GREET {\037ON|OFF\037}");
|
||||
else if (subcommand.equals_ci("NOBOT"))
|
||||
this->SendSyntax(source, "\037channel\037 NOBOT {\037ON|OFF\037}");
|
||||
else
|
||||
this->OnSyntaxError(source, "");
|
||||
}
|
||||
};
|
||||
|
||||
class BSSet : public Module
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
/* BotServ core functions
|
||||
*
|
||||
* (C) 2003-2012 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"
|
||||
|
||||
class CommandBSSetDontKickOps : public Command
|
||||
{
|
||||
public:
|
||||
CommandBSSetDontKickOps(Module *creator, const Anope::string &sname = "botserv/set/dontkickops") : Command(creator, sname, 2, 2)
|
||||
{
|
||||
this->SetDesc(_("To protect ops against bot kicks"));
|
||||
this->SetSyntax(_("\037channel\037 {ON | OFF}"));
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
|
||||
{
|
||||
ChannelInfo *ci = cs_findchan(params[0]);
|
||||
if (ci == NULL)
|
||||
{
|
||||
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
AccessGroup access = source.AccessFor(ci);
|
||||
if (!source.HasPriv("botserv/administration") && !access.HasPriv("SET"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
}
|
||||
|
||||
if (readonly)
|
||||
{
|
||||
source.Reply(_("Sorry, bot option setting is temporarily disabled."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (params[1].equals_ci("ON"))
|
||||
{
|
||||
bool override = !access.HasPriv("SET");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enable dontkickops";
|
||||
|
||||
ci->botflags.SetFlag(BS_DONTKICKOPS);
|
||||
source.Reply(_("Bot \002won't kick ops\002 on channel %s."), ci->name.c_str());
|
||||
}
|
||||
else if (params[1].equals_ci("OFF"))
|
||||
{
|
||||
bool override = !access.HasPriv("SET");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to disable dontkickops";
|
||||
|
||||
ci->botflags.UnsetFlag(BS_DONTKICKOPS);
|
||||
source.Reply(_("Bot \002will kick ops\002 on channel %s."), ci->name.c_str());
|
||||
}
|
||||
else
|
||||
this->OnSyntaxError(source, source.command);
|
||||
}
|
||||
|
||||
bool OnHelp(CommandSource &source, const Anope::string &) anope_override
|
||||
{
|
||||
this->SendSyntax(source);
|
||||
source.Reply(_(" \n"
|
||||
"Enables or disables \002ops protection\002 mode on a channel.\n"
|
||||
"When it is enabled, ops won't be kicked by the bot\n"
|
||||
"even if they don't match the NOKICK level."));
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class BSSetDontKickOps : public Module
|
||||
{
|
||||
CommandBSSetDontKickOps commandbssetdontkickops;
|
||||
|
||||
public:
|
||||
BSSetDontKickOps(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE),
|
||||
commandbssetdontkickops(this)
|
||||
{
|
||||
this->SetAuthor("Anope");
|
||||
}
|
||||
};
|
||||
|
||||
MODULE_INIT(BSSetDontKickOps)
|
||||
@@ -0,0 +1,90 @@
|
||||
/* BotServ core functions
|
||||
*
|
||||
* (C) 2003-2012 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"
|
||||
|
||||
class CommandBSSetDontKickVoices : public Command
|
||||
{
|
||||
public:
|
||||
CommandBSSetDontKickVoices(Module *creator, const Anope::string &sname = "botserv/set/dontkickvoices") : Command(creator, sname, 2, 2)
|
||||
{
|
||||
this->SetDesc(_("To protect voices against bot kicks"));
|
||||
this->SetSyntax(_("\037channel\037 {ON | OFF}"));
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
|
||||
{
|
||||
ChannelInfo *ci = cs_findchan(params[0]);
|
||||
if (ci == NULL)
|
||||
{
|
||||
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
AccessGroup access = source.AccessFor(ci);
|
||||
if (!source.HasPriv("botserv/administration") && !access.HasPriv("SET"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
}
|
||||
|
||||
if (readonly)
|
||||
{
|
||||
source.Reply(_("Sorry, bot option setting is temporarily disabled."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (params[1].equals_ci("ON"))
|
||||
{
|
||||
bool override = !access.HasPriv("SET");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enable dontkickvoices";
|
||||
|
||||
ci->botflags.SetFlag(BS_DONTKICKVOICES);
|
||||
source.Reply(_("Bot \002won't kick voices\002 on channel %s."), ci->name.c_str());
|
||||
}
|
||||
else if (params[1].equals_ci("OFF"))
|
||||
{
|
||||
bool override = !access.HasPriv("SET");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to disable dontkickvoices";
|
||||
|
||||
ci->botflags.UnsetFlag(BS_DONTKICKVOICES);
|
||||
source.Reply(_("Bot \002will kick voices\002 on channel %s."), ci->name.c_str());
|
||||
}
|
||||
else
|
||||
this->OnSyntaxError(source, source.command);
|
||||
}
|
||||
|
||||
bool OnHelp(CommandSource &source, const Anope::string &) anope_override
|
||||
{
|
||||
this->SendSyntax(source);
|
||||
source.Reply(_(" \n"
|
||||
"Enables or disables \002voices protection\002 mode on a channel.\n"
|
||||
"When it is enabled, voices won't be kicked by the bot\n"
|
||||
"even if they don't match the NOKICK level."));
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class BSSetDontKickVoices : public Module
|
||||
{
|
||||
CommandBSSetDontKickVoices commandbssetdontkickvoices;
|
||||
|
||||
public:
|
||||
BSSetDontKickVoices(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE),
|
||||
commandbssetdontkickvoices(this)
|
||||
{
|
||||
this->SetAuthor("Anope");
|
||||
}
|
||||
};
|
||||
|
||||
MODULE_INIT(BSSetDontKickVoices)
|
||||
@@ -0,0 +1,99 @@
|
||||
/* BotServ core functions
|
||||
*
|
||||
* (C) 2003-2012 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"
|
||||
|
||||
class CommandBSSetFantasy : public Command
|
||||
{
|
||||
public:
|
||||
CommandBSSetFantasy(Module *creator, const Anope::string &sname = "botserv/set/fantasy") : Command(creator, sname, 2, 2)
|
||||
{
|
||||
this->SetDesc(_("Enable fantaisist commands"));
|
||||
this->SetSyntax(_("\037channel\037 {\037ON|OFF\037}"));
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
|
||||
{
|
||||
ChannelInfo *ci = cs_findchan(params[0]);
|
||||
const Anope::string &value = params[1];
|
||||
|
||||
if (ci == NULL)
|
||||
{
|
||||
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!source.HasPriv("botserv/administration") && !source.AccessFor(ci).HasPriv("SET"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
}
|
||||
|
||||
if (readonly)
|
||||
{
|
||||
source.Reply(_("Sorry, bot option setting is temporarily disabled."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (value.equals_ci("ON"))
|
||||
{
|
||||
bool override = !source.AccessFor(ci).HasPriv("SET");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enable fantasy";
|
||||
|
||||
ci->botflags.SetFlag(BS_FANTASY);
|
||||
source.Reply(_("Fantasy mode is now \002on\002 on channel %s."), ci->name.c_str());
|
||||
}
|
||||
else if (value.equals_ci("OFF"))
|
||||
{
|
||||
bool override = !source.AccessFor(ci).HasPriv("SET");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to disable fantasy";
|
||||
|
||||
ci->botflags.UnsetFlag(BS_FANTASY);
|
||||
source.Reply(_("Fantasy mode is now \002off\002 on channel %s."), ci->name.c_str());
|
||||
}
|
||||
else
|
||||
this->OnSyntaxError(source, source.command);
|
||||
}
|
||||
|
||||
bool OnHelp(CommandSource &source, const Anope::string &) anope_override
|
||||
{
|
||||
this->SendSyntax(source);
|
||||
source.Reply(_(" \n"
|
||||
"Enables or disables \002fantasy\002 mode on a channel.\n"
|
||||
"When it is enabled, users will be able to use\n"
|
||||
"%s commands on a channel when prefixed\n"
|
||||
"with one of the following fantasy characters: \002%s\002\n"
|
||||
" \n"
|
||||
"Note that users wanting to use fantaisist\n"
|
||||
"commands MUST have enough level for both\n"
|
||||
"the FANTASIA and another level depending\n"
|
||||
"of the command if required (for example, to use \n"
|
||||
"!op, user must have enough access for the OPDEOP\n"
|
||||
"level)."), Config->ChanServ.c_str(), Config->BSFantasyCharacter.c_str());
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class BSSetFantasy : public Module
|
||||
{
|
||||
CommandBSSetFantasy commandbssetfantasy;
|
||||
|
||||
public:
|
||||
BSSetFantasy(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE),
|
||||
commandbssetfantasy(this)
|
||||
{
|
||||
this->SetAuthor("Anope");
|
||||
}
|
||||
};
|
||||
|
||||
MODULE_INIT(BSSetFantasy)
|
||||
@@ -0,0 +1,92 @@
|
||||
/* BotServ core functions
|
||||
*
|
||||
* (C) 2003-2012 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"
|
||||
|
||||
class CommandBSSetGreet : public Command
|
||||
{
|
||||
public:
|
||||
CommandBSSetGreet(Module *creator, const Anope::string &sname = "botserv/set/greet") : Command(creator, sname, 2, 2)
|
||||
{
|
||||
this->SetDesc(_("Enable greet messages"));
|
||||
this->SetSyntax(_("\037channel\037 {\037ON|OFF\037}"));
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
|
||||
{
|
||||
ChannelInfo *ci = cs_findchan(params[0]);
|
||||
const Anope::string &value = params[1];
|
||||
|
||||
if (ci == NULL)
|
||||
{
|
||||
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!source.HasPriv("botserv/administration") && !source.AccessFor(ci).HasPriv("SET"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
}
|
||||
|
||||
if (readonly)
|
||||
{
|
||||
source.Reply(_("Sorry, bot option setting is temporarily disabled."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (value.equals_ci("ON"))
|
||||
{
|
||||
bool override = !source.AccessFor(ci).HasPriv("SET");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to enable greets";
|
||||
|
||||
ci->botflags.SetFlag(BS_GREET);
|
||||
source.Reply(_("Greet mode is now \002on\002 on channel %s."), ci->name.c_str());
|
||||
}
|
||||
else if (value.equals_ci("OFF"))
|
||||
{
|
||||
bool override = !source.AccessFor(ci).HasPriv("SET");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to disable greets";
|
||||
|
||||
ci->botflags.UnsetFlag(BS_GREET);
|
||||
source.Reply(_("Greet mode is now \002off\002 on channel %s."), ci->name.c_str());
|
||||
}
|
||||
else
|
||||
this->OnSyntaxError(source, source.command);
|
||||
}
|
||||
|
||||
bool OnHelp(CommandSource &source, const Anope::string &) anope_override
|
||||
{
|
||||
this->SendSyntax(source);
|
||||
source.Reply(_(" \n"
|
||||
"Enables or disables \002greet\002 mode on a channel.\n"
|
||||
"When it is enabled, the bot will display greet\n"
|
||||
"messages of users joining the channel, provided\n"
|
||||
"they have enough access to the channel."));
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class BSSetGreet : public Module
|
||||
{
|
||||
CommandBSSetGreet commandbssetgreet;
|
||||
|
||||
public:
|
||||
BSSetGreet(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE),
|
||||
commandbssetgreet(this)
|
||||
{
|
||||
this->SetAuthor("Anope");
|
||||
}
|
||||
};
|
||||
|
||||
MODULE_INIT(BSSetGreet)
|
||||
@@ -0,0 +1,87 @@
|
||||
/* BotServ core functions
|
||||
*
|
||||
* (C) 2003-2012 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"
|
||||
|
||||
class CommandBSSetNoBot : public Command
|
||||
{
|
||||
public:
|
||||
CommandBSSetNoBot(Module *creator, const Anope::string &sname = "botserv/set/nobot") : Command(creator, sname, 2, 2)
|
||||
{
|
||||
this->SetDesc(_("Prevent a bot from being assigned to a channel"));
|
||||
this->SetSyntax(_("\037channel\037 {\037ON|OFF\037}"));
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
|
||||
{
|
||||
ChannelInfo *ci = cs_findchan(params[0]);
|
||||
const Anope::string &value = params[1];
|
||||
|
||||
if (ci == NULL)
|
||||
{
|
||||
source.Reply(CHAN_X_NOT_REGISTERED, params[0].c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!source.HasCommand("botserv/set/nobot"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
}
|
||||
|
||||
if (value.equals_ci("ON"))
|
||||
{
|
||||
bool override = !source.AccessFor(ci).HasPriv("SET");
|
||||
Log(override ? LOG_ADMIN : LOG_COMMAND, source, this, ci) << "to enable nobot";
|
||||
|
||||
ci->botflags.SetFlag(BS_NOBOT);
|
||||
if (ci->bi)
|
||||
ci->bi->UnAssign(source.GetUser(), ci);
|
||||
source.Reply(_("No Bot mode is now \002on\002 on channel %s."), ci->name.c_str());
|
||||
}
|
||||
else if (value.equals_ci("OFF"))
|
||||
{
|
||||
bool override = !source.AccessFor(ci).HasPriv("SET");
|
||||
Log(override ? LOG_ADMIN : LOG_COMMAND, source, this, ci) << "to disable nobot";
|
||||
|
||||
ci->botflags.UnsetFlag(BS_NOBOT);
|
||||
source.Reply(_("No Bot mode is now \002off\002 on channel %s."), ci->name.c_str());
|
||||
}
|
||||
else
|
||||
this->OnSyntaxError(source, source.command);
|
||||
}
|
||||
|
||||
bool OnHelp(CommandSource &source, const Anope::string &) anope_override
|
||||
{
|
||||
this->SendSyntax(source);
|
||||
source.Reply(_(" \n"
|
||||
"This option makes a channel be unassignable. If a bot \n"
|
||||
"is already assigned to the channel, it is unassigned\n"
|
||||
"automatically when you enable the option."));
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class BSSetNoBot : public Module
|
||||
{
|
||||
CommandBSSetNoBot commandbssetnobot;
|
||||
|
||||
public:
|
||||
BSSetNoBot(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE),
|
||||
commandbssetnobot(this)
|
||||
{
|
||||
this->SetAuthor("Anope");
|
||||
}
|
||||
};
|
||||
|
||||
MODULE_INIT(BSSetNoBot)
|
||||
@@ -0,0 +1,78 @@
|
||||
/* BotServ core functions
|
||||
*
|
||||
* (C) 2003-2012 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"
|
||||
|
||||
class CommandBSSetPrivate : public Command
|
||||
{
|
||||
public:
|
||||
CommandBSSetPrivate(Module *creator, const Anope::string &sname = "botserv/set/private") : Command(creator, sname, 2, 2)
|
||||
{
|
||||
this->SetDesc(_("Prevent a bot from being assigned by non IRC operators"));
|
||||
this->SetSyntax(_("\037botname\037 {\037ON|OFF\037}"));
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
|
||||
{
|
||||
BotInfo *bi = findbot(params[0]);
|
||||
const Anope::string &value = params[1];
|
||||
|
||||
if (bi == NULL)
|
||||
{
|
||||
source.Reply(BOT_DOES_NOT_EXIST, params[0].c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
if (!source.HasCommand("botserv/set/private"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
}
|
||||
|
||||
if (value.equals_ci("ON"))
|
||||
{
|
||||
bi->SetFlag(BI_PRIVATE);
|
||||
source.Reply(_("Private mode of bot %s is now \002on\002."), bi->nick.c_str());
|
||||
}
|
||||
else if (value.equals_ci("OFF"))
|
||||
{
|
||||
bi->UnsetFlag(BI_PRIVATE);
|
||||
source.Reply(_("Private mode of bot %s is now \002off\002."), bi->nick.c_str());
|
||||
}
|
||||
else
|
||||
this->OnSyntaxError(source, source.command);
|
||||
}
|
||||
|
||||
bool OnHelp(CommandSource &source, const Anope::string &) anope_override
|
||||
{
|
||||
this->SendSyntax(source);
|
||||
source.Reply(_(" \n"
|
||||
"This option prevents a bot from being assigned to a\n"
|
||||
"channel by users that aren't IRC operators."));
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class BSSetPrivate : public Module
|
||||
{
|
||||
CommandBSSetPrivate commandbssetprivate;
|
||||
|
||||
public:
|
||||
BSSetPrivate(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE),
|
||||
commandbssetprivate(this)
|
||||
{
|
||||
this->SetAuthor("Anope");
|
||||
}
|
||||
};
|
||||
|
||||
MODULE_INIT(BSSetPrivate)
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
static std::map<Anope::string, int16_t, ci::less> defaultLevels;
|
||||
|
||||
static void reset_levels(ChannelInfo *ci)
|
||||
static inline void reset_levels(ChannelInfo *ci)
|
||||
{
|
||||
ci->ClearLevels();
|
||||
for (std::map<Anope::string, int16_t, ci::less>::iterator it = defaultLevels.begin(), it_end = defaultLevels.end(); it != it_end; ++it)
|
||||
@@ -31,26 +31,26 @@ class AccessChanAccess : public ChanAccess
|
||||
{
|
||||
}
|
||||
|
||||
bool HasPriv(const Anope::string &name) const
|
||||
bool HasPriv(const Anope::string &name) const anope_override
|
||||
{
|
||||
return this->ci->GetLevel(name) != ACCESS_INVALID && this->level >= this->ci->GetLevel(name);
|
||||
}
|
||||
|
||||
Anope::string Serialize()
|
||||
Anope::string Serialize() const
|
||||
{
|
||||
return stringify(this->level);
|
||||
}
|
||||
|
||||
void Unserialize(const Anope::string &data)
|
||||
void Unserialize(const Anope::string &data) anope_override
|
||||
{
|
||||
this->level = convertTo<int>(data);
|
||||
}
|
||||
|
||||
static int DetermineLevel(ChanAccess *access)
|
||||
static int DetermineLevel(const ChanAccess *access)
|
||||
{
|
||||
if (access->provider->name == "access/access")
|
||||
{
|
||||
AccessChanAccess *aaccess = debug_cast<AccessChanAccess *>(access);
|
||||
const AccessChanAccess *aaccess = anope_dynamic_static_cast<const AccessChanAccess *>(access);
|
||||
return aaccess->level;
|
||||
}
|
||||
else
|
||||
@@ -80,7 +80,7 @@ class AccessAccessProvider : public AccessProvider
|
||||
{
|
||||
}
|
||||
|
||||
ChanAccess *Create()
|
||||
ChanAccess *Create() anope_override
|
||||
{
|
||||
return new AccessChanAccess(this);
|
||||
}
|
||||
@@ -90,8 +90,6 @@ class CommandCSAccess : public Command
|
||||
{
|
||||
void DoAdd(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
User *u = source.u;
|
||||
|
||||
Anope::string mask = params[2];
|
||||
int level = ACCESS_INVALID;
|
||||
|
||||
@@ -106,33 +104,51 @@ class CommandCSAccess : public Command
|
||||
source.Reply(_("Access level must be non-zero."));
|
||||
return;
|
||||
}
|
||||
|
||||
AccessGroup u_access = ci->AccessFor(u);
|
||||
ChanAccess *highest = u_access.Highest();
|
||||
int u_level = (highest ? AccessChanAccess::DetermineLevel(highest) : 0);
|
||||
if (level >= u_level && !u_access.Founder && !u->HasPriv("chanserv/access/modify"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
}
|
||||
else if (level <= ACCESS_INVALID || level >= ACCESS_FOUNDER)
|
||||
{
|
||||
source.Reply(CHAN_ACCESS_LEVEL_RANGE, ACCESS_INVALID + 1, ACCESS_FOUNDER - 1);
|
||||
return;
|
||||
}
|
||||
|
||||
bool override = !ci->AccessFor(u).HasPriv("ACCESS_CHANGE") || (level >= u_level && !u_access.Founder);
|
||||
AccessGroup u_access = source.AccessFor(ci);
|
||||
const ChanAccess *highest = u_access.Highest();
|
||||
|
||||
if (mask.find_first_of("!*@") == Anope::string::npos && findnick(mask) == NULL)
|
||||
mask += "!*@*";
|
||||
AccessChanAccess tmp_access(NULL);
|
||||
tmp_access.ci = ci;
|
||||
tmp_access.level = level;
|
||||
|
||||
bool override = false;
|
||||
|
||||
if ((!highest || *highest <= tmp_access) && !u_access.Founder)
|
||||
{
|
||||
if (source.HasPriv("chanserv/access/modify"))
|
||||
override = true;
|
||||
else
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (mask.find_first_of("!*@") == Anope::string::npos && !findnick(mask))
|
||||
{
|
||||
User *targ = finduser(mask);
|
||||
if (targ != NULL)
|
||||
mask = "*!*@" + targ->GetDisplayedHost();
|
||||
else
|
||||
{
|
||||
source.Reply(NICK_X_NOT_REGISTERED, mask.c_str());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (unsigned i = ci->GetAccessCount(); i > 0; --i)
|
||||
{
|
||||
ChanAccess *access = ci->GetAccess(i - 1);
|
||||
const ChanAccess *access = ci->GetAccess(i - 1);
|
||||
if (mask.equals_ci(access->mask))
|
||||
{
|
||||
/* Don't allow lowering from a level >= u_level */
|
||||
if (AccessChanAccess::DetermineLevel(access) >= u_level && !u_access.Founder && !u->HasPriv("chanserv/access/modify"))
|
||||
if ((!highest || *access >= *highest) && !u_access.Founder && !source.HasPriv("chanserv/access/modify"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
@@ -151,18 +167,18 @@ class CommandCSAccess : public Command
|
||||
service_reference<AccessProvider> provider("AccessProvider", "access/access");
|
||||
if (!provider)
|
||||
return;
|
||||
AccessChanAccess *access = debug_cast<AccessChanAccess *>(provider->Create());
|
||||
AccessChanAccess *access = anope_dynamic_static_cast<AccessChanAccess *>(provider->Create());
|
||||
access->ci = ci;
|
||||
access->mask = mask;
|
||||
access->creator = u->nick;
|
||||
access->creator = source.GetNick();
|
||||
access->level = level;
|
||||
access->last_seen = 0;
|
||||
access->created = Anope::CurTime;
|
||||
ci->AddAccess(access);
|
||||
|
||||
FOREACH_MOD(I_OnAccessAdd, OnAccessAdd(ci, u, access));
|
||||
FOREACH_MOD(I_OnAccessAdd, OnAccessAdd(ci, source, access));
|
||||
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to add " << mask << " with level " << level;
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to add " << mask << " with level " << level;
|
||||
source.Reply(_("\002%s\002 added to %s access list at level \002%d\002."), access->mask.c_str(), ci->name.c_str(), level);
|
||||
|
||||
return;
|
||||
@@ -170,8 +186,6 @@ class CommandCSAccess : public Command
|
||||
|
||||
void DoDel(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
User *u = source.u;
|
||||
|
||||
const Anope::string &mask = params[2];
|
||||
|
||||
if (!ci->GetAccessCount())
|
||||
@@ -190,7 +204,7 @@ class CommandCSAccess : public Command
|
||||
public:
|
||||
AccessDelCallback(CommandSource &_source, ChannelInfo *_ci, Command *_c, const Anope::string &numlist) : NumberList(numlist, true), source(_source), ci(_ci), c(_c), Deleted(0), Denied(false), override(false)
|
||||
{
|
||||
if (!ci->AccessFor(source.u).HasPriv("ACCESS_CHANGE") && source.u->HasPriv("chanserv/access/modify"))
|
||||
if (!source.AccessFor(ci).HasPriv("ACCESS_CHANGE") && source.HasPriv("chanserv/access/modify"))
|
||||
this->override = true;
|
||||
}
|
||||
|
||||
@@ -202,7 +216,7 @@ class CommandCSAccess : public Command
|
||||
source.Reply(_("No matching entries on %s access list."), ci->name.c_str());
|
||||
else
|
||||
{
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source.u, c, ci) << "to delete " << Nicks;
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, c, ci) << "to delete " << Nicks;
|
||||
|
||||
if (Deleted == 1)
|
||||
source.Reply(_("Deleted 1 entry from %s access list."), ci->name.c_str());
|
||||
@@ -211,19 +225,17 @@ class CommandCSAccess : public Command
|
||||
}
|
||||
}
|
||||
|
||||
void HandleNumber(unsigned Number)
|
||||
void HandleNumber(unsigned Number) anope_override
|
||||
{
|
||||
if (!Number || Number > ci->GetAccessCount())
|
||||
return;
|
||||
|
||||
User *user = source.u;
|
||||
|
||||
ChanAccess *access = ci->GetAccess(Number - 1);
|
||||
|
||||
AccessGroup u_access = ci->AccessFor(user);
|
||||
ChanAccess *u_highest = u_access.Highest();
|
||||
AccessGroup u_access = source.AccessFor(ci);
|
||||
const ChanAccess *u_highest = u_access.Highest();
|
||||
|
||||
if ((u_highest ? AccessChanAccess::DetermineLevel(u_highest) : 0) <= AccessChanAccess::DetermineLevel(access) && !u_access.Founder && !this->override && !access->mask.equals_ci(user->Account()->display))
|
||||
if ((!u_highest || *u_highest <= *access) && !u_access.Founder && !this->override && !access->mask.equals_ci(source.nc->display))
|
||||
{
|
||||
Denied = true;
|
||||
return;
|
||||
@@ -235,7 +247,7 @@ class CommandCSAccess : public Command
|
||||
else
|
||||
Nicks = access->mask;
|
||||
|
||||
FOREACH_MOD(I_OnAccessDel, OnAccessDel(ci, user, access));
|
||||
FOREACH_MOD(I_OnAccessDel, OnAccessDel(ci, source, access));
|
||||
|
||||
ci->EraseAccess(Number - 1);
|
||||
}
|
||||
@@ -245,25 +257,23 @@ class CommandCSAccess : public Command
|
||||
}
|
||||
else
|
||||
{
|
||||
AccessGroup u_access = ci->AccessFor(u);
|
||||
ChanAccess *highest = u_access.Highest();
|
||||
int u_level = (highest ? AccessChanAccess::DetermineLevel(highest) : 0);
|
||||
AccessGroup u_access = source.AccessFor(ci);
|
||||
const ChanAccess *highest = u_access.Highest();
|
||||
|
||||
for (unsigned i = ci->GetAccessCount(); i > 0; --i)
|
||||
{
|
||||
ChanAccess *access = ci->GetAccess(i - 1);
|
||||
if (mask.equals_ci(access->mask))
|
||||
{
|
||||
int access_level = AccessChanAccess::DetermineLevel(access);
|
||||
if (!access->mask.equals_ci(u->Account()->display) && !u_access.Founder && u_level <= access_level && !u->HasPriv("chanserv/access/modify"))
|
||||
if (!access->mask.equals_ci(source.nc->display) && !u_access.Founder && (!highest || *highest <= *access) && !source.HasPriv("chanserv/access/modify"))
|
||||
source.Reply(ACCESS_DENIED);
|
||||
else
|
||||
{
|
||||
source.Reply(_("\002%s\002 deleted from %s access list."), access->mask.c_str(), ci->name.c_str());
|
||||
bool override = !u_access.Founder && !u_access.HasPriv("ACCESS_CHANGE") && !access->mask.equals_ci(u->Account()->display);
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to delete " << access->mask;
|
||||
bool override = !u_access.Founder && !u_access.HasPriv("ACCESS_CHANGE") && !access->mask.equals_ci(source.nc->display);
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to delete " << access->mask;
|
||||
|
||||
FOREACH_MOD(I_OnAccessDel, OnAccessDel(ci, u, access));
|
||||
FOREACH_MOD(I_OnAccessDel, OnAccessDel(ci, source, access));
|
||||
ci->EraseAccess(access);
|
||||
}
|
||||
return;
|
||||
@@ -294,12 +304,12 @@ class CommandCSAccess : public Command
|
||||
{
|
||||
}
|
||||
|
||||
void HandleNumber(unsigned number)
|
||||
void HandleNumber(unsigned number) anope_override
|
||||
{
|
||||
if (!number || number > ci->GetAccessCount())
|
||||
return;
|
||||
|
||||
ChanAccess *access = ci->GetAccess(number - 1);
|
||||
const ChanAccess *access = ci->GetAccess(number - 1);
|
||||
|
||||
Anope::string timebuf;
|
||||
if (ci->c)
|
||||
@@ -330,7 +340,7 @@ class CommandCSAccess : public Command
|
||||
{
|
||||
for (unsigned i = 0, end = ci->GetAccessCount(); i < end; ++i)
|
||||
{
|
||||
ChanAccess *access = ci->GetAccess(i);
|
||||
const ChanAccess *access = ci->GetAccess(i);
|
||||
|
||||
if (!nick.empty() && !Anope::Match(access->mask, nick))
|
||||
continue;
|
||||
@@ -404,20 +414,18 @@ class CommandCSAccess : public Command
|
||||
|
||||
void DoClear(CommandSource &source, ChannelInfo *ci)
|
||||
{
|
||||
User *u = source.u;
|
||||
|
||||
if (!IsFounder(u, ci) && !u->HasPriv("chanserv/access/modify"))
|
||||
if (!source.IsFounder(ci) && !source.HasPriv("chanserv/access/modify"))
|
||||
source.Reply(ACCESS_DENIED);
|
||||
else
|
||||
{
|
||||
FOREACH_MOD(I_OnAccessClear, OnAccessClear(ci, u));
|
||||
FOREACH_MOD(I_OnAccessClear, OnAccessClear(ci, source));
|
||||
|
||||
ci->ClearAccess();
|
||||
|
||||
source.Reply(_("Channel %s access list has been cleared."), ci->name.c_str());
|
||||
|
||||
bool override = !IsFounder(u, ci);
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to clear the access list";
|
||||
bool override = !source.IsFounder(ci);
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to clear the access list";
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -431,16 +439,15 @@ class CommandCSAccess : public Command
|
||||
this->SetSyntax(_("\037channel\037 DEL {\037mask\037 | \037entry-num\037 | \037list\037}"));
|
||||
this->SetSyntax(_("\037channel\037 LIST [\037mask\037 | \037list\037]"));
|
||||
this->SetSyntax(_("\037channel\037 VIEW [\037mask\037 | \037list\037]"));
|
||||
this->SetSyntax(_("\037channel\037 CLEAR\002"));
|
||||
this->SetSyntax(_("\037channel\037 CLEAR"));
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms)
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
|
||||
{
|
||||
const Anope::string &cmd = params[1];
|
||||
const Anope::string &nick = params.size() > 2 ? params[2] : "";
|
||||
const Anope::string &s = params.size() > 3 ? params[3] : "";
|
||||
|
||||
User *u = source.u;
|
||||
ChannelInfo *ci = cs_findchan(params[0]);
|
||||
if (ci == NULL)
|
||||
{
|
||||
@@ -453,16 +460,16 @@ class CommandCSAccess : public Command
|
||||
bool is_del = cmd.equals_ci("DEL");
|
||||
|
||||
bool has_access = false;
|
||||
if (u->HasPriv("chanserv/access/modify"))
|
||||
if (source.HasPriv("chanserv/access/modify"))
|
||||
has_access = true;
|
||||
else if (is_list && ci->AccessFor(u).HasPriv("ACCESS_LIST"))
|
||||
else if (is_list && source.AccessFor(ci).HasPriv("ACCESS_LIST"))
|
||||
has_access = true;
|
||||
else if (ci->AccessFor(u).HasPriv("ACCESS_CHANGE"))
|
||||
else if (source.AccessFor(ci).HasPriv("ACCESS_CHANGE"))
|
||||
has_access = true;
|
||||
else if (is_del)
|
||||
{
|
||||
NickAlias *na = findnick(nick);
|
||||
if (na && na->nc == u->Account())
|
||||
const NickAlias *na = findnick(nick);
|
||||
if (na && na->nc == source.nc)
|
||||
has_access = true;
|
||||
}
|
||||
|
||||
@@ -491,7 +498,7 @@ class CommandCSAccess : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand)
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
|
||||
{
|
||||
this->SendSyntax(source);
|
||||
source.Reply(" ");
|
||||
@@ -559,8 +566,6 @@ class CommandCSLevels : public Command
|
||||
{
|
||||
void DoSet(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
User *u = source.u;
|
||||
|
||||
const Anope::string &what = params[2];
|
||||
const Anope::string &lev = params[3];
|
||||
|
||||
@@ -591,10 +596,10 @@ class CommandCSLevels : public Command
|
||||
else
|
||||
{
|
||||
ci->SetLevel(p->name, level);
|
||||
FOREACH_MOD(I_OnLevelChange, OnLevelChange(u, ci, p->name, level));
|
||||
FOREACH_MOD(I_OnLevelChange, OnLevelChange(source, ci, p->name, level));
|
||||
|
||||
bool override = !ci->AccessFor(u).HasPriv("FOUNDER");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to set " << p->name << " to level " << level;
|
||||
bool override = !source.AccessFor(ci).HasPriv("FOUNDER");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to set " << p->name << " to level " << level;
|
||||
|
||||
if (level == ACCESS_FOUNDER)
|
||||
source.Reply(_("Level for %s on channel %s changed to founder only."), p->name.c_str(), ci->name.c_str());
|
||||
@@ -606,8 +611,6 @@ class CommandCSLevels : public Command
|
||||
|
||||
void DoDisable(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
User *u = source.u;
|
||||
|
||||
const Anope::string &what = params[2];
|
||||
|
||||
/* Don't allow disabling of the founder level. It would be hard to change it back if you dont have access to use this command */
|
||||
@@ -617,10 +620,10 @@ class CommandCSLevels : public Command
|
||||
if (p != NULL)
|
||||
{
|
||||
ci->SetLevel(p->name, ACCESS_INVALID);
|
||||
FOREACH_MOD(I_OnLevelChange, OnLevelChange(u, ci, p->name, ACCESS_INVALID));
|
||||
FOREACH_MOD(I_OnLevelChange, OnLevelChange(source, ci, p->name, ACCESS_INVALID));
|
||||
|
||||
bool override = !ci->AccessFor(u).HasPriv("FOUNDER");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to disable " << p->name;
|
||||
bool override = !source.AccessFor(ci).HasPriv("FOUNDER");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to disable " << p->name;
|
||||
|
||||
source.Reply(_("\002%s\002 disabled on channel %s."), p->name.c_str(), ci->name.c_str());
|
||||
return;
|
||||
@@ -668,13 +671,11 @@ class CommandCSLevels : public Command
|
||||
|
||||
void DoReset(CommandSource &source, ChannelInfo *ci)
|
||||
{
|
||||
User *u = source.u;
|
||||
|
||||
reset_levels(ci);
|
||||
FOREACH_MOD(I_OnLevelChange, OnLevelChange(u, ci, "ALL", 0));
|
||||
FOREACH_MOD(I_OnLevelChange, OnLevelChange(source, ci, "ALL", 0));
|
||||
|
||||
bool override = !ci->AccessFor(u).HasPriv("FOUNDER");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to reset all levels";
|
||||
bool override = !source.AccessFor(ci).HasPriv("FOUNDER");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to reset all levels";
|
||||
|
||||
source.Reply(_("Access levels for \002%s\002 reset to defaults."), ci->name.c_str());
|
||||
return;
|
||||
@@ -690,14 +691,12 @@ class CommandCSLevels : public Command
|
||||
this->SetSyntax(_("\037channel\037 RESET"));
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms)
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
|
||||
{
|
||||
const Anope::string &cmd = params[1];
|
||||
const Anope::string &what = params.size() > 2 ? params[2] : "";
|
||||
const Anope::string &s = params.size() > 3 ? params[3] : "";
|
||||
|
||||
User *u = source.u;
|
||||
|
||||
ChannelInfo *ci = cs_findchan(params[0]);
|
||||
if (ci == NULL)
|
||||
{
|
||||
@@ -710,7 +709,7 @@ class CommandCSLevels : public Command
|
||||
*/
|
||||
if (cmd.equals_ci("SET") ? s.empty() : (cmd.substr(0, 3).equals_ci("DIS") ? (what.empty() || !s.empty()) : !what.empty()))
|
||||
this->OnSyntaxError(source, cmd);
|
||||
else if (!ci->AccessFor(u).HasPriv("FOUNDER") && !u->HasPriv("chanserv/access/modify"))
|
||||
else if (!source.AccessFor(ci).HasPriv("FOUNDER") && !source.HasPriv("chanserv/access/modify"))
|
||||
source.Reply(ACCESS_DENIED);
|
||||
else if (cmd.equals_ci("SET"))
|
||||
this->DoSet(source, ci, params);
|
||||
@@ -726,7 +725,7 @@ class CommandCSLevels : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand)
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
|
||||
{
|
||||
if (subcommand.equals_ci("DESC"))
|
||||
{
|
||||
@@ -741,7 +740,7 @@ class CommandCSLevels : public Command
|
||||
const Privilege &p = privs[i];
|
||||
ListFormatter::ListEntry entry;
|
||||
entry["Name"] = p.name;
|
||||
entry["Description"] = translate(source.u, p.desc.c_str());
|
||||
entry["Description"] = translate(source.nc, p.desc.c_str());
|
||||
list.addEntry(entry);
|
||||
}
|
||||
|
||||
@@ -804,7 +803,7 @@ class CSAccess : public Module
|
||||
}
|
||||
}
|
||||
|
||||
void OnReload()
|
||||
void OnReload() anope_override
|
||||
{
|
||||
defaultLevels.clear();
|
||||
ConfigReader config;
|
||||
@@ -829,12 +828,12 @@ class CSAccess : public Module
|
||||
}
|
||||
}
|
||||
|
||||
void OnCreateChan(ChannelInfo *ci)
|
||||
void OnCreateChan(ChannelInfo *ci) anope_override
|
||||
{
|
||||
reset_levels(ci);
|
||||
}
|
||||
|
||||
EventReturn OnGroupCheckPriv(const AccessGroup *group, const Anope::string &priv)
|
||||
EventReturn OnGroupCheckPriv(const AccessGroup *group, const Anope::string &priv) anope_override
|
||||
{
|
||||
if (group->ci == NULL)
|
||||
return EVENT_CONTINUE;
|
||||
|
||||
@@ -50,13 +50,11 @@ class CommandCSAKick : public Command
|
||||
{
|
||||
void DoAdd(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
User *u = source.u;
|
||||
|
||||
Anope::string mask = params[2];
|
||||
Anope::string reason = params.size() > 3 ? params[3] : "";
|
||||
NickAlias *na = findnick(mask);
|
||||
const NickAlias *na = findnick(mask);
|
||||
NickCore *nc = NULL;
|
||||
AutoKick *akick;
|
||||
const AutoKick *akick;
|
||||
|
||||
if (!na)
|
||||
{
|
||||
@@ -86,7 +84,7 @@ class CommandCSAKick : public Command
|
||||
* or whether the mask matches a user with higher/equal access - Viper */
|
||||
if (ci->HasFlag(CI_PEACE) && nc)
|
||||
{
|
||||
AccessGroup nc_access = ci->AccessFor(nc), u_access = ci->AccessFor(u);
|
||||
AccessGroup nc_access = ci->AccessFor(nc), u_access = source.AccessFor(ci);
|
||||
if (nc == ci->GetFounder() || nc_access >= u_access)
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
@@ -101,7 +99,7 @@ class CommandCSAKick : public Command
|
||||
{
|
||||
User *u2 = it->second;
|
||||
|
||||
AccessGroup nc_access = ci->AccessFor(nc), u_access = ci->AccessFor(u);
|
||||
AccessGroup nc_access = ci->AccessFor(nc), u_access = source.AccessFor(ci);
|
||||
Entry entry_mask(CMODE_BEGIN, mask);
|
||||
|
||||
if ((ci->AccessFor(u2).HasPriv("FOUNDER") || nc_access >= u_access) && entry_mask.Matches(u2))
|
||||
@@ -113,11 +111,11 @@ class CommandCSAKick : public Command
|
||||
|
||||
/* Match against the lastusermask of all nickalias's with equal
|
||||
* or higher access. - Viper */
|
||||
for (nickalias_map::const_iterator it = NickAliasList.begin(), it_end = NickAliasList.end(); it != it_end; ++it)
|
||||
for (nickalias_map::const_iterator it = NickAliasList->begin(), it_end = NickAliasList->end(); it != it_end; ++it)
|
||||
{
|
||||
na = it->second;
|
||||
|
||||
AccessGroup nc_access = ci->AccessFor(na->nc), u_access = ci->AccessFor(u);
|
||||
AccessGroup nc_access = ci->AccessFor(na->nc), u_access = source.AccessFor(ci);
|
||||
if (na->nc && (na->nc == ci->GetFounder() || nc_access >= u_access))
|
||||
{
|
||||
Anope::string buf = na->nick + "!" + na->last_usermask;
|
||||
@@ -147,14 +145,14 @@ class CommandCSAKick : public Command
|
||||
}
|
||||
|
||||
if (nc)
|
||||
akick = ci->AddAkick(u->nick, nc, reason);
|
||||
akick = ci->AddAkick(source.GetNick(), nc, reason);
|
||||
else
|
||||
akick = ci->AddAkick(u->nick, mask, reason);
|
||||
akick = ci->AddAkick(source.GetNick(), mask, reason);
|
||||
|
||||
bool override = !ci->AccessFor(u).HasPriv("AKICK");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to add " << mask << (reason == "" ? "" : ": ") << reason;
|
||||
bool override = !source.AccessFor(ci).HasPriv("AKICK");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to add " << mask << (reason == "" ? "" : ": ") << reason;
|
||||
|
||||
FOREACH_MOD(I_OnAkickAdd, OnAkickAdd(u, ci, akick));
|
||||
FOREACH_MOD(I_OnAkickAdd, OnAkickAdd(source, ci, akick));
|
||||
|
||||
source.Reply(_("\002%s\002 added to %s autokick list."), mask.c_str(), ci->name.c_str());
|
||||
|
||||
@@ -163,10 +161,7 @@ class CommandCSAKick : public Command
|
||||
|
||||
void DoDel(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
User *u = source.u;
|
||||
|
||||
const Anope::string &mask = params[2];
|
||||
AutoKick *akick;
|
||||
unsigned i, end;
|
||||
|
||||
if (!ci->GetAkickCount())
|
||||
@@ -191,8 +186,8 @@ class CommandCSAKick : public Command
|
||||
|
||||
~AkickDelCallback()
|
||||
{
|
||||
bool override = !ci->AccessFor(source.u).HasPriv("AKICK");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source.u, c, ci) << "to delete " << Deleted << (Deleted == 1 ? " entry" : " entries");
|
||||
bool override = !source.AccessFor(ci).HasPriv("AKICK");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, c, ci) << "to delete " << Deleted << (Deleted == 1 ? " entry" : " entries");
|
||||
|
||||
if (!Deleted)
|
||||
source.Reply(_("No matching entries on %s autokick list."), ci->name.c_str());
|
||||
@@ -202,11 +197,13 @@ class CommandCSAKick : public Command
|
||||
source.Reply(_("Deleted %d entries from %s autokick list."), Deleted, ci->name.c_str());
|
||||
}
|
||||
|
||||
void HandleNumber(unsigned Number)
|
||||
void HandleNumber(unsigned Number) anope_override
|
||||
{
|
||||
if (!Number || Number > ci->GetAkickCount())
|
||||
return;
|
||||
|
||||
FOREACH_MOD(I_OnAkickDel, OnAkickDel(source, ci, ci->GetAkick(Number - 1)));
|
||||
|
||||
++Deleted;
|
||||
ci->EraseAkick(Number - 1);
|
||||
}
|
||||
@@ -216,12 +213,12 @@ class CommandCSAKick : public Command
|
||||
}
|
||||
else
|
||||
{
|
||||
NickAlias *na = findnick(mask);
|
||||
NickCore *nc = na ? na->nc : NULL;
|
||||
const NickAlias *na = findnick(mask);
|
||||
const NickCore *nc = na ? *na->nc : NULL;
|
||||
|
||||
for (i = 0, end = ci->GetAkickCount(); i < end; ++i)
|
||||
{
|
||||
akick = ci->GetAkick(i);
|
||||
const AutoKick *akick = ci->GetAkick(i);
|
||||
|
||||
if ((akick->HasFlag(AK_ISNICK) && akick->nc == nc) || (!akick->HasFlag(AK_ISNICK) && mask.equals_ci(akick->mask)))
|
||||
break;
|
||||
@@ -233,8 +230,10 @@ class CommandCSAKick : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
bool override = !ci->AccessFor(u).HasPriv("AKICK");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to delete " << mask;
|
||||
bool override = !source.AccessFor(ci).HasPriv("AKICK");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to delete " << mask;
|
||||
|
||||
FOREACH_MOD(I_OnAkickDel, OnAkickDel(source, ci, ci->GetAkick(i)));
|
||||
|
||||
ci->EraseAkick(i);
|
||||
|
||||
@@ -258,12 +257,12 @@ class CommandCSAKick : public Command
|
||||
{
|
||||
}
|
||||
|
||||
void HandleNumber(unsigned number)
|
||||
void HandleNumber(unsigned number) anope_override
|
||||
{
|
||||
if (!number || number > ci->GetAkickCount())
|
||||
return;
|
||||
|
||||
AutoKick *akick = ci->GetAkick(number - 1);
|
||||
const AutoKick *akick = ci->GetAkick(number - 1);
|
||||
|
||||
Anope::string timebuf, lastused;
|
||||
if (akick->addtime)
|
||||
@@ -292,7 +291,7 @@ class CommandCSAKick : public Command
|
||||
{
|
||||
for (unsigned i = 0, end = ci->GetAkickCount(); i < end; ++i)
|
||||
{
|
||||
AutoKick *akick = ci->GetAkick(i);
|
||||
const AutoKick *akick = ci->GetAkick(i);
|
||||
|
||||
if (!mask.empty())
|
||||
{
|
||||
@@ -367,7 +366,6 @@ class CommandCSAKick : public Command
|
||||
|
||||
void DoEnforce(CommandSource &source, ChannelInfo *ci)
|
||||
{
|
||||
User *u = source.u;
|
||||
Channel *c = ci->c;
|
||||
int count = 0;
|
||||
|
||||
@@ -385,17 +383,16 @@ class CommandCSAKick : public Command
|
||||
++count;
|
||||
}
|
||||
|
||||
bool override = !ci->AccessFor(u).HasPriv("AKICK");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "ENFORCE, affects " << count << " users";
|
||||
bool override = !source.AccessFor(ci).HasPriv("AKICK");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "ENFORCE, affects " << count << " users";
|
||||
|
||||
source.Reply(_("AKICK ENFORCE for \002%s\002 complete; \002%d\002 users were affected."), ci->name.c_str(), count);
|
||||
}
|
||||
|
||||
void DoClear(CommandSource &source, ChannelInfo *ci)
|
||||
{
|
||||
User *u = source.u;
|
||||
bool override = !ci->AccessFor(u).HasPriv("AKICK");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to clear the akick list";
|
||||
bool override = !source.AccessFor(ci).HasPriv("AKICK");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to clear the akick list";
|
||||
|
||||
ci->ClearAkick();
|
||||
source.Reply(_("Channel %s akick list has been cleared."), ci->name.c_str());
|
||||
@@ -413,14 +410,12 @@ class CommandCSAKick : public Command
|
||||
this->SetSyntax(_("\037channel\037 CLEAR"));
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms)
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
|
||||
{
|
||||
Anope::string chan = params[0];
|
||||
Anope::string cmd = params[1];
|
||||
Anope::string mask = params.size() > 2 ? params[2] : "";
|
||||
|
||||
User *u = source.u;
|
||||
|
||||
ChannelInfo *ci = cs_findchan(params[0]);
|
||||
if (ci == NULL)
|
||||
{
|
||||
@@ -430,7 +425,7 @@ class CommandCSAKick : public Command
|
||||
|
||||
if (mask.empty() && (cmd.equals_ci("ADD") || cmd.equals_ci("DEL")))
|
||||
this->OnSyntaxError(source, cmd);
|
||||
else if (!ci->AccessFor(u).HasPriv("AKICK") && !u->HasPriv("chanserv/access/modify"))
|
||||
else if (!source.AccessFor(ci).HasPriv("AKICK") && !source.HasPriv("chanserv/access/modify"))
|
||||
source.Reply(ACCESS_DENIED);
|
||||
else if (!cmd.equals_ci("LIST") && !cmd.equals_ci("VIEW") && !cmd.equals_ci("ENFORCE") && readonly)
|
||||
source.Reply(_("Sorry, channel autokick list modification is temporarily disabled."));
|
||||
@@ -452,7 +447,7 @@ class CommandCSAKick : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand)
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
|
||||
{
|
||||
this->SendSyntax(source);
|
||||
source.Reply(" ");
|
||||
|
||||
@@ -48,18 +48,17 @@ class CommandCSAppendTopic : public Command
|
||||
this->SetSyntax(_("\037channel\037 \037text\037"));
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms)
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
|
||||
{
|
||||
const Anope::string &newtopic = params[1];
|
||||
|
||||
User *u = source.u;
|
||||
Channel *c = findchan(params[0]);;
|
||||
|
||||
if (!c)
|
||||
source.Reply(CHAN_X_NOT_IN_USE, params[0].c_str());
|
||||
else if (!c->ci)
|
||||
source.Reply(CHAN_X_NOT_REGISTERED, c->name.c_str());
|
||||
else if (!c->ci->AccessFor(u).HasPriv("TOPIC") && !u->HasCommand("chanserv/topic"))
|
||||
else if (!source.AccessFor(c->ci).HasPriv("TOPIC") && !source.HasCommand("chanserv/topic"))
|
||||
source.Reply(ACCESS_DENIED);
|
||||
else
|
||||
{
|
||||
@@ -74,17 +73,17 @@ class CommandCSAppendTopic : public Command
|
||||
|
||||
bool has_topiclock = c->ci->HasFlag(CI_TOPICLOCK);
|
||||
c->ci->UnsetFlag(CI_TOPICLOCK);
|
||||
c->ChangeTopic(u->nick, topic, Anope::CurTime);
|
||||
c->ChangeTopic(source.GetNick(), topic, Anope::CurTime);
|
||||
if (has_topiclock)
|
||||
c->ci->SetFlag(CI_TOPICLOCK);
|
||||
|
||||
bool override = !c->ci->AccessFor(u).HasPriv("TOPIC");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, c->ci) << "to append: " << topic;
|
||||
bool override = !source.AccessFor(c->ci).HasPriv("TOPIC");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, c->ci) << "to append: " << topic;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand)
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
|
||||
{
|
||||
this->SendSyntax(source);
|
||||
source.Reply(" ");
|
||||
|
||||
@@ -23,7 +23,7 @@ class CommandCSBan : public Command
|
||||
this->SetSyntax(_("\037channel\037 \037mask\037 [\037reason\037]"));
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms)
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
|
||||
{
|
||||
const Anope::string &chan = params[0];
|
||||
const Anope::string &target = params[1];
|
||||
@@ -36,11 +36,11 @@ class CommandCSBan : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
User *u = source.u;
|
||||
Channel *c = ci->c;
|
||||
User *u = source.GetUser();
|
||||
User *u2 = finduser(target);
|
||||
|
||||
AccessGroup u_access = ci->AccessFor(u);
|
||||
AccessGroup u_access = source.AccessFor(ci);
|
||||
|
||||
if (!c)
|
||||
source.Reply(CHAN_X_NOT_IN_USE, chan.c_str());
|
||||
@@ -66,7 +66,7 @@ class CommandCSBan : public Command
|
||||
get_idealban(ci, u2, mask);
|
||||
|
||||
// XXX need a way to detect if someone is overriding
|
||||
Log(LOG_COMMAND, u, this, ci) << "for " << mask;
|
||||
Log(LOG_COMMAND, source, this, ci) << "for " << mask;
|
||||
|
||||
c->SetMode(NULL, CMODE_BAN, mask);
|
||||
|
||||
@@ -74,15 +74,15 @@ class CommandCSBan : public Command
|
||||
if (!c->FindUser(u2))
|
||||
return;
|
||||
|
||||
if (ci->HasFlag(CI_SIGNKICK) || (ci->HasFlag(CI_SIGNKICK_LEVEL) && !ci->AccessFor(u).HasPriv("SIGNKICK")))
|
||||
c->Kick(ci->WhoSends(), u2, "%s (%s)", reason.c_str(), u->nick.c_str());
|
||||
if (ci->HasFlag(CI_SIGNKICK) || (ci->HasFlag(CI_SIGNKICK_LEVEL) && !source.AccessFor(ci).HasPriv("SIGNKICK")))
|
||||
c->Kick(ci->WhoSends(), u2, "%s (%s)", reason.c_str(), source.GetNick().c_str());
|
||||
else
|
||||
c->Kick(ci->WhoSends(), u2, "%s", reason.c_str());
|
||||
}
|
||||
}
|
||||
else if (u_access.HasPriv("FOUNDER"))
|
||||
{
|
||||
Log(LOG_COMMAND, u, this, ci) << "for " << target;
|
||||
Log(LOG_COMMAND, source, this, ci) << "for " << target;
|
||||
|
||||
c->SetMode(NULL, CMODE_BAN, target);
|
||||
|
||||
@@ -106,7 +106,7 @@ class CommandCSBan : public Command
|
||||
|
||||
++kicked;
|
||||
if (ci->HasFlag(CI_SIGNKICK) || (ci->HasFlag(CI_SIGNKICK_LEVEL) && !u_access.HasPriv("SIGNKICK")))
|
||||
c->Kick(ci->WhoSends(), uc->user, "%s (Matches %s) (%s)", reason.c_str(), target.c_str(), u->nick.c_str());
|
||||
c->Kick(ci->WhoSends(), uc->user, "%s (Matches %s) (%s)", reason.c_str(), target.c_str(), source.GetNick().c_str());
|
||||
else
|
||||
c->Kick(ci->WhoSends(), uc->user, "%s (Matches %s)", reason.c_str(), target.c_str());
|
||||
}
|
||||
@@ -121,7 +121,7 @@ class CommandCSBan : public Command
|
||||
source.Reply(NICK_X_NOT_IN_USE, target.c_str());
|
||||
}
|
||||
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand)
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
|
||||
{
|
||||
this->SendSyntax(source);
|
||||
source.Reply(" ");
|
||||
|
||||
@@ -22,11 +22,10 @@ class CommandCSClearUsers : public Command
|
||||
this->SetSyntax(_("\037channel\037"));
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms)
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
|
||||
{
|
||||
const Anope::string &chan = params[0];
|
||||
|
||||
User *u = source.u;
|
||||
Channel *c = findchan(chan);
|
||||
Anope::string modebuf;
|
||||
|
||||
@@ -40,13 +39,13 @@ class CommandCSClearUsers : public Command
|
||||
source.Reply(CHAN_X_NOT_REGISTERED, c->name.c_str());
|
||||
return;
|
||||
}
|
||||
else if (!c->ci->AccessFor(u).HasPriv("FOUNDER") && !u->HasCommand("chanserv/clearusers"))
|
||||
else if (!source.AccessFor(c->ci).HasPriv("FOUNDER") && !source.HasCommand("chanserv/clearusers"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
}
|
||||
|
||||
Anope::string buf = "CLEARUSERS command from " + u->nick + " (" + u->Account()->display + ")";
|
||||
Anope::string buf = "CLEARUSERS command from " + source.GetNick() + " (" + source.nc->display + ")";
|
||||
|
||||
for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; )
|
||||
{
|
||||
@@ -55,15 +54,15 @@ class CommandCSClearUsers : public Command
|
||||
c->Kick(NULL, uc->user, "%s", buf.c_str());
|
||||
}
|
||||
|
||||
bool override = !c->ci->AccessFor(u).HasPriv("FOUNDER");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, c->ci);
|
||||
bool override = !source.AccessFor(c->ci).HasPriv("FOUNDER");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, c->ci);
|
||||
|
||||
source.Reply(_("All users have been kicked from \002%s\002."), chan.c_str());
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand)
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
|
||||
{
|
||||
this->SendSyntax(source);
|
||||
source.Reply(" ");
|
||||
|
||||
@@ -22,13 +22,13 @@ public:
|
||||
this->SetSyntax(_("\037channel\037 \037target\037 [\037what\037]"));
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms)
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
|
||||
{
|
||||
const Anope::string &channel = params[0];
|
||||
const Anope::string &target = params[1];
|
||||
Anope::string what = params.size() > 2 ? params[2] : "";
|
||||
|
||||
User *u = source.u;
|
||||
User *u = source.GetUser();
|
||||
ChannelInfo *ci = cs_findchan(params[0]);
|
||||
if (ci == NULL)
|
||||
{
|
||||
@@ -36,18 +36,19 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
if (!ci->AccessFor(u).HasPriv("SET"))
|
||||
if (!source.AccessFor(ci).HasPriv("SET"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
}
|
||||
|
||||
ChannelInfo *target_ci = cs_findchan(target);
|
||||
if (!target_ci)
|
||||
{
|
||||
source.Reply(CHAN_X_NOT_REGISTERED, target.c_str());
|
||||
return;
|
||||
}
|
||||
if (!IsFounder(u, ci) || !IsFounder(u, target_ci))
|
||||
if (!source.IsFounder(ci) || !source.IsFounder(target_ci))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
@@ -58,19 +59,19 @@ public:
|
||||
|
||||
if (what.empty())
|
||||
{
|
||||
delete target_ci;
|
||||
target_ci->destroy();
|
||||
target_ci = new ChannelInfo(*ci);
|
||||
target_ci->name = target;
|
||||
RegisteredChannelList[target_ci->name] = target_ci;
|
||||
(*RegisteredChannelList)[target_ci->name] = target_ci;
|
||||
target_ci->c = findchan(target_ci->name);
|
||||
if (target_ci->c)
|
||||
{
|
||||
target_ci->c->ci = target_ci;
|
||||
|
||||
check_modes(target_ci->c);
|
||||
target_ci->c->CheckModes();
|
||||
|
||||
ChannelMode *cm;
|
||||
if (u->FindChannel(target_ci->c) != NULL)
|
||||
if (u && u->FindChannel(target_ci->c) != NULL)
|
||||
{
|
||||
/* On most ircds you do not receive the admin/owner mode till its registered */
|
||||
if ((cm = ModeManager::FindChannelModeByName(CMODE_OWNER)))
|
||||
@@ -107,7 +108,7 @@ public:
|
||||
{
|
||||
for (unsigned i = 0; i < ci->GetAccessCount(); ++i)
|
||||
{
|
||||
ChanAccess *taccess = ci->GetAccess(i);
|
||||
const ChanAccess *taccess = ci->GetAccess(i);
|
||||
AccessProvider *provider = taccess->provider;
|
||||
|
||||
ChanAccess *newaccess = provider->Create();
|
||||
@@ -128,7 +129,7 @@ public:
|
||||
target_ci->ClearAkick();
|
||||
for (unsigned i = 0; i < ci->GetAkickCount(); ++i)
|
||||
{
|
||||
AutoKick *akick = ci->GetAkick(i);
|
||||
const AutoKick *akick = ci->GetAkick(i);
|
||||
if (akick->HasFlag(AK_ISNICK))
|
||||
target_ci->AddAkick(akick->creator, akick->nc, akick->reason, akick->addtime, akick->last_used);
|
||||
else
|
||||
@@ -142,7 +143,7 @@ public:
|
||||
target_ci->ClearBadWords();
|
||||
for (unsigned i = 0; i < ci->GetBadWordCount(); ++i)
|
||||
{
|
||||
BadWord *bw = ci->GetBadWord(i);
|
||||
const BadWord *bw = ci->GetBadWord(i);
|
||||
target_ci->AddBadWord(bw->word, bw->type);
|
||||
}
|
||||
|
||||
@@ -154,12 +155,12 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
Log(LOG_COMMAND, u, this, ci) << "to clone " << (what.empty() ? "everything from it" : what) << " to " << target_ci->name;
|
||||
Log(LOG_COMMAND, source, this, ci) << "to clone " << (what.empty() ? "everything from it" : what) << " to " << target_ci->name;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand)
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
|
||||
{
|
||||
this->SendSyntax(source);
|
||||
source.Reply(" ");
|
||||
|
||||
@@ -22,12 +22,10 @@ class CommandCSDrop : public Command
|
||||
this->SetSyntax(_("\037channel\037"));
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms)
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
|
||||
{
|
||||
const Anope::string &chan = params[0];
|
||||
|
||||
User *u = source.u;
|
||||
|
||||
if (readonly)
|
||||
{
|
||||
source.Reply(_("Sorry, channel de-registration is temporarily disabled.")); // XXX: READ_ONLY_MODE?
|
||||
@@ -41,39 +39,39 @@ class CommandCSDrop : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
if (ci->HasFlag(CI_SUSPENDED) && !u->HasCommand("chanserv/drop"))
|
||||
if (ci->HasFlag(CI_SUSPENDED) && !source.HasCommand("chanserv/drop"))
|
||||
{
|
||||
source.Reply(CHAN_X_SUSPENDED, chan.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
if ((ci->HasFlag(CI_SECUREFOUNDER) ? !IsFounder(u, ci) : !ci->AccessFor(u).HasPriv("FOUNDER")) && !u->HasCommand("chanserv/drop"))
|
||||
if ((ci->HasFlag(CI_SECUREFOUNDER) ? !source.IsFounder(ci) : !source.AccessFor(ci).HasPriv("FOUNDER")) && !source.HasCommand("chanserv/drop"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
}
|
||||
|
||||
if (ci->c && ModeManager::FindChannelModeByName(CMODE_REGISTERED))
|
||||
ci->c->RemoveMode(NULL, CMODE_REGISTERED, "", false);
|
||||
bool override = (ci->HasFlag(CI_SECUREFOUNDER) ? !source.IsFounder(ci) : !source.AccessFor(ci).HasPriv("FOUNDER"));
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "(founder was: " << (ci->GetFounder() ? ci->GetFounder()->display : "none") << ")";
|
||||
|
||||
bool override = (ci->HasFlag(CI_SECUREFOUNDER) ? !IsFounder(u, ci) : !ci->AccessFor(u).HasPriv("FOUNDER"));
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "(founder was: " << (ci->GetFounder() ? ci->GetFounder()->display : "none") << ")";
|
||||
FOREACH_MOD(I_OnChanDrop, OnChanDrop(ci));
|
||||
|
||||
delete ci;
|
||||
Channel *c = ci->c;
|
||||
ci->destroy();
|
||||
|
||||
source.Reply(_("Channel \002%s\002 has been dropped."), chan.c_str());
|
||||
|
||||
FOREACH_MOD(I_OnChanDrop, OnChanDrop(chan));
|
||||
if (c)
|
||||
c->CheckModes();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand)
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
|
||||
{
|
||||
User *u = source.u;
|
||||
this->SendSyntax(source);
|
||||
source.Reply(" ");
|
||||
if (u->IsServicesOper())
|
||||
if (source.IsServicesOper())
|
||||
source.Reply(_("Unregisters the named channel. Only \002Services Operators\002\n"
|
||||
"can drop a channel for which they have not identified."));
|
||||
else
|
||||
|
||||
@@ -20,9 +20,9 @@ class CommandCSEnforce : public Command
|
||||
private:
|
||||
void DoSet(Channel *c)
|
||||
{
|
||||
ChannelInfo *ci;
|
||||
const ChannelInfo *ci = c->ci;
|
||||
|
||||
if (!(ci = c->ci))
|
||||
if (!ci)
|
||||
return;
|
||||
|
||||
if (ci->HasFlag(CI_SECUREOPS))
|
||||
@@ -39,10 +39,9 @@ class CommandCSEnforce : public Command
|
||||
|
||||
void DoSecureOps(Channel *c)
|
||||
{
|
||||
ChannelInfo *ci;
|
||||
bool hadsecureops = false;
|
||||
ChannelInfo *ci = c->ci;
|
||||
|
||||
if (!(ci = c->ci))
|
||||
if (!ci)
|
||||
return;
|
||||
|
||||
/* Dirty hack to allow chan_set_correct_modes to work ok.
|
||||
@@ -50,6 +49,7 @@ class CommandCSEnforce : public Command
|
||||
* part of the code. This way we can enforce SECUREOPS even
|
||||
* if it's off.
|
||||
*/
|
||||
bool hadsecureops = false;
|
||||
if (!ci->HasFlag(CI_SECUREOPS))
|
||||
{
|
||||
ci->SetFlag(CI_SECUREOPS);
|
||||
@@ -91,10 +91,10 @@ class CommandCSEnforce : public Command
|
||||
|
||||
void DoCModeR(Channel *c)
|
||||
{
|
||||
ChannelInfo *ci;
|
||||
ChannelInfo *ci = c->ci;
|
||||
Anope::string mask;
|
||||
|
||||
if (!(ci = c->ci))
|
||||
if (!ci)
|
||||
return;
|
||||
|
||||
for (CUserList::iterator it = c->users.begin(), it_end = c->users.end(); it != it_end; )
|
||||
@@ -118,18 +118,17 @@ class CommandCSEnforce : public Command
|
||||
this->SetSyntax(_("\037channel\037 [\037what\037]"));
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms)
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
|
||||
{
|
||||
const Anope::string &what = params.size() > 1 ? params[1] : "";
|
||||
|
||||
User *u = source.u;
|
||||
Channel *c = findchan(params[0]);
|
||||
|
||||
if (!c)
|
||||
source.Reply(CHAN_X_NOT_IN_USE, params[0].c_str());
|
||||
else if (!c->ci)
|
||||
source.Reply(CHAN_X_NOT_REGISTERED, c->name.c_str());
|
||||
else if (!c->ci->AccessFor(u).HasPriv("AKICK"))
|
||||
else if (!source.AccessFor(c->ci).HasPriv("AKICK"))
|
||||
source.Reply(ACCESS_DENIED);
|
||||
else
|
||||
{
|
||||
@@ -165,7 +164,7 @@ class CommandCSEnforce : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand)
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
|
||||
{
|
||||
this->SendSyntax(source);
|
||||
source.Reply(" ");
|
||||
|
||||
@@ -15,28 +15,27 @@
|
||||
|
||||
struct EntryMsg : Serializable
|
||||
{
|
||||
ChannelInfo *ci;
|
||||
serialize_obj<ChannelInfo> ci;
|
||||
Anope::string creator;
|
||||
Anope::string message;
|
||||
time_t when;
|
||||
|
||||
EntryMsg(ChannelInfo *c, const Anope::string &cname, const Anope::string &cmessage, time_t ct = Anope::CurTime)
|
||||
{
|
||||
|
||||
this->ci = c;
|
||||
this->creator = cname;
|
||||
this->message = cmessage;
|
||||
this->when = ct;
|
||||
}
|
||||
|
||||
Anope::string serialize_name() const
|
||||
const Anope::string serialize_name() const anope_override
|
||||
{
|
||||
return "EntryMsg";
|
||||
}
|
||||
|
||||
serialized_data serialize()
|
||||
Serialize::Data serialize() const anope_override
|
||||
{
|
||||
serialized_data data;
|
||||
Serialize::Data data;
|
||||
|
||||
data["ci"] << this->ci->name;
|
||||
data["creator"] << this->creator;
|
||||
@@ -46,20 +45,31 @@ struct EntryMsg : Serializable
|
||||
return data;
|
||||
}
|
||||
|
||||
static void unserialize(serialized_data &data);
|
||||
static Serializable* unserialize(Serializable *obj, Serialize::Data &data);
|
||||
};
|
||||
|
||||
static unsigned MaxEntries = 0;
|
||||
|
||||
struct EntryMessageList : std::vector<EntryMsg>, ExtensibleItem
|
||||
struct EntryMessageList : serialize_checker<std::vector<EntryMsg *> >, ExtensibleItem
|
||||
{
|
||||
EntryMessageList() : serialize_checker<std::vector<EntryMsg *> >("EntryMsg") { }
|
||||
};
|
||||
|
||||
void EntryMsg::unserialize(serialized_data &data)
|
||||
Serializable* EntryMsg::unserialize(Serializable *obj, Serialize::Data &data)
|
||||
{
|
||||
ChannelInfo *ci = cs_findchan(data["ci"].astr());
|
||||
if (!ci)
|
||||
return;
|
||||
return NULL;
|
||||
|
||||
if (obj)
|
||||
{
|
||||
EntryMsg *msg = anope_dynamic_static_cast<EntryMsg *>(obj);
|
||||
msg->ci = ci;
|
||||
data["creator"] >> msg->creator;
|
||||
data["message"] >> msg->message;
|
||||
data["when"] >> msg->when;
|
||||
return msg;
|
||||
}
|
||||
|
||||
EntryMessageList *messages = ci->GetExt<EntryMessageList *>("cs_entrymsg");
|
||||
if (messages == NULL)
|
||||
@@ -68,7 +78,9 @@ void EntryMsg::unserialize(serialized_data &data)
|
||||
ci->Extend("cs_entrymsg", messages);
|
||||
}
|
||||
|
||||
messages->push_back(EntryMsg(ci, data["creator"].astr(), data["message"].astr()));
|
||||
EntryMsg *m = new EntryMsg(ci, data["creator"].astr(), data["message"].astr());
|
||||
(*messages)->push_back(m);
|
||||
return m;
|
||||
}
|
||||
|
||||
class CommandEntryMessage : public Command
|
||||
@@ -78,6 +90,12 @@ class CommandEntryMessage : public Command
|
||||
{
|
||||
EntryMessageList *messages = ci->GetExt<EntryMessageList *>("cs_entrymsg");
|
||||
if (messages == NULL)
|
||||
{
|
||||
messages = new EntryMessageList();
|
||||
ci->Extend("cs_entrymsg", messages);
|
||||
}
|
||||
|
||||
if ((*messages)->empty())
|
||||
{
|
||||
source.Reply(_("Entry message list for \002%s\002 is empty."), ci->name.c_str());
|
||||
return;
|
||||
@@ -87,15 +105,15 @@ class CommandEntryMessage : public Command
|
||||
|
||||
ListFormatter list;
|
||||
list.addColumn("Number").addColumn("Creator").addColumn("Created").addColumn("Message");
|
||||
for (unsigned i = 0; i < messages->size(); ++i)
|
||||
for (unsigned i = 0; i < (*messages)->size(); ++i)
|
||||
{
|
||||
EntryMsg &msg = messages->at(i);
|
||||
EntryMsg *msg = (*messages)->at(i);
|
||||
|
||||
ListFormatter::ListEntry entry;
|
||||
entry["Number"] = stringify(i + 1);
|
||||
entry["Creator"] = msg.creator;
|
||||
entry["Created"] = do_strftime(msg.when);
|
||||
entry["Message"] = msg.message;
|
||||
entry["Creator"] = msg->creator;
|
||||
entry["Created"] = do_strftime(msg->when);
|
||||
entry["Message"] = msg->message;
|
||||
list.addEntry(entry);
|
||||
}
|
||||
|
||||
@@ -116,11 +134,12 @@ class CommandEntryMessage : public Command
|
||||
ci->Extend("cs_entrymsg", messages);
|
||||
}
|
||||
|
||||
if (MaxEntries && messages->size() >= MaxEntries)
|
||||
if (MaxEntries && (*messages)->size() >= MaxEntries)
|
||||
source.Reply(_("The entry message list for \002%s\002 is full."), ci->name.c_str());
|
||||
else
|
||||
{
|
||||
messages->push_back(EntryMsg(ci, source.u->nick, message));
|
||||
(*messages)->push_back(new EntryMsg(ci, source.GetNick(), message));
|
||||
Log(source.IsFounder(ci) ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to add a message";
|
||||
source.Reply(_("Entry message added to \002%s\002"), ci->name.c_str());
|
||||
}
|
||||
}
|
||||
@@ -128,18 +147,28 @@ class CommandEntryMessage : public Command
|
||||
void DoDel(CommandSource &source, ChannelInfo *ci, const Anope::string &message)
|
||||
{
|
||||
EntryMessageList *messages = ci->GetExt<EntryMessageList *>("cs_entrymsg");
|
||||
if (messages == NULL)
|
||||
{
|
||||
messages = new EntryMessageList();
|
||||
ci->Extend("cs_entrymsg", messages);
|
||||
}
|
||||
|
||||
if (!message.is_pos_number_only())
|
||||
source.Reply(("Entry message \002%s\002 not found on channel \002%s\002."), message.c_str(), ci->name.c_str());
|
||||
else if (messages != NULL)
|
||||
else if ((*messages)->empty())
|
||||
source.Reply(_("Entry message list for \002%s\002 is empty."), ci->name.c_str());
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
unsigned i = convertTo<unsigned>(message);
|
||||
if (i > 0 && i <= messages->size())
|
||||
if (i > 0 && i <= (*messages)->size())
|
||||
{
|
||||
messages->erase(messages->begin() + i - 1);
|
||||
if (messages->empty())
|
||||
(*messages)->at(i - 1)->destroy();
|
||||
(*messages)->erase((*messages)->begin() + i - 1);
|
||||
if ((*messages)->empty())
|
||||
ci->Shrink("cs_entrymsg");
|
||||
Log(source.IsFounder(ci) ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to remove a message";
|
||||
source.Reply(_("Entry message \002%i\002 for \002%s\002 deleted."), i, ci->name.c_str());
|
||||
}
|
||||
else
|
||||
@@ -150,13 +179,20 @@ class CommandEntryMessage : public Command
|
||||
source.Reply(_("Entry message \002%s\002 not found on channel \002%s\002."), message.c_str(), ci->name.c_str());
|
||||
}
|
||||
}
|
||||
else
|
||||
source.Reply(_("Entry message list for \002%s\002 is empty."), ci->name.c_str());
|
||||
}
|
||||
|
||||
void DoClear(CommandSource &source, ChannelInfo *ci)
|
||||
{
|
||||
ci->Shrink("cs_entrymsg");
|
||||
EntryMessageList *messages = ci->GetExt<EntryMessageList *>("cs_entrymsg");
|
||||
if (messages != NULL)
|
||||
{
|
||||
for (unsigned i = 0; i < (*messages)->size(); ++i)
|
||||
(*messages)->at(i)->destroy();
|
||||
(*messages)->clear();
|
||||
ci->Shrink("cs_entrymsg");
|
||||
}
|
||||
|
||||
Log(source.IsFounder(ci) ? LOG_COMMAND : LOG_OVERRIDE, source, this, ci) << "to remove all messages";
|
||||
source.Reply(_("Entry messages for \002%s\002 have been cleared."), ci->name.c_str());
|
||||
}
|
||||
|
||||
@@ -164,13 +200,14 @@ class CommandEntryMessage : public Command
|
||||
CommandEntryMessage(Module *creator) : Command(creator, "chanserv/entrymsg", 2, 3)
|
||||
{
|
||||
this->SetDesc(_("Manage the channel's entry messages"));
|
||||
this->SetSyntax(_("\037channel\037 {ADD|DEL|LIST|CLEAR} [\037message\037|\037num\037]"));
|
||||
this->SetSyntax(_("\037channel\037 ADD \037message\037"));
|
||||
this->SetSyntax(_("\037channel\037 DEL \037num\037"));
|
||||
this->SetSyntax(_("\037channel\037 LIST"));
|
||||
this->SetSyntax(_("\037channel\037 CLEAR"));
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms)
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
|
||||
{
|
||||
User *u = source.u;
|
||||
|
||||
ChannelInfo *ci = cs_findchan(params[0]);
|
||||
if (ci == NULL)
|
||||
{
|
||||
@@ -178,29 +215,20 @@ class CommandEntryMessage : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
if (IsFounder(u, ci) || u->HasCommand("chanserv/set"))
|
||||
if (source.IsFounder(ci) || source.HasCommand("chanserv/set"))
|
||||
{
|
||||
bool success = true;
|
||||
if (params[1].equals_ci("LIST"))
|
||||
this->DoList(source, ci);
|
||||
else if (params[1].equals_ci("CLEAR"))
|
||||
this->DoClear(source, ci);
|
||||
else if (params.size() < 3)
|
||||
{
|
||||
success = false;
|
||||
this->OnSyntaxError(source, "");
|
||||
}
|
||||
else if (params[1].equals_ci("ADD"))
|
||||
this->DoAdd(source, ci, params[2]);
|
||||
else if (params[1].equals_ci("DEL"))
|
||||
this->DoDel(source, ci, params[2]);
|
||||
else
|
||||
{
|
||||
success = false;
|
||||
this->OnSyntaxError(source, "");
|
||||
}
|
||||
if (success)
|
||||
Log(IsFounder(u, ci) ? LOG_COMMAND : LOG_OVERRIDE, u, this, ci) << " to " << params[1] << " a message";
|
||||
}
|
||||
else
|
||||
source.Reply(ACCESS_DENIED);
|
||||
@@ -208,11 +236,27 @@ class CommandEntryMessage : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand)
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
|
||||
{
|
||||
this->SendSyntax(source);
|
||||
source.Reply(" ");
|
||||
source.Reply(_("Controls what messages will be sent to users when they join the channel."));
|
||||
source.Reply(" ");
|
||||
source.Reply(_("The \002ENTRYMSG ADD\002 command adds the given message to\n"
|
||||
"the list of messages to be shown to users when they join\n"
|
||||
"the channel."));
|
||||
source.Reply(" ");
|
||||
source.Reply(_("The \002ENTRYMSG DEL\002 command removes the given message from\n"
|
||||
"the list of messages to be shown to users when they join\n"
|
||||
"the channel. You can remove the message by specifying its number\n"
|
||||
"which you can get by listing the messages as explained below."));
|
||||
source.Reply(" ");
|
||||
source.Reply(_("The \002ENTRYMSG LIST\002 command displays a listing of messages\n"
|
||||
"to be shown to users when they join the channel."));
|
||||
source.Reply(" ");
|
||||
source.Reply(_("The \002ENTRYMSG CLEAR\002 command clears all entries from\n"
|
||||
"the list of messages to be shown to users when they join\n"
|
||||
"the channel, effectively disabling entry messages."));
|
||||
return true;
|
||||
}
|
||||
};
|
||||
@@ -233,19 +277,19 @@ class CSEntryMessage : public Module
|
||||
this->OnReload();
|
||||
}
|
||||
|
||||
void OnJoinChannel(User *u, Channel *c)
|
||||
void OnJoinChannel(User *u, Channel *c) anope_override
|
||||
{
|
||||
if (u && c && c->ci && u->server->IsSynced())
|
||||
{
|
||||
EntryMessageList *messages = c->ci->GetExt<EntryMessageList *>("cs_entrymsg");
|
||||
|
||||
if (messages != NULL)
|
||||
for (unsigned i = 0; i < messages->size(); ++i)
|
||||
u->SendMessage(c->ci->WhoSends(), "[%s] %s", c->ci->name.c_str(), (*messages)[i].message.c_str());
|
||||
for (unsigned i = 0; i < (*messages)->size(); ++i)
|
||||
u->SendMessage(c->ci->WhoSends(), "[%s] %s", c->ci->name.c_str(), (*messages)->at(i)->message.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void OnReload()
|
||||
void OnReload() anope_override
|
||||
{
|
||||
ConfigReader config;
|
||||
MaxEntries = config.ReadInteger("cs_entrymsg", "maxentries", "5", 0, true);
|
||||
|
||||
@@ -0,0 +1,166 @@
|
||||
/* Chanstats core functions
|
||||
*
|
||||
* (C) 2003-2012 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 "../extra/sql.h"
|
||||
|
||||
class MySQLInterface : public SQLInterface
|
||||
{
|
||||
public:
|
||||
MySQLInterface(Module *o) : SQLInterface(o) { }
|
||||
|
||||
void OnResult(const SQLResult &r) anope_override
|
||||
{
|
||||
}
|
||||
|
||||
void OnError(const SQLResult &r) anope_override
|
||||
{
|
||||
if (!r.GetQuery().query.empty())
|
||||
Log(LOG_DEBUG) << "Chanstats: Error executing query " << r.finished_query << ": " << r.GetError();
|
||||
else
|
||||
Log(LOG_DEBUG) << "Chanstats: Error executing query: " << r.GetError();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class CommandCSStats : public Command
|
||||
{
|
||||
public:
|
||||
CommandCSStats(Module *creator) : Command (creator, "chanserv/stats", 0, 2)
|
||||
{
|
||||
this->SetFlag(CFLAG_STRIP_CHANNEL);
|
||||
this->SetDesc(_("Displays your Channel Stats"));
|
||||
this->SetSyntax(_("\037nick\037"));
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms);
|
||||
};
|
||||
|
||||
class CommandCSGStats : public Command
|
||||
{
|
||||
public:
|
||||
CommandCSGStats(Module *creator) : Command (creator, "chanserv/gstats", 0, 2)
|
||||
{
|
||||
this->SetFlag(CFLAG_STRIP_CHANNEL);
|
||||
this->SetDesc(_("Displays your Global Stats"));
|
||||
this->SetSyntax(_("\037nick\037"));
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms);
|
||||
};
|
||||
|
||||
|
||||
class CSStats;
|
||||
static CSStats *me;
|
||||
class CSStats : public Module
|
||||
{
|
||||
CommandCSStats commandcsstats;
|
||||
CommandCSGStats commandcsgstats;
|
||||
service_reference<SQLProvider> sql;
|
||||
MySQLInterface sqlinterface;
|
||||
Anope::string prefix;
|
||||
public:
|
||||
CSStats(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE),
|
||||
commandcsstats(this), commandcsgstats(this), sql("", ""), sqlinterface(this)
|
||||
{
|
||||
me = this;
|
||||
this->SetAuthor("Anope");
|
||||
|
||||
Implementation i[] = { I_OnReload };
|
||||
ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
|
||||
this->OnReload();
|
||||
}
|
||||
|
||||
void OnReload() anope_override
|
||||
{
|
||||
ConfigReader config;
|
||||
prefix = config.ReadValue("chanstats", "prefix", "anope_", 0);
|
||||
Anope::string engine = config.ReadValue("chanstats", "engine", "", 0);
|
||||
this->sql = service_reference<SQLProvider>("SQLProvider", engine);
|
||||
}
|
||||
|
||||
SQLResult RunQuery(const SQLQuery &query)
|
||||
{
|
||||
if (!this->sql)
|
||||
throw SQLException("Unable to locate SQL reference, is m_mysql loaded and configured correctly?");
|
||||
|
||||
SQLResult res = this->sql->RunQuery(query);
|
||||
if (!res.GetError().empty())
|
||||
throw SQLException(res.GetError());
|
||||
return res;
|
||||
}
|
||||
|
||||
void DoStats(CommandSource &source, const bool is_global, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (!source.c)
|
||||
return;
|
||||
|
||||
Anope::string display;
|
||||
if (params.empty())
|
||||
display = source.nc->display;
|
||||
else if (const NickAlias *na = findnick(params[0]))
|
||||
display = na->nc->display;
|
||||
else
|
||||
{
|
||||
source.Reply(_("%s not found."), params[0].c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
SQLQuery query;
|
||||
query = "SELECT letters, words, line, smileys_happy+smileys_sad+smileys_other as smileys,"
|
||||
"actions FROM `" + prefix + "chanstats` "
|
||||
"WHERE `nick` = @nick@ AND `chan` = @channel@ AND `type` = 'total';";
|
||||
if (is_global)
|
||||
query.setValue("channel", "");
|
||||
else
|
||||
query.setValue("channel", source.c->ci->name);
|
||||
query.setValue("nick", display);
|
||||
SQLResult res = this->RunQuery(query);
|
||||
|
||||
if (res.Rows() > 0)
|
||||
{
|
||||
if (is_global)
|
||||
source.Reply(_("Network stats for %s:"), display.c_str());
|
||||
else
|
||||
source.Reply(_("Channel stats for %s on %s:"), display.c_str(), source.c->name.c_str());
|
||||
|
||||
source.Reply(_("letters: %s, words: %s, lines: %s, smileys %s, actions: %s"),
|
||||
res.Get(0, "letters").c_str(), res.Get(0, "words").c_str(),
|
||||
res.Get(0, "line").c_str(), res.Get(0, "smileys").c_str(),
|
||||
res.Get(0, "actions").c_str());
|
||||
}
|
||||
else
|
||||
source.Reply(_("No stats for %s"), display.c_str());
|
||||
}
|
||||
catch (const SQLException &ex)
|
||||
{
|
||||
Log(LOG_DEBUG) << ex.GetReason();
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
void CommandCSStats::Execute(CommandSource &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
me->DoStats(source, false, params);
|
||||
}
|
||||
|
||||
void CommandCSGStats::Execute(CommandSource &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
me->DoStats(source, true, params);
|
||||
}
|
||||
|
||||
MODULE_INIT(CSStats)
|
||||
|
||||
@@ -0,0 +1,207 @@
|
||||
/* Chanstats core functions
|
||||
*
|
||||
* (C) 2003-2012 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 "../extra/sql.h"
|
||||
|
||||
class MySQLInterface : public SQLInterface
|
||||
{
|
||||
public:
|
||||
MySQLInterface(Module *o) : SQLInterface(o) { }
|
||||
|
||||
void OnResult(const SQLResult &r) anope_override
|
||||
{
|
||||
}
|
||||
|
||||
void OnError(const SQLResult &r) anope_override
|
||||
{
|
||||
if (!r.GetQuery().query.empty())
|
||||
Log(LOG_DEBUG) << "Chanstats: Error executing query " << r.finished_query << ": " << r.GetError();
|
||||
else
|
||||
Log(LOG_DEBUG) << "Chanstats: Error executing query: " << r.GetError();
|
||||
}
|
||||
};
|
||||
|
||||
class CommandCSTop : public Command
|
||||
{
|
||||
public:
|
||||
CommandCSTop(Module *creator) : Command (creator, "chanserv/top", 0, 2)
|
||||
{
|
||||
this->SetFlag(CFLAG_STRIP_CHANNEL);
|
||||
this->SetDesc(_("Displays the top 3 users of a channel"));
|
||||
this->SetSyntax(_("\037channel\037"));
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms);
|
||||
};
|
||||
|
||||
class CommandCSTop10 : public Command
|
||||
{
|
||||
public:
|
||||
CommandCSTop10(Module *creator) : Command (creator, "chanserv/top10", 0, 2)
|
||||
{
|
||||
this->SetFlag(CFLAG_STRIP_CHANNEL);
|
||||
this->SetDesc(_("Displays the top 10 users of a channel"));
|
||||
this->SetSyntax(_("\037channel\037"));
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms);
|
||||
};
|
||||
|
||||
class CommandCSGTop : public Command
|
||||
{
|
||||
public:
|
||||
CommandCSGTop(Module *creator) : Command (creator, "chanserv/gtop", 0, 1)
|
||||
{
|
||||
this->SetFlag(CFLAG_STRIP_CHANNEL);
|
||||
this->SetDesc(_("Displays the top 3 users of the network"));
|
||||
this->SetSyntax("");
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms);
|
||||
};
|
||||
|
||||
class CommandCSGTop10 : public Command
|
||||
{
|
||||
public:
|
||||
CommandCSGTop10(Module *creator) : Command (creator, "chanserv/gtop10", 0, 1)
|
||||
{
|
||||
this->SetFlag(CFLAG_STRIP_CHANNEL);
|
||||
this->SetDesc(_("Displays the top 10 users of the network"));
|
||||
this->SetSyntax("");
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms);
|
||||
};
|
||||
|
||||
|
||||
class CSTop;
|
||||
static CSTop *me;
|
||||
class CSTop : public Module
|
||||
{
|
||||
CommandCSTop commandcstop;
|
||||
CommandCSGTop commandcsgtop;
|
||||
CommandCSTop10 commandcstop10;
|
||||
CommandCSGTop10 commandcsgtop10;
|
||||
service_reference<SQLProvider> sql;
|
||||
MySQLInterface sqlinterface;
|
||||
Anope::string prefix;
|
||||
|
||||
public:
|
||||
CSTop(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator, CORE),
|
||||
commandcstop(this), commandcsgtop(this), commandcstop10(this), commandcsgtop10(this), sql("", ""),
|
||||
sqlinterface(this)
|
||||
{
|
||||
me = this;
|
||||
this->SetAuthor("Anope");
|
||||
|
||||
Implementation i[] = { I_OnReload };
|
||||
ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
|
||||
this->OnReload();
|
||||
}
|
||||
|
||||
void OnReload() anope_override
|
||||
{
|
||||
ConfigReader config;
|
||||
prefix = config.ReadValue("chanstats", "prefix", "anope_", 0);
|
||||
Anope::string engine = config.ReadValue("chanstats", "engine", "", 0);
|
||||
this->sql = service_reference<SQLProvider>("SQLProvider", engine);
|
||||
}
|
||||
|
||||
SQLResult RunQuery(const SQLQuery &query)
|
||||
{
|
||||
if (!this->sql)
|
||||
throw SQLException("Unable to locate SQL reference, is m_mysql loaded and configured correctly?");
|
||||
|
||||
SQLResult res = sql->RunQuery(query);
|
||||
if (!res.GetError().empty())
|
||||
throw SQLException(res.GetError());
|
||||
return res;
|
||||
}
|
||||
|
||||
void DoTop(CommandSource &source, const std::vector<Anope::string> ¶ms, bool is_global, int limit = 1)
|
||||
{
|
||||
if (!source.c || !source.c->ci)
|
||||
return;
|
||||
|
||||
Anope::string channel;
|
||||
if (is_global || params.empty())
|
||||
channel = source.c->ci->name;
|
||||
else if (!params.empty())
|
||||
channel = params[0];
|
||||
else
|
||||
{
|
||||
source.Reply(_("%s not found."), params[0].c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
SQLQuery query;
|
||||
query = "SELECT nick, letters, words, line, actions,"
|
||||
"smileys_happy+smileys_sad+smileys_other as smileys "
|
||||
"FROM `" + prefix + "chanstats` "
|
||||
"WHERE `nick` != '' AND `chan` = @channel@ AND `type` = 'total' "
|
||||
"ORDER BY `letters` DESC LIMIT @limit@;";
|
||||
query.setValue("limit", limit, false);
|
||||
|
||||
if (is_global)
|
||||
query.setValue("channel", "");
|
||||
else
|
||||
query.setValue("channel", channel.c_str());
|
||||
|
||||
SQLResult res = this->RunQuery(query);
|
||||
|
||||
if (res.Rows() > 0)
|
||||
{
|
||||
source.Reply(_("Top %i of %s"), limit, (is_global ? "Network" : channel.c_str()));
|
||||
for (int i = 0; i < res.Rows(); ++i)
|
||||
{
|
||||
source.Reply(_("%2lu \002%-16s\002 letters: %s, words: %s, lines: %s, smileys %s, actions: %s"),
|
||||
i+1, res.Get(i, "nick").c_str(), res.Get(i, "letters").c_str(),
|
||||
res.Get(i, "words").c_str(), res.Get(i, "line").c_str(),
|
||||
res.Get(0, "smileys").c_str(), res.Get(0, "actions").c_str());
|
||||
}
|
||||
}
|
||||
else
|
||||
source.Reply(_("No stats for %s"), is_global ? "Network" : channel.c_str());
|
||||
}
|
||||
catch (const SQLException &ex)
|
||||
{
|
||||
Log(LOG_DEBUG) << ex.GetReason();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void CommandCSTop::Execute(CommandSource &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
me->DoTop(source, params, false, 3);
|
||||
}
|
||||
|
||||
void CommandCSTop10::Execute(CommandSource &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
me->DoTop(source, params, false, 10);
|
||||
}
|
||||
|
||||
void CommandCSGTop::Execute(CommandSource &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
me->DoTop(source, params, true, 3);
|
||||
}
|
||||
|
||||
void CommandCSGTop10::Execute(CommandSource &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
me->DoTop(source, params, true, 10);
|
||||
}
|
||||
|
||||
|
||||
MODULE_INIT(CSTop)
|
||||
@@ -24,7 +24,7 @@ class FlagsChanAccess : public ChanAccess
|
||||
{
|
||||
}
|
||||
|
||||
bool HasPriv(const Anope::string &priv) const
|
||||
bool HasPriv(const Anope::string &priv) const anope_override
|
||||
{
|
||||
std::map<Anope::string, char>::iterator it = defaultFlags.find(priv);
|
||||
if (it != defaultFlags.end() && this->flags.count(it->second) > 0)
|
||||
@@ -32,18 +32,18 @@ class FlagsChanAccess : public ChanAccess
|
||||
return false;
|
||||
}
|
||||
|
||||
Anope::string Serialize()
|
||||
Anope::string Serialize() const
|
||||
{
|
||||
return Anope::string(this->flags.begin(), this->flags.end());
|
||||
}
|
||||
|
||||
void Unserialize(const Anope::string &data)
|
||||
void Unserialize(const Anope::string &data) anope_override
|
||||
{
|
||||
for (unsigned i = data.length(); i > 0; --i)
|
||||
this->flags.insert(data[i - 1]);
|
||||
}
|
||||
|
||||
static Anope::string DetermineFlags(ChanAccess *access)
|
||||
static Anope::string DetermineFlags(const ChanAccess *access)
|
||||
{
|
||||
if (access->provider->name == "access/flags")
|
||||
return access->Serialize();
|
||||
@@ -65,7 +65,7 @@ class FlagsAccessProvider : public AccessProvider
|
||||
{
|
||||
}
|
||||
|
||||
ChanAccess *Create()
|
||||
ChanAccess *Create() anope_override
|
||||
{
|
||||
return new FlagsChanAccess(this);
|
||||
}
|
||||
@@ -75,8 +75,6 @@ class CommandCSFlags : public Command
|
||||
{
|
||||
void DoModify(CommandSource &source, ChannelInfo *ci, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
User *u = source.u;
|
||||
|
||||
Anope::string mask = params.size() > 2 ? params[2] : "";
|
||||
Anope::string flags = params.size() > 3 ? params[3] : "";
|
||||
|
||||
@@ -86,10 +84,19 @@ class CommandCSFlags : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
AccessGroup u_access = ci->AccessFor(u);
|
||||
AccessGroup u_access = source.AccessFor(ci);
|
||||
|
||||
if (mask.find_first_of("!*@") == Anope::string::npos && findnick(mask) == NULL)
|
||||
mask += "!*@*";
|
||||
if (mask.find_first_of("!*@") == Anope::string::npos && !findnick(mask))
|
||||
{
|
||||
User *targ = finduser(mask);
|
||||
if (targ != NULL)
|
||||
mask = "*!*@" + targ->GetDisplayedHost();
|
||||
else
|
||||
{
|
||||
source.Reply(NICK_X_NOT_REGISTERED, mask.c_str());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
ChanAccess *current = NULL;
|
||||
std::set<char> current_flags;
|
||||
@@ -132,7 +139,7 @@ class CommandCSFlags : public Command
|
||||
{
|
||||
if (!u_access.HasPriv(it->first))
|
||||
{
|
||||
if (u->HasPriv("chanserv/access/modify"))
|
||||
if (source.HasPriv("chanserv/access/modify"))
|
||||
override = true;
|
||||
else
|
||||
continue;
|
||||
@@ -152,12 +159,12 @@ class CommandCSFlags : public Command
|
||||
continue;
|
||||
else if (!u_access.HasPriv(it->first))
|
||||
{
|
||||
if (u->HasPriv("chanserv/access/modify"))
|
||||
if (source.HasPriv("chanserv/access/modify"))
|
||||
override = true;
|
||||
else
|
||||
{
|
||||
source.Reply(_("You can not set the \002%c\002 flag."), f);
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (add == 1)
|
||||
@@ -172,9 +179,9 @@ class CommandCSFlags : public Command
|
||||
{
|
||||
if (current != NULL)
|
||||
{
|
||||
FOREACH_MOD(I_OnAccessDel, OnAccessDel(ci, u, current));
|
||||
FOREACH_MOD(I_OnAccessDel, OnAccessDel(ci, source, current));
|
||||
ci->EraseAccess(current);
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to delete " << mask;
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to delete " << mask;
|
||||
source.Reply(_("\002%s\002 removed from the %s access list."), mask.c_str(), ci->name.c_str());
|
||||
}
|
||||
else
|
||||
@@ -187,10 +194,10 @@ class CommandCSFlags : public Command
|
||||
service_reference<AccessProvider> provider("AccessProvider", "access/flags");
|
||||
if (!provider)
|
||||
return;
|
||||
FlagsChanAccess *access = debug_cast<FlagsChanAccess *>(provider->Create());
|
||||
FlagsChanAccess *access = anope_dynamic_static_cast<FlagsChanAccess *>(provider->Create());
|
||||
access->ci = ci;
|
||||
access->mask = mask;
|
||||
access->creator = u->nick;
|
||||
access->creator = source.GetNick();
|
||||
access->last_seen = current ? current->last_seen : 0;
|
||||
access->created = Anope::CurTime;
|
||||
access->flags = current_flags;
|
||||
@@ -200,9 +207,9 @@ class CommandCSFlags : public Command
|
||||
|
||||
ci->AddAccess(access);
|
||||
|
||||
FOREACH_MOD(I_OnAccessAdd, OnAccessAdd(ci, u, access));
|
||||
FOREACH_MOD(I_OnAccessAdd, OnAccessAdd(ci, source, access));
|
||||
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to modify " << mask << "'s flags to " << access->Serialize();
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to modify " << mask << "'s flags to " << access->Serialize();
|
||||
source.Reply(_("Access for \002%s\002 on %s set to +\002%s\002"), access->mask.c_str(), ci->name.c_str(), access->Serialize().c_str());
|
||||
|
||||
return;
|
||||
@@ -225,11 +232,12 @@ class CommandCSFlags : public Command
|
||||
unsigned count = 0;
|
||||
for (unsigned i = 0, end = ci->GetAccessCount(); i < end; ++i)
|
||||
{
|
||||
ChanAccess *access = ci->GetAccess(i);
|
||||
const Anope::string &flags = FlagsChanAccess::DetermineFlags(access);
|
||||
const ChanAccess *access = ci->GetAccess(i);
|
||||
|
||||
if (!arg.empty())
|
||||
{
|
||||
const Anope::string &flags = FlagsChanAccess::DetermineFlags(access);
|
||||
|
||||
if (arg[0] == '+')
|
||||
{
|
||||
bool pass = true;
|
||||
@@ -249,7 +257,7 @@ class CommandCSFlags : public Command
|
||||
entry["Mask"] = access->mask;
|
||||
entry["Flags"] = FlagsChanAccess::DetermineFlags(access);
|
||||
entry["Creator"] = access->creator;
|
||||
entry["Created"] = do_strftime(access->created, source.u->Account(), true);
|
||||
entry["Created"] = do_strftime(access->created, source.nc, true);
|
||||
list.addEntry(entry);
|
||||
}
|
||||
|
||||
@@ -272,20 +280,18 @@ class CommandCSFlags : public Command
|
||||
|
||||
void DoClear(CommandSource &source, ChannelInfo *ci)
|
||||
{
|
||||
User *u = source.u;
|
||||
|
||||
if (!IsFounder(u, ci) && !u->HasPriv("chanserv/access/modify"))
|
||||
if (!source.IsFounder(ci) && !source.HasPriv("chanserv/access/modify"))
|
||||
source.Reply(ACCESS_DENIED);
|
||||
else
|
||||
{
|
||||
ci->ClearAccess();
|
||||
|
||||
FOREACH_MOD(I_OnAccessClear, OnAccessClear(ci, u));
|
||||
FOREACH_MOD(I_OnAccessClear, OnAccessClear(ci, source));
|
||||
|
||||
source.Reply(_("Channel %s access list has been cleared."), ci->name.c_str());
|
||||
|
||||
bool override = !IsFounder(u, ci);
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci) << "to clear the access list";
|
||||
bool override = !source.IsFounder(ci);
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci) << "to clear the access list";
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -297,15 +303,14 @@ class CommandCSFlags : public Command
|
||||
this->SetDesc(_("Modify the list of privileged users"));
|
||||
this->SetSyntax(_("\037channel\037 MODIFY \037mask\037 \037changes\037"));
|
||||
this->SetSyntax(_("\037channel\037 LIST [\037mask\037 | +\037flags\037]"));
|
||||
this->SetSyntax(_("\037channel\037 CLEAR\002"));
|
||||
this->SetSyntax(_("\037channel\037 CLEAR"));
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms)
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
|
||||
{
|
||||
const Anope::string &chan = params[0];
|
||||
const Anope::string &cmd = params[1];
|
||||
|
||||
User *u = source.u;
|
||||
ChannelInfo *ci = cs_findchan(chan);
|
||||
if (ci == NULL)
|
||||
{
|
||||
@@ -315,11 +320,11 @@ class CommandCSFlags : public Command
|
||||
|
||||
bool is_list = cmd.equals_ci("LIST");
|
||||
bool has_access = false;
|
||||
if (u->HasPriv("chanserv/access/modify"))
|
||||
if (source.HasPriv("chanserv/access/modify"))
|
||||
has_access = true;
|
||||
else if (is_list && ci->AccessFor(u).HasPriv("ACCESS_LIST"))
|
||||
else if (is_list && source.AccessFor(ci).HasPriv("ACCESS_LIST"))
|
||||
has_access = true;
|
||||
else if (ci->AccessFor(u).HasPriv("ACCESS_CHANGE"))
|
||||
else if (source.AccessFor(ci).HasPriv("ACCESS_CHANGE"))
|
||||
has_access = true;
|
||||
|
||||
if (!has_access)
|
||||
@@ -336,7 +341,7 @@ class CommandCSFlags : public Command
|
||||
this->OnSyntaxError(source, cmd);
|
||||
}
|
||||
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand)
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
|
||||
{
|
||||
this->SendSyntax(source);
|
||||
source.Reply(" ");
|
||||
@@ -369,7 +374,7 @@ class CommandCSFlags : public Command
|
||||
Privilege *p = PrivilegeManager::FindPrivilege(it->second);
|
||||
if (p == NULL)
|
||||
continue;
|
||||
source.Reply(" %c - %s", it->first, translate(source.u->Account(), p->desc.c_str()));
|
||||
source.Reply(" %c - %s", it->first, translate(source.nc, p->desc.c_str()));
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -394,7 +399,7 @@ class CSFlags : public Module
|
||||
this->OnReload();
|
||||
}
|
||||
|
||||
void OnReload()
|
||||
void OnReload() anope_override
|
||||
{
|
||||
ConfigReader config;
|
||||
defaultFlags.clear();
|
||||
|
||||
@@ -22,11 +22,10 @@ class CommandCSGetKey : public Command
|
||||
this->SetSyntax(_("\037channel\037"));
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms)
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
|
||||
{
|
||||
const Anope::string &chan = params[0];
|
||||
|
||||
User *u = source.u;
|
||||
ChannelInfo *ci = cs_findchan(params[0]);
|
||||
if (ci == NULL)
|
||||
{
|
||||
@@ -34,8 +33,7 @@ class CommandCSGetKey : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!ci->AccessFor(u).HasPriv("GETKEY") && !u->HasCommand("chanserv/getkey"))
|
||||
if (!source.AccessFor(ci).HasPriv("GETKEY") && !source.HasCommand("chanserv/getkey"))
|
||||
{
|
||||
source.Reply(ACCESS_DENIED);
|
||||
return;
|
||||
@@ -48,14 +46,14 @@ class CommandCSGetKey : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
bool override = !ci->AccessFor(u).HasPriv("GETKEY");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, u, this, ci);
|
||||
bool override = !source.AccessFor(ci).HasPriv("GETKEY");
|
||||
Log(override ? LOG_OVERRIDE : LOG_COMMAND, source, this, ci);
|
||||
|
||||
source.Reply(_("Key for channel \002%s\002 is \002%s\002."), chan.c_str(), key.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand)
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
|
||||
{
|
||||
this->SendSyntax(source);
|
||||
source.Reply(" ");
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
class CommandCSInfo : public Command
|
||||
{
|
||||
void CheckOptStr(Anope::string &buf, ChannelInfoFlag opt, const char *str, ChannelInfo *ci, NickCore *nc)
|
||||
void CheckOptStr(Anope::string &buf, ChannelInfoFlag opt, const char *str, const ChannelInfo *ci, const NickCore *nc)
|
||||
{
|
||||
if (ci->HasFlag(opt))
|
||||
{
|
||||
@@ -34,11 +34,11 @@ class CommandCSInfo : public Command
|
||||
this->SetSyntax(_("\037channel\037"));
|
||||
}
|
||||
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms)
|
||||
void Execute(CommandSource &source, const std::vector<Anope::string> ¶ms) anope_override
|
||||
{
|
||||
const Anope::string &chan = params[0];
|
||||
|
||||
User *u = source.u;
|
||||
NickCore *nc = source.nc;
|
||||
ChannelInfo *ci = cs_findchan(params[0]);
|
||||
if (ci == NULL)
|
||||
{
|
||||
@@ -46,14 +46,14 @@ class CommandCSInfo : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
bool has_auspex = u->IsIdentified() && u->HasPriv("chanserv/auspex");
|
||||
bool has_auspex = source.HasPriv("chanserv/auspex");
|
||||
bool show_all = false;
|
||||
|
||||
/* Should we show all fields? Only for sadmins and identified users */
|
||||
if (has_auspex || ci->AccessFor(u).HasPriv("INFO"))
|
||||
if (has_auspex || source.AccessFor(ci).HasPriv("INFO"))
|
||||
show_all = true;
|
||||
|
||||
InfoFormatter info(u);
|
||||
InfoFormatter info(nc);
|
||||
|
||||
source.Reply(CHAN_INFO_HEADER, chan.c_str());
|
||||
if (ci->GetFounder())
|
||||
@@ -68,7 +68,7 @@ class CommandCSInfo : public Command
|
||||
info["Registered"] = do_strftime(ci->time_registered);
|
||||
info["Last used"] = do_strftime(ci->last_used);
|
||||
|
||||
ModeLock *secret = ci->GetMLock(CMODE_SECRET);
|
||||
const ModeLock *secret = ci->GetMLock(CMODE_SECRET);
|
||||
if (!ci->last_topic.empty() && (show_all || ((!secret || secret->set == false) && (!ci->c || !ci->c->HasMode(CMODE_SECRET)))))
|
||||
{
|
||||
info["Last topic"] = ci->last_topic;
|
||||
@@ -80,20 +80,21 @@ class CommandCSInfo : public Command
|
||||
info["Ban type"] = stringify(ci->bantype);
|
||||
|
||||
Anope::string optbuf;
|
||||
CheckOptStr(optbuf, CI_KEEPTOPIC, _("Topic Retention"), ci, u->Account());
|
||||
CheckOptStr(optbuf, CI_PEACE, _("Peace"), ci, u->Account());
|
||||
CheckOptStr(optbuf, CI_PRIVATE, _("Private"), ci, u->Account());
|
||||
CheckOptStr(optbuf, CI_RESTRICTED, _("Restricted Access"), ci, u->Account());
|
||||
CheckOptStr(optbuf, CI_SECURE, _("Secure"), ci, u->Account());
|
||||
CheckOptStr(optbuf, CI_SECUREFOUNDER, _("Secure Founder"), ci, u->Account());
|
||||
CheckOptStr(optbuf, CI_SECUREOPS, _("Secure Ops"), ci, u->Account());
|
||||
CheckOptStr(optbuf, CI_KEEPTOPIC, _("Topic Retention"), ci, nc);
|
||||
CheckOptStr(optbuf, CI_PEACE, _("Peace"), ci, nc);
|
||||
CheckOptStr(optbuf, CI_PRIVATE, _("Private"), ci, nc);
|
||||
CheckOptStr(optbuf, CI_RESTRICTED, _("Restricted Access"), ci, nc);
|
||||
CheckOptStr(optbuf, CI_SECURE, _("Secure"), ci, nc);
|
||||
CheckOptStr(optbuf, CI_SECUREFOUNDER, _("Secure Founder"), ci, nc);
|
||||
CheckOptStr(optbuf, CI_SECUREOPS, _("Secure Ops"), ci, nc);
|
||||
if (ci->HasFlag(CI_SIGNKICK))
|
||||
CheckOptStr(optbuf, CI_SIGNKICK, _("Signed kicks"), ci, u->Account());
|
||||
CheckOptStr(optbuf, CI_SIGNKICK, _("Signed kicks"), ci, nc);
|
||||
else
|
||||
CheckOptStr(optbuf, CI_SIGNKICK_LEVEL, _("Signed kicks"), ci, u->Account());
|
||||
CheckOptStr(optbuf, CI_TOPICLOCK, _("Topic Lock"), ci, u->Account());
|
||||
CheckOptStr(optbuf, CI_PERSIST, _("Persistant"), ci, u->Account());
|
||||
CheckOptStr(optbuf, CI_NO_EXPIRE, _("No expire"), ci, u->Account());
|
||||
CheckOptStr(optbuf, CI_SIGNKICK_LEVEL, _("Signed kicks"), ci, nc);
|
||||
CheckOptStr(optbuf, CI_TOPICLOCK, _("Topic Lock"), ci, nc);
|
||||
CheckOptStr(optbuf, CI_PERSIST, _("Persistant"), ci, nc);
|
||||
CheckOptStr(optbuf, CI_NO_EXPIRE, _("No expire"), ci, nc);
|
||||
CheckOptStr(optbuf, CI_STATS, _("Chanstats"), ci, nc);
|
||||
|
||||
info["Options"] = optbuf.empty() ? _("None") : optbuf;
|
||||
info["Mode lock"] = ci->GetMLockAsString(true);
|
||||
@@ -103,7 +104,7 @@ class CommandCSInfo : public Command
|
||||
}
|
||||
if (ci->HasFlag(CI_SUSPENDED))
|
||||
{
|
||||
Anope::string *by = ci->GetExt<ExtensibleString *>("suspend_by"), *reason = ci->GetExt<ExtensibleString *>("suspend_reason");
|
||||
Anope::string *by = ci->GetExt<ExtensibleItemClass<Anope::string> *>("suspend_by"), *reason = ci->GetExt<ExtensibleItemClass<Anope::string> *>("suspend_reason");
|
||||
if (by != NULL)
|
||||
info["Suspended"] = Anope::printf("[%s] %s", by->c_str(), (reason && !reason->empty() ? reason->c_str() : NO_REASON));
|
||||
}
|
||||
@@ -119,15 +120,16 @@ class CommandCSInfo : public Command
|
||||
return;
|
||||
}
|
||||
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand)
|
||||
bool OnHelp(CommandSource &source, const Anope::string &subcommand) anope_override
|
||||
{
|
||||
this->SendSyntax(source);
|
||||
source.Reply(" ");
|
||||
source.Reply(_("Lists information about the named registered channel,\n"
|
||||
"including its founder, time of registration, last time\n"
|
||||
"used, description, and mode lock, if any. If \002ALL\002 is\n"
|
||||
"specified, the entry message and successor will also\n"
|
||||
"be displayed."));
|
||||
"including its founder, time of registration, and last\n"
|
||||
"time used. If the user issuing the command has the\n"
|
||||
"appropriate access for it, then the description, successor,\n"
|
||||
"last topic set, settings and expiration time will also\n"
|
||||
"be displayed when applicable."));
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user