From e0583918834a3f8683e430adf3923ea89d2a449a Mon Sep 17 00:00:00 2001 From: "rob rob@31f1291d-b8d6-0310-a050-a5561fc1590b" Date: Mon, 2 May 2005 19:02:12 +0000 Subject: BUILD : 1.7.8 (753) BUGS : N/a NOTES : Merged anope-dev with trunk git-svn-id: svn://svn.anope.org/anope/trunk@753 31f1291d-b8d6-0310-a050-a5561fc1590b git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@516 5417fbe8-f217-4b02-8779-1006273d7864 --- src/core/Makefile | 45 +++ src/core/Makefile.sub | 30 ++ src/core/Makefile.win32 | 25 ++ src/core/bs_act.c | 93 +++++ src/core/bs_assign.c | 102 +++++ src/core/bs_badwords.c | 290 +++++++++++++++ src/core/bs_bot.c | 372 +++++++++++++++++++ src/core/bs_botlist.c | 108 ++++++ src/core/bs_fantasy.c | 80 ++++ src/core/bs_fantasy_kick.c | 87 +++++ src/core/bs_fantasy_kickban.c | 90 +++++ src/core/bs_fantasy_owner.c | 87 +++++ src/core/bs_fantasy_seen.c | 136 +++++++ src/core/bs_fantasy_unban.c | 78 ++++ src/core/bs_help.c | 67 ++++ src/core/bs_info.c | 282 ++++++++++++++ src/core/bs_kick.c | 377 +++++++++++++++++++ src/core/bs_say.c | 97 +++++ src/core/bs_set.c | 207 +++++++++++ src/core/bs_unassign.c | 88 +++++ src/core/configure | 35 ++ src/core/cs_access.c | 507 +++++++++++++++++++++++++ src/core/cs_akick.c | 584 +++++++++++++++++++++++++++++ src/core/cs_ban.c | 227 ++++++++++++ src/core/cs_clear.c | 375 +++++++++++++++++++ src/core/cs_drop.c | 128 +++++++ src/core/cs_forbid.c | 132 +++++++ src/core/cs_getkey.c | 88 +++++ src/core/cs_getpass.c | 100 +++++ src/core/cs_help.c | 84 +++++ src/core/cs_identify.c | 118 ++++++ src/core/cs_info.c | 249 +++++++++++++ src/core/cs_invite.c | 88 +++++ src/core/cs_kick.c | 152 ++++++++ src/core/cs_list.c | 172 +++++++++ src/core/cs_logout.c | 128 +++++++ src/core/cs_modes.c | 392 ++++++++++++++++++++ src/core/cs_register.c | 199 ++++++++++ src/core/cs_sendpass.c | 123 +++++++ src/core/cs_set.c | 839 ++++++++++++++++++++++++++++++++++++++++++ src/core/cs_status.c | 102 +++++ src/core/cs_suspend.c | 188 ++++++++++ src/core/cs_topic.c | 119 ++++++ src/core/cs_xop.c | 474 ++++++++++++++++++++++++ src/core/he_help.c | 76 ++++ src/core/hs_del.c | 91 +++++ src/core/hs_delall.c | 96 +++++ src/core/hs_group.c | 121 ++++++ src/core/hs_help.c | 66 ++++ src/core/hs_list.c | 179 +++++++++ src/core/hs_off.c | 87 +++++ src/core/hs_on.c | 102 +++++ src/core/hs_set.c | 147 ++++++++ src/core/hs_setall.c | 150 ++++++++ src/core/ms_cancel.c | 105 ++++++ src/core/ms_check.c | 118 ++++++ src/core/ms_del.c | 199 ++++++++++ src/core/ms_help.c | 66 ++++ src/core/ms_info.c | 231 ++++++++++++ src/core/ms_list.c | 197 ++++++++++ src/core/ms_read.c | 201 ++++++++++ src/core/ms_rsend.c | 119 ++++++ src/core/ms_send.c | 73 ++++ src/core/ms_sendall.c | 95 +++++ src/core/ms_set.c | 265 +++++++++++++ src/core/ms_staff.c | 92 +++++ src/core/ns_access.c | 189 ++++++++++ src/core/ns_alist.c | 186 ++++++++++ src/core/ns_drop.c | 156 ++++++++ src/core/ns_forbid.c | 151 ++++++++ src/core/ns_getemail.c | 102 +++++ src/core/ns_getpass.c | 111 ++++++ src/core/ns_ghost.c | 122 ++++++ src/core/ns_group.c | 326 ++++++++++++++++ src/core/ns_help.c | 77 ++++ src/core/ns_identify.c | 160 ++++++++ src/core/ns_info.c | 272 ++++++++++++++ src/core/ns_list.c | 230 ++++++++++++ src/core/ns_logout.c | 125 +++++++ src/core/ns_recover.c | 111 ++++++ src/core/ns_register.c | 486 ++++++++++++++++++++++++ src/core/ns_release.c | 107 ++++++ src/core/ns_sendpass.c | 120 ++++++ src/core/ns_set.c | 519 ++++++++++++++++++++++++++ src/core/ns_status.c | 94 +++++ src/core/ns_suspend.c | 193 ++++++++++ src/core/ns_update.c | 90 +++++ src/core/os_admin.c | 250 +++++++++++++ src/core/os_akill.c | 378 +++++++++++++++++++ src/core/os_chankill.c | 130 +++++++ src/core/os_chanlist.c | 116 ++++++ src/core/os_clearmodes.c | 356 ++++++++++++++++++ src/core/os_defcon.c | 167 +++++++++ src/core/os_global.c | 81 ++++ src/core/os_help.c | 66 ++++ src/core/os_ignore.c | 200 ++++++++++ src/core/os_jupe.c | 88 +++++ src/core/os_kick.c | 100 +++++ src/core/os_killclones.c | 129 +++++++ src/core/os_logonnews.c | 65 ++++ src/core/os_mode.c | 101 +++++ src/core/os_modinfo.c | 149 ++++++++ src/core/os_modlist.c | 182 +++++++++ src/core/os_modload.c | 96 +++++ src/core/os_modunload.c | 95 +++++ src/core/os_noop.c | 106 ++++++ src/core/os_oline.c | 111 ++++++ src/core/os_oper.c | 244 ++++++++++++ src/core/os_opernews.c | 65 ++++ src/core/os_quit.c | 82 +++++ src/core/os_randomnews.c | 65 ++++ src/core/os_raw.c | 77 ++++ src/core/os_reload.c | 84 +++++ src/core/os_restart.c | 89 +++++ src/core/os_session.c | 68 ++++ src/core/os_set.c | 262 +++++++++++++ src/core/os_sgline.c | 355 ++++++++++++++++++ src/core/os_shutdown.c | 83 +++++ src/core/os_sqline.c | 355 ++++++++++++++++++ src/core/os_staff.c | 158 ++++++++ src/core/os_stats.c | 400 ++++++++++++++++++++ src/core/os_svsnick.c | 126 +++++++ src/core/os_szline.c | 350 ++++++++++++++++++ src/core/os_umode.c | 116 ++++++ src/core/os_update.c | 74 ++++ src/core/os_userlist.c | 121 ++++++ 126 files changed, 21287 insertions(+) create mode 100644 src/core/Makefile create mode 100644 src/core/Makefile.sub create mode 100644 src/core/Makefile.win32 create mode 100644 src/core/bs_act.c create mode 100644 src/core/bs_assign.c create mode 100644 src/core/bs_badwords.c create mode 100644 src/core/bs_bot.c create mode 100644 src/core/bs_botlist.c create mode 100644 src/core/bs_fantasy.c create mode 100644 src/core/bs_fantasy_kick.c create mode 100644 src/core/bs_fantasy_kickban.c create mode 100644 src/core/bs_fantasy_owner.c create mode 100644 src/core/bs_fantasy_seen.c create mode 100644 src/core/bs_fantasy_unban.c create mode 100644 src/core/bs_help.c create mode 100644 src/core/bs_info.c create mode 100644 src/core/bs_kick.c create mode 100644 src/core/bs_say.c create mode 100644 src/core/bs_set.c create mode 100644 src/core/bs_unassign.c create mode 100755 src/core/configure create mode 100644 src/core/cs_access.c create mode 100644 src/core/cs_akick.c create mode 100644 src/core/cs_ban.c create mode 100644 src/core/cs_clear.c create mode 100644 src/core/cs_drop.c create mode 100644 src/core/cs_forbid.c create mode 100644 src/core/cs_getkey.c create mode 100644 src/core/cs_getpass.c create mode 100644 src/core/cs_help.c create mode 100644 src/core/cs_identify.c create mode 100644 src/core/cs_info.c create mode 100644 src/core/cs_invite.c create mode 100644 src/core/cs_kick.c create mode 100644 src/core/cs_list.c create mode 100644 src/core/cs_logout.c create mode 100644 src/core/cs_modes.c create mode 100644 src/core/cs_register.c create mode 100644 src/core/cs_sendpass.c create mode 100644 src/core/cs_set.c create mode 100644 src/core/cs_status.c create mode 100644 src/core/cs_suspend.c create mode 100644 src/core/cs_topic.c create mode 100644 src/core/cs_xop.c create mode 100644 src/core/he_help.c create mode 100644 src/core/hs_del.c create mode 100644 src/core/hs_delall.c create mode 100644 src/core/hs_group.c create mode 100644 src/core/hs_help.c create mode 100644 src/core/hs_list.c create mode 100644 src/core/hs_off.c create mode 100644 src/core/hs_on.c create mode 100644 src/core/hs_set.c create mode 100644 src/core/hs_setall.c create mode 100644 src/core/ms_cancel.c create mode 100644 src/core/ms_check.c create mode 100644 src/core/ms_del.c create mode 100644 src/core/ms_help.c create mode 100644 src/core/ms_info.c create mode 100644 src/core/ms_list.c create mode 100644 src/core/ms_read.c create mode 100644 src/core/ms_rsend.c create mode 100644 src/core/ms_send.c create mode 100644 src/core/ms_sendall.c create mode 100644 src/core/ms_set.c create mode 100644 src/core/ms_staff.c create mode 100644 src/core/ns_access.c create mode 100644 src/core/ns_alist.c create mode 100644 src/core/ns_drop.c create mode 100644 src/core/ns_forbid.c create mode 100644 src/core/ns_getemail.c create mode 100644 src/core/ns_getpass.c create mode 100644 src/core/ns_ghost.c create mode 100644 src/core/ns_group.c create mode 100644 src/core/ns_help.c create mode 100644 src/core/ns_identify.c create mode 100644 src/core/ns_info.c create mode 100644 src/core/ns_list.c create mode 100644 src/core/ns_logout.c create mode 100644 src/core/ns_recover.c create mode 100644 src/core/ns_register.c create mode 100644 src/core/ns_release.c create mode 100644 src/core/ns_sendpass.c create mode 100644 src/core/ns_set.c create mode 100644 src/core/ns_status.c create mode 100644 src/core/ns_suspend.c create mode 100644 src/core/ns_update.c create mode 100644 src/core/os_admin.c create mode 100644 src/core/os_akill.c create mode 100644 src/core/os_chankill.c create mode 100644 src/core/os_chanlist.c create mode 100644 src/core/os_clearmodes.c create mode 100644 src/core/os_defcon.c create mode 100644 src/core/os_global.c create mode 100644 src/core/os_help.c create mode 100644 src/core/os_ignore.c create mode 100644 src/core/os_jupe.c create mode 100644 src/core/os_kick.c create mode 100644 src/core/os_killclones.c create mode 100644 src/core/os_logonnews.c create mode 100644 src/core/os_mode.c create mode 100644 src/core/os_modinfo.c create mode 100644 src/core/os_modlist.c create mode 100644 src/core/os_modload.c create mode 100644 src/core/os_modunload.c create mode 100644 src/core/os_noop.c create mode 100644 src/core/os_oline.c create mode 100644 src/core/os_oper.c create mode 100644 src/core/os_opernews.c create mode 100644 src/core/os_quit.c create mode 100644 src/core/os_randomnews.c create mode 100644 src/core/os_raw.c create mode 100644 src/core/os_reload.c create mode 100644 src/core/os_restart.c create mode 100644 src/core/os_session.c create mode 100644 src/core/os_set.c create mode 100644 src/core/os_sgline.c create mode 100644 src/core/os_shutdown.c create mode 100644 src/core/os_sqline.c create mode 100644 src/core/os_staff.c create mode 100644 src/core/os_stats.c create mode 100644 src/core/os_svsnick.c create mode 100644 src/core/os_szline.c create mode 100644 src/core/os_umode.c create mode 100644 src/core/os_update.c create mode 100644 src/core/os_userlist.c (limited to 'src/core') diff --git a/src/core/Makefile b/src/core/Makefile new file mode 100644 index 000000000..e73fd7e7c --- /dev/null +++ b/src/core/Makefile @@ -0,0 +1,45 @@ +include ./Makefile.inc + +MAKEARGS = 'CFLAGS=${CFLAGS}' 'CC=${CC}' 'ANOPELIBS=${ANOPELIBS}' \ + 'LDFLAGS=${LDFLAGS}' 'BINDEST=${BINDEST}' 'INSTALL=${INSTALL}' \ + 'INCLUDEDIR=${INCLUDEDIR}' 'RM=${RM}' 'CP=${CP}' \ + 'TOUCH=${TOUCH}' 'SHELL=${SHELL}' 'DATDEST=${DATDEST}' \ + 'RUNGROUP=${RUNGROUP}' 'MODULE_PATH=${MODULE_PATH}' \ + 'PROFILE=${PROFILE}' 'SHARED=${SHARED}' + +OBJECTS= $(SRCS:.c=.o) +SO_FILES=$(OBJECTS:.o=.s) +CDEFS= -g -rdynamic -Wall +CFLAGS=$(CFLAGS) $(CDEFS) + +all: modules subs + +modules: $(OBJECTS) $(SO_FILES) + +install: + $(CP) ./*.so $(MODULE_PATH) + +distclean: clean spotless + +.c.o: + $(CC) $(CFLAGS) -I../${INCLUDEDIR} -c $< + +.o.s: + $(CC) ${SHARED} $< -o $*.so ${PROFILE} + +subs: + @for i in $(SUBS); do \ + echo "make all in $$i..."; \ + (cd $$i; $(MAKE) $(MAKEARGS) all); done + +subs_clean: + @for i in $(SUBS); do \ + echo "cleaning in $$i..."; \ + (cd $$i; $(MAKE) $(MAKEARGS) clean); done + +clean: subs_clean + rm -f *.o *.so *.c~ core + +spotless: clean + rm -f *.so Makefile.inc + diff --git a/src/core/Makefile.sub b/src/core/Makefile.sub new file mode 100644 index 000000000..b060ca5b6 --- /dev/null +++ b/src/core/Makefile.sub @@ -0,0 +1,30 @@ +MAKEARGS = 'CFLAGS=${CFLAGS}' 'CC=${CC}' 'ANOPELIBS=${ANOPELIBS}' \ + 'LDFLAGS=${LDFLAGS}' 'BINDEST=${BINDEST}' 'INSTALL=${INSTALL}' \ + 'INCLUDEDIR=${INCLUDEDIR}' 'RM=${RM}' 'CP=${CP}' \ + 'TOUCH=${TOUCH}' 'SHELL=${SHELL}' 'DATDEST=${DATDEST}' \ + 'RUNGROUP=${RUNGROUP}' 'MODULE_PATH=${MODULE_PATH}' \ + 'PROFILE=${PROFILE}' 'SHARED=${SHARED}' + +OBJECTS= $(SRCS:.c=.o) +SO_FILES=$(OBJECTS:.o=.s) +CDEFS= -g -rdynamic -Wall +CFLAGS=$(CFLAGS) $(CDEFS) + +all: module + +module: $(OBJECTS) so + +distclean: clean spotless + +.c.o: + $(CC) $(CFLAGS) -I../ -I../../${INCLUDEDIR} -c $< + +so: + $(CC) ${SHARED} $(OBJECTS) -o ../$(TARGET).so ${PROFILE} + +clean: + rm -f *.o *.so *.c~ core + +spotless: clean + rm -f *~ + diff --git a/src/core/Makefile.win32 b/src/core/Makefile.win32 new file mode 100644 index 000000000..e1f4301a3 --- /dev/null +++ b/src/core/Makefile.win32 @@ -0,0 +1,25 @@ +include ../../Makefile.inc.win32 + +SRCS=bs_act.c bs_assign.c bs_badwords.c bs_bot.c bs_botlist.c bs_fantasy.c bs_fantasy_kick.c bs_fantasy_kickban.c bs_fantasy_owner.c bs_fantasy_seen.c bs_fantasy_unban.c bs_help.c bs_info.c bs_kick.c bs_say.c bs_set.c bs_unassign.c cs_access.c cs_akick.c cs_ban.c cs_clear.c cs_drop.c cs_forbid.c cs_getkey.c cs_getpass.c cs_help.c cs_identify.c cs_info.c cs_invite.c cs_kick.c cs_list.c cs_logout.c cs_modes.c cs_register.c cs_sendpass.c cs_set.c cs_status.c cs_suspend.c cs_topic.c cs_xop.c he_help.c hs_del.c hs_delall.c hs_group.c hs_help.c hs_list.c hs_off.c hs_on.c hs_set.c hs_setall.c ms_cancel.c ms_check.c ms_del.c ms_help.c ms_info.c ms_list.c ms_read.c ms_rsend.c ms_send.c ms_sendall.c ms_set.c ms_staff.c ns_access.c ns_alist.c ns_drop.c ns_forbid.c ns_getemail.c ns_getpass.c ns_ghost.c ns_group.c ns_help.c ns_identify.c ns_info.c ns_list.c ns_logout.c ns_recover.c ns_register.c ns_release.c ns_sendpass.c ns_set.c ns_status.c ns_suspend.c ns_update.c os_admin.c os_akill.c os_chankill.c os_chanlist.c os_clearmodes.c os_defcon.c os_global.c os_help.c os_ignore.c os_jupe.c os_kick.c os_killclones.c \ + os_logonnews.c os_mode.c os_modinfo.c os_modlist.c os_modload.c os_modunload.c os_noop.c os_oline.c os_oper.c os_opernews.c os_quit.c os_randomnews.c os_raw.c os_reload.c os_restart.c os_session.c os_set.c os_sgline.c os_shutdown.c os_sqline.c os_staff.c os_stats.c os_svsnick.c os_szline.c os_umode.c os_update.c os_userlist.c +OBJECTS= $(SRCS:.c=.dll) +CFLAGS=/LD /MD /D MODULE_COMPILE $(CFLAGS) /I"../../include" +LFLAGS=/link ../anope.lib wsock32.lib $(LIBS) $(LFLAGS) $(MYSQL_LIB_PATH) /export:AnopeInit /export:AnopeFini + +all: $(OBJECTS) + +distclean: clean spotless + +.c.dll: + $(CC) $(CFLAGS) $< $(LFLAGS) + +clean: + -@del *.obj + +spotless: clean + -@del *.dll *.lib *.exp + +install: + -@mkdir ..\..\$(DATDEST)\modules + -@mkdir ..\..\$(DATDEST)\modules\runtime + -@copy *.dll ..\..\$(DATDEST)\modules diff --git a/src/core/bs_act.c b/src/core/bs_act.c new file mode 100644 index 000000000..0929ba716 --- /dev/null +++ b/src/core/bs_act.c @@ -0,0 +1,93 @@ +/* BotServ core functions + * + * (C) 2003-2005 Anope Team + * Contact us at info@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. + * + * $Id$ + * + */ +/*************************************************************************/ + +#include "module.h" + +int do_act(User * u); +void myBotServHelp(User * u); + +/** + * Create the command, and tell anope about it. + * @param argc Argument count + * @param argv Argument list + * @return MOD_CONT to allow the module, MOD_STOP to stop it + **/ +int AnopeInit(int argc, char **argv) +{ + Command *c; + + moduleAddAuthor("Anope"); + moduleAddVersion("$Id$"); + moduleSetType(CORE); + c = createCommand("ACT", do_act, NULL, BOT_HELP_ACT, -1, -1, -1, -1); + moduleAddCommand(BOTSERV, c, MOD_UNIQUE); + + moduleSetBotHelp(myBotServHelp); + + return MOD_CONT; +} + +/** + * Unload the module + **/ +void AnopeFini(void) +{ + +} + +/** + * Add the help response to Anopes /bs help output. + * @param u The user who is requesting help + **/ +void myBotServHelp(User * u) +{ + notice_lang(s_BotServ, u, BOT_HELP_CMD_ACT); +} + +/** + * The /bs act command. + * @param u The user who issued the command + * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing. + **/ +int do_act(User * u) +{ + ChannelInfo *ci; + + char *chan = strtok(NULL, " "); + char *text = strtok(NULL, ""); + + if (!chan || !text) + syntax_error(s_BotServ, u, "ACT", BOT_ACT_SYNTAX); + else if (!(ci = cs_findchan(chan))) + notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan); + else if (ci->flags & CI_VERBOTEN) + notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, chan); + else if (!ci->bi) + notice_help(s_BotServ, u, BOT_NOT_ASSIGNED); + else if (!ci->c || ci->c->usercount < BSMinUsers) + notice_lang(s_BotServ, u, BOT_NOT_ON_CHANNEL, ci->name); + else if (!check_access(u, ci, CA_SAY)) + notice_lang(s_BotServ, u, ACCESS_DENIED); + else { + strnrepl(text, BUFSIZE, "\001", ""); + anope_cmd_privmsg(ci->bi->nick, ci->name, "%cACTION %s %c", 1, + text, 1); + ci->bi->lastmsg = time(NULL); + if (logchan && LogBot) + anope_cmd_privmsg(ci->bi->nick, LogChannel, "ACT %s %s %s", + u->nick, ci->name, text); + } + return MOD_CONT; +} diff --git a/src/core/bs_assign.c b/src/core/bs_assign.c new file mode 100644 index 000000000..320a615fc --- /dev/null +++ b/src/core/bs_assign.c @@ -0,0 +1,102 @@ +/* BotServ core functions + * + * (C) 2003-2005 Anope Team + * Contact us at info@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. + * + * $Id$ + * + */ +/*************************************************************************/ + +#include "module.h" + +int do_assign(User * u); +void myBotServHelp(User * u); + +/** + * Create the command, and tell anope about it. + * @param argc Argument count + * @param argv Argument list + * @return MOD_CONT to allow the module, MOD_STOP to stop it + **/ +int AnopeInit(int argc, char **argv) +{ + Command *c; + + moduleAddAuthor("Anope"); + moduleAddVersion("$Id$"); + moduleSetType(CORE); + c = createCommand("ASSIGN", do_assign, NULL, BOT_HELP_ASSIGN, -1, -1, + -1, -1); + moduleAddCommand(BOTSERV, c, MOD_UNIQUE); + + moduleSetBotHelp(myBotServHelp); + + return MOD_CONT; +} + +/** + * Unload the module + **/ +void AnopeFini(void) +{ + +} + + +/** + * Add the help response to Anopes /bs help output. + * @param u The user who is requesting help + **/ +void myBotServHelp(User * u) +{ + notice_lang(s_BotServ, u, BOT_HELP_CMD_ASSIGN); +} + +/** + * The /bs assign command. + * @param u The user who issued the command + * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing. + **/ +int do_assign(User * u) +{ + char *chan = strtok(NULL, " "); + char *nick = strtok(NULL, " "); + BotInfo *bi; + ChannelInfo *ci; + + if (readonly) + notice_lang(s_BotServ, u, BOT_ASSIGN_READONLY); + else if (!chan || !nick) + syntax_error(s_BotServ, u, "ASSIGN", BOT_ASSIGN_SYNTAX); + else if (!(bi = findbot(nick))) + notice_lang(s_BotServ, u, BOT_DOES_NOT_EXIST, nick); + else if (bi->flags & BI_PRIVATE && !is_oper(u)) + notice_lang(s_BotServ, u, PERMISSION_DENIED); + else if (!(ci = cs_findchan(chan))) + notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan); + else if (ci->flags & CI_VERBOTEN) + notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, chan); + else if ((ci->bi) && (stricmp(ci->bi->nick, nick) == 0)) + notice_lang(s_BotServ, u, BOT_ASSIGN_ALREADY, ci->bi->nick, chan); + else if ((ci->botflags & BS_NOBOT) + || (!check_access(u, ci, CA_ASSIGN) && !is_services_admin(u))) + notice_lang(s_BotServ, u, PERMISSION_DENIED); + else { + if (ci->bi) + unassign(u, ci); + ci->bi = bi; + bi->chancount++; + if (ci->c && ci->c->usercount >= BSMinUsers) { + bot_join(ci); + } + notice_lang(s_BotServ, u, BOT_ASSIGN_ASSIGNED, bi->nick, ci->name); + send_event(EVENT_BOT_ASSIGN, 2, ci->name, bi->nick); + } + return MOD_CONT; +} diff --git a/src/core/bs_badwords.c b/src/core/bs_badwords.c new file mode 100644 index 000000000..de42f6355 --- /dev/null +++ b/src/core/bs_badwords.c @@ -0,0 +1,290 @@ +/* BotServ core functions + * + * (C) 2003-2005 Anope Team + * Contact us at info@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. + * + * $Id$ + * + */ +/*************************************************************************/ + +#include "module.h" + +int do_badwords(User * u); +void myBotServHelp(User * u); +int badwords_del_callback(User * u, int num, va_list args); +int badwords_list(User * u, int index, ChannelInfo * ci, int *sent_header); +int badwords_list_callback(User * u, int num, va_list args); + +/** + * Create the command, and tell anope about it. + * @param argc Argument count + * @param argv Argument list + * @return MOD_CONT to allow the module, MOD_STOP to stop it + **/ +int AnopeInit(int argc, char **argv) +{ + Command *c; + + moduleAddAuthor("Anope"); + moduleAddVersion("$Id$"); + moduleSetType(CORE); + + c = createCommand("BADWORDS", do_badwords, NULL, BOT_HELP_BADWORDS, -1, + -1, -1, -1); + moduleAddCommand(BOTSERV, c, MOD_UNIQUE); + + moduleSetBotHelp(myBotServHelp); + + return MOD_CONT; +} + +/** + * Unload the module + **/ +void AnopeFini(void) +{ + +} + + + +/** + * Add the help response to Anopes /bs help output. + * @param u The user who is requesting help + **/ +void myBotServHelp(User * u) +{ + notice_lang(s_BotServ, u, BOT_HELP_CMD_BADWORDS); +} + +/** + * The /bs badwords command. + * @param u The user who issued the command + * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing. + **/ +int do_badwords(User * u) +{ + char *chan = strtok(NULL, " "); + char *cmd = strtok(NULL, " "); + char *word = strtok(NULL, ""); + ChannelInfo *ci; + BadWord *bw; + + int i; + int need_args = (cmd + && (!stricmp(cmd, "LIST") || !stricmp(cmd, "CLEAR"))); + + if (!cmd || (need_args ? 0 : !word)) { + syntax_error(s_BotServ, u, "BADWORDS", BOT_BADWORDS_SYNTAX); + } else if (!(ci = cs_findchan(chan))) { + notice_lang(s_BotServ, u, CHAN_X_NOT_REGISTERED, chan); + } else if (ci->flags & CI_VERBOTEN) { + notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, chan); + } else if (!check_access(u, ci, CA_BADWORDS) + && (!need_args || !is_services_admin(u))) { + notice_lang(s_BotServ, u, ACCESS_DENIED); + } else if (stricmp(cmd, "ADD") == 0) { + + char *opt, *pos; + int type = BW_ANY; + + if (readonly) { + notice_lang(s_BotServ, u, BOT_BADWORDS_DISABLED); + return MOD_CONT; + } + + pos = strrchr(word, ' '); + if (pos) { + opt = pos + 1; + if (*opt) { + if (!stricmp(opt, "SINGLE")) + type = BW_SINGLE; + else if (!stricmp(opt, "START")) + type = BW_START; + else if (!stricmp(opt, "END")) + type = BW_END; + if (type != BW_ANY) + *pos = 0; + } + } + + for (bw = ci->badwords, i = 0; i < ci->bwcount; bw++, i++) { + if (bw->word && ((BSCaseSensitive && (!strcmp(bw->word, word))) + || (!BSCaseSensitive + && (!stricmp(bw->word, word))))) { + notice_lang(s_BotServ, u, BOT_BADWORDS_ALREADY_EXISTS, + bw->word, ci->name); + return MOD_CONT; + } + } + + for (i = 0; i < ci->bwcount; i++) { + if (!ci->badwords[i].in_use) + break; + } + if (i == ci->bwcount) { + if (i < BSBadWordsMax) { + ci->bwcount++; + ci->badwords = + srealloc(ci->badwords, sizeof(BadWord) * ci->bwcount); + } else { + notice_lang(s_BotServ, u, BOT_BADWORDS_REACHED_LIMIT, + BSBadWordsMax); + return MOD_CONT; + } + } + bw = &ci->badwords[i]; + bw->in_use = 1; + bw->word = sstrdup(word); + bw->type = type; + + notice_lang(s_BotServ, u, BOT_BADWORDS_ADDED, bw->word, ci->name); + + } else if (stricmp(cmd, "DEL") == 0) { + + if (readonly) { + notice_lang(s_BotServ, u, BOT_BADWORDS_DISABLED); + return MOD_CONT; + } + + /* Special case: is it a number/list? Only do search if it isn't. */ + if (isdigit(*word) && strspn(word, "1234567890,-") == strlen(word)) { + int count, deleted, last = -1; + deleted = + process_numlist(word, &count, badwords_del_callback, u, ci, + &last); + if (!deleted) { + if (count == 1) { + notice_lang(s_BotServ, u, BOT_BADWORDS_NO_SUCH_ENTRY, + last, ci->name); + } else { + notice_lang(s_BotServ, u, BOT_BADWORDS_NO_MATCH, + ci->name); + } + } else if (deleted == 1) { + notice_lang(s_BotServ, u, BOT_BADWORDS_DELETED_ONE, + ci->name); + } else { + notice_lang(s_BotServ, u, BOT_BADWORDS_DELETED_SEVERAL, + deleted, ci->name); + } + } else { + for (i = 0; i < ci->bwcount; i++) { + if (ci->badwords[i].in_use + && !stricmp(ci->badwords[i].word, word)) + break; + } + if (i == ci->bwcount) { + notice_lang(s_BotServ, u, BOT_BADWORDS_NOT_FOUND, word, + chan); + return MOD_CONT; + } + bw = &ci->badwords[i]; + notice_lang(s_BotServ, u, BOT_BADWORDS_DELETED, bw->word, + ci->name); + if (bw->word) + free(bw->word); + bw->word = NULL; + bw->in_use = 0; + } + + } else if (stricmp(cmd, "LIST") == 0) { + int sent_header = 0; + + if (ci->bwcount == 0) { + notice_lang(s_BotServ, u, BOT_BADWORDS_LIST_EMPTY, chan); + return MOD_CONT; + } + if (word && strspn(word, "1234567890,-") == strlen(word)) { + process_numlist(word, NULL, badwords_list_callback, u, ci, + &sent_header); + } else { + for (i = 0; i < ci->bwcount; i++) { + if (!(ci->badwords[i].in_use)) + continue; + if (word && ci->badwords[i].word + && !match_wild_nocase(word, ci->badwords[i].word)) + continue; + badwords_list(u, i, ci, &sent_header); + } + } + if (!sent_header) + notice_lang(s_BotServ, u, BOT_BADWORDS_NO_MATCH, chan); + + } else if (stricmp(cmd, "CLEAR") == 0) { + + if (readonly) { + notice_lang(s_BotServ, u, BOT_BADWORDS_DISABLED); + return MOD_CONT; + } + + for (i = 0; i < ci->bwcount; i++) + if (ci->badwords[i].word) + free(ci->badwords[i].word); + + free(ci->badwords); + ci->badwords = NULL; + ci->bwcount = 0; + + notice_lang(s_BotServ, u, BOT_BADWORDS_CLEAR); + + } else { + syntax_error(s_BotServ, u, "BADWORDS", BOT_BADWORDS_SYNTAX); + } + return MOD_CONT; +} + +int badwords_del_callback(User * u, int num, va_list args) +{ + BadWord *bw; + ChannelInfo *ci = va_arg(args, ChannelInfo *); + int *last = va_arg(args, int *); + if (num < 1 || num > ci->bwcount) + return 0; + *last = num; + + bw = &ci->badwords[num - 1]; + if (bw->word) + free(bw->word); + bw->word = NULL; + bw->in_use = 0; + + return 1; +} + +int badwords_list(User * u, int index, ChannelInfo * ci, int *sent_header) +{ + BadWord *bw = &ci->badwords[index]; + + if (!bw->in_use) + return 0; + if (!*sent_header) { + notice_lang(s_BotServ, u, BOT_BADWORDS_LIST_HEADER, ci->name); + *sent_header = 1; + } + + notice_lang(s_BotServ, u, BOT_BADWORDS_LIST_FORMAT, index + 1, + bw->word, + ((bw->type == + BW_SINGLE) ? "(SINGLE)" : ((bw->type == + BW_START) ? "(START)" + : ((bw->type == + BW_END) ? "(END)" : ""))) + ); + return 1; +} + +int badwords_list_callback(User * u, int num, va_list args) +{ + ChannelInfo *ci = va_arg(args, ChannelInfo *); + int *sent_header = va_arg(args, int *); + if (num < 1 || num > ci->bwcount) + return 0; + return badwords_list(u, num - 1, ci, sent_header); +} diff --git a/src/core/bs_bot.c b/src/core/bs_bot.c new file mode 100644 index 000000000..0e604a410 --- /dev/null +++ b/src/core/bs_bot.c @@ -0,0 +1,372 @@ +/* BotServ core functions + * + * (C) 2003-2005 Anope Team + * Contact us at info@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. + * + * $Id$ + * + */ +/*************************************************************************/ + +#include "module.h" + +/** + * RFC: defination of a valid nick + * nickname = ( letter / special ) *8( letter / digit / special / "-" ) + * letter = %x41-5A / %x61-7A ; A-Z / a-z + * digit = %x30-39 ; 0-9 + * special = %x5B-60 / %x7B-7D ; "[", "]", "\", "`", "_", "^", "{", "|", "}" + **/ +#define isvalidnick(c) ( isalnum(c) || ((c) >='\x5B' && (c) <='\x60') || ((c) >='\x7B' && (c) <='\x7D') || (c)=='-' ) + + +int do_bot(User * u); +int delbot(BotInfo * bi); +void myBotServHelp(User * u); +void change_bot_nick(BotInfo * bi, char *newnick); + +/** + * Create the command, and tell anope about it. + * @param argc Argument count + * @param argv Argument list + * @return MOD_CONT to allow the module, MOD_STOP to stop it + **/ +int AnopeInit(int argc, char **argv) +{ + Command *c; + + moduleAddAuthor("Anope"); + moduleAddVersion("$Id$"); + moduleSetType(CORE); + + c = createCommand("BOT", do_bot, is_services_admin, -1, -1, -1, + BOT_SERVADMIN_HELP_BOT, BOT_SERVADMIN_HELP_BOT); + moduleAddCommand(BOTSERV, c, MOD_UNIQUE); + + moduleSetBotHelp(myBotServHelp); + + return MOD_CONT; +} + +/** + * Unload the module + **/ +void AnopeFini(void) +{ + +} + + + +/** + * Add the help response to Anopes /bs help output. + * @param u The user who is requesting help + **/ +void myBotServHelp(User * u) +{ + if (is_services_admin(u)) { + notice_lang(s_BotServ, u, BOT_HELP_CMD_BOT); + } +} + +/** + * The /bs bot command. + * @param u The user who issued the command + * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing. + **/ +int do_bot(User * u) +{ + BotInfo *bi; + char *cmd = strtok(NULL, " "); + char *ch = NULL; + + if (!cmd) + syntax_error(s_BotServ, u, "BOT", BOT_BOT_SYNTAX); + else if (!stricmp(cmd, "ADD")) { + char *nick = strtok(NULL, " "); + char *user = strtok(NULL, " "); + char *host = strtok(NULL, " "); + char *real = strtok(NULL, ""); + + if (!nick || !user || !host || !real) + syntax_error(s_BotServ, u, "BOT", BOT_BOT_SYNTAX); + else if (readonly) + notice_lang(s_BotServ, u, BOT_BOT_READONLY); + else if (findbot(nick)) + notice_lang(s_BotServ, u, BOT_BOT_ALREADY_EXISTS, nick); + else { + NickAlias *na; + + /** + * Check the nick is valid re RFC 2812 + **/ + if (isdigit(nick[0]) || nick[0] == '-') { + notice_lang(s_BotServ, u, BOT_BAD_NICK); + return MOD_CONT; + } + for (ch = nick; *ch && (ch - nick) < NICKMAX; ch++) { + if (!isvalidnick(*ch)) { + notice_lang(s_BotServ, u, BOT_BAD_NICK); + return MOD_CONT; + } + } + + /* check for hardcored ircd forbidden nicks */ + if (!anope_valid_nick(nick)) { + notice_lang(s_BotServ, u, BOT_BAD_NICK); + return MOD_CONT; + } + + if (!isValidHost(host, 3)) { + notice_lang(s_BotServ, u, BOT_BAD_HOST); + return MOD_CONT; + } + for (ch = user; *ch && (ch - user) < USERMAX; ch++) { + if (!isalnum(*ch)) { + notice_lang(s_BotServ, u, BOT_BAD_IDENT); + return MOD_CONT; + } + } + + /** + * Check the host is valid re RFC 2812 + **/ + + /* Check whether it's a services client's nick and return if so - Certus */ + /* use nickIsServices reduce the total number lines of code - TSL */ + + if (nickIsServices(nick, 0)) { + notice_lang(s_BotServ, u, BOT_BOT_CREATION_FAILED); + return MOD_CONT; + } + + /* We check whether the nick is registered, and inform the user + * if so. You need to drop the nick manually before you can use + * it as a bot nick from now on -GD + */ + if ((na = findnick(nick))) { + notice_lang(s_BotServ, u, NICK_ALREADY_REGISTERED, nick); + return MOD_CONT; + } + + bi = makebot(nick); + if (!bi) { + notice_lang(s_BotServ, u, BOT_BOT_CREATION_FAILED); + return MOD_CONT; + } + + bi->user = sstrdup(user); + bi->host = sstrdup(host); + bi->real = sstrdup(real); + bi->created = time(NULL); + bi->chancount = 0; + + /* We check whether user with this nick is online, and kill it if so */ + EnforceQlinedNick(nick, s_BotServ); + + /* We make the bot online, ready to serve */ + anope_cmd_bot_nick(bi->nick, bi->user, bi->host, bi->real, + ircd->botserv_bot_mode); + + notice_lang(s_BotServ, u, BOT_BOT_ADDED, bi->nick, bi->user, + bi->host, bi->real); + + send_event(EVENT_BOT_CREATE, 1, bi->nick); + } + } else if (!stricmp(cmd, "CHANGE")) { + char *oldnick = strtok(NULL, " "); + char *nick = strtok(NULL, " "); + char *user = strtok(NULL, " "); + char *host = strtok(NULL, " "); + char *real = strtok(NULL, ""); + + if (!oldnick || !nick) + syntax_error(s_BotServ, u, "BOT", BOT_BOT_SYNTAX); + else if (readonly) + notice_lang(s_BotServ, u, BOT_BOT_READONLY); + else if (!(bi = findbot(oldnick))) + notice_lang(s_BotServ, u, BOT_DOES_NOT_EXIST, oldnick); + else { + NickAlias *na; + + /* Checks whether there *are* changes. + * Case sensitive because we may want to change just the case. + * And we must finally check that the nick is not already + * taken by another bot. + */ + if (!strcmp(bi->nick, nick) + && ((user) ? !strcmp(bi->user, user) : 1) + && ((host) ? !strcmp(bi->host, host) : 1) + && ((real) ? !strcmp(bi->real, real) : 1)) { + notice_lang(s_BotServ, u, BOT_BOT_ANY_CHANGES); + return MOD_CONT; + } + + /* Check whether it's a services client's nick and return if so - Certus */ + /* use nickIsServices() to reduce the number of lines of code - TSL */ + if (nickIsServices(nick, 0)) { + notice_lang(s_BotServ, u, BOT_BOT_CREATION_FAILED); + return MOD_CONT; + } + + /** + * Check the nick is valid re RFC 2812 + **/ + if (isdigit(nick[0]) || nick[0] == '-') { + notice_lang(s_BotServ, u, BOT_BAD_NICK); + return MOD_CONT; + } + for (ch = nick; *ch && (ch - nick) < NICKMAX; ch++) { + if (!isvalidnick(*ch)) { + notice_lang(s_BotServ, u, BOT_BAD_NICK); + return MOD_CONT; + } + } + + /* check for hardcored ircd forbidden nicks */ + if (!anope_valid_nick(nick)) { + notice_lang(s_BotServ, u, BOT_BAD_NICK); + return MOD_CONT; + } + + if (!isValidHost(host, 3)) { + notice_lang(s_BotServ, u, BOT_BAD_HOST); + return MOD_CONT; + } + + for (ch = user; *ch && (ch - user) < USERMAX; ch++) { + if (!isalnum(*ch)) { + notice_lang(s_BotServ, u, BOT_BAD_IDENT); + return MOD_CONT; + } + } + + if (stricmp(bi->nick, nick) && findbot(nick)) { + notice_lang(s_BotServ, u, BOT_BOT_ALREADY_EXISTS, nick); + return MOD_CONT; + } + + if (stricmp(bi->nick, nick)) { + /* We check whether the nick is registered, and inform the user + * if so. You need to drop the nick manually before you can use + * it as a bot nick from now on -GD + */ + if ((na = findnick(nick))) { + notice_lang(s_BotServ, u, NICK_ALREADY_REGISTERED, + nick); + return MOD_CONT; + } + + /* The new nick is really different, so we remove the Q line for + the old nick. */ + if (ircd->sqline) { + anope_cmd_unsqline(bi->nick); + } + + /* We check whether user with this nick is online, and kill it if so */ + EnforceQlinedNick(nick, s_BotServ); + } + + if (strcmp(nick, bi->nick)) + change_bot_nick(bi, nick); + + if (user && strcmp(user, bi->user)) { + free(bi->user); + bi->user = sstrdup(user); + } + if (host && strcmp(host, bi->host)) { + free(bi->host); + bi->host = sstrdup(host); + } + if (real && strcmp(real, bi->real)) { + free(bi->real); + bi->real = sstrdup(real); + } + + /* If only the nick changes, we just make the bot change his nick, + else we must make it quit and rejoin. */ + if (!user) + anope_cmd_chg_nick(oldnick, bi->nick); + else { + anope_cmd_quit(oldnick, "Quit: Be right back"); + + anope_cmd_bot_nick(bi->nick, bi->user, bi->host, bi->real, + ircd->botserv_bot_mode); + bot_rejoin_all(bi); + } + + notice_lang(s_BotServ, u, BOT_BOT_CHANGED, oldnick, bi->nick, + bi->user, bi->host, bi->real); + + send_event(EVENT_BOT_CHANGE, 1, bi->nick); + } + } else if (!stricmp(cmd, "DEL")) { + char *nick = strtok(NULL, " "); + + if (!nick) + syntax_error(s_BotServ, u, "BOT", BOT_BOT_SYNTAX); + else if (readonly) + notice_lang(s_BotServ, u, BOT_BOT_READONLY); + else if (!(bi = findbot(nick))) + notice_lang(s_BotServ, u, BOT_DOES_NOT_EXIST, nick); + else { + send_event(EVENT_BOT_DEL, 1, bi->nick); + anope_cmd_quit(bi->nick, + "Quit: Help! I'm being deleted by %s!", + u->nick); + if (ircd->sqline) { + anope_cmd_unsqline(bi->nick); + } + delbot(bi); + + notice_lang(s_BotServ, u, BOT_BOT_DELETED, nick); + } + } else + syntax_error(s_BotServ, u, "BOT", BOT_BOT_SYNTAX); + + return MOD_CONT; +} + +int delbot(BotInfo * bi) +{ + cs_remove_bot(bi); + + if (bi->next) + bi->next->prev = bi->prev; + if (bi->prev) + bi->prev->next = bi->next; + else + botlists[tolower(*bi->nick)] = bi->next; + + nbots--; + + free(bi->nick); + free(bi->user); + free(bi->host); + free(bi->real); + + free(bi); + + return 1; +} + +void change_bot_nick(BotInfo * bi, char *newnick) +{ + if (bi->next) + bi->next->prev = bi->prev; + if (bi->prev) + bi->prev->next = bi->next; + else + botlists[tolower(*bi->nick)] = bi->next; + + if (bi->nick) + free(bi->nick); + bi->nick = sstrdup(newnick); + + insert_bot(bi); +} diff --git a/src/core/bs_botlist.c b/src/core/bs_botlist.c new file mode 100644 index 000000000..cc510aec0 --- /dev/null +++ b/src/core/bs_botlist.c @@ -0,0 +1,108 @@ +/* BotServ core functions + * + * (C) 2003-2005 Anope Team + * Contact us at info@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. + * + * $Id$ + * + */ +/*************************************************************************/ + +#include "module.h" + +int do_botlist(User * u); +void myBotServHelp(User * u); + +/** + * Create the botlist command, and tell anope about it. + * @param argc Argument count + * @param argv Argument list + * @return MOD_CONT to allow the module, MOD_STOP to stop it + **/ +int AnopeInit(int argc, char **argv) +{ + Command *c; + + moduleAddAuthor("Anope"); + moduleAddVersion("$Id$"); + moduleSetType(CORE); + c = createCommand("BOTLIST", do_botlist, NULL, BOT_HELP_BOTLIST, -1, + -1, -1, -1); + moduleAddCommand(BOTSERV, c, MOD_UNIQUE); + + moduleSetBotHelp(myBotServHelp); + + return MOD_CONT; +} + +/** + * Unload the module + **/ +void AnopeFini(void) +{ + +} + + + +/** + * Add the help response to Anopes /bs help output. + * @param u The user who is requesting help + **/ +void myBotServHelp(User * u) +{ + notice_lang(s_BotServ, u, BOT_HELP_CMD_BOTLIST); +} + +/** + * The /bs botlist command. + * @param u The user who issued the command + * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing. + **/ +int do_botlist(User * u) +{ + int i, count = 0; + BotInfo *bi; + + if (!nbots) { + notice_lang(s_BotServ, u, BOT_BOTLIST_EMPTY); + return MOD_CONT; + } + + for (i = 0; i < 256; i++) { + for (bi = botlists[i]; bi; bi = bi->next) { + if (!(bi->flags & BI_PRIVATE)) { + if (!count) + notice_lang(s_BotServ, u, BOT_BOTLIST_HEADER); + count++; + notice_user(s_BotServ, u, " %-15s (%s@%s)", bi->nick, + bi->user, bi->host); + } + } + } + + if (is_oper(u) && count < nbots) { + notice_lang(s_BotServ, u, BOT_BOTLIST_PRIVATE_HEADER); + + for (i = 0; i < 256; i++) { + for (bi = botlists[i]; bi; bi = bi->next) { + if (bi->flags & BI_PRIVATE) { + notice_user(s_BotServ, u, " %-15s (%s@%s)", + bi->nick, bi->user, bi->host); + count++; + } + } + } + } + + if (!count) + notice_lang(s_BotServ, u, BOT_BOTLIST_EMPTY); + else + notice_lang(s_BotServ, u, BOT_BOTLIST_FOOTER, count); + return MOD_CONT; +} diff --git a/src/core/bs_fantasy.c b/src/core/bs_fantasy.c new file mode 100644 index 000000000..9ea3fe402 --- /dev/null +++ b/src/core/bs_fantasy.c @@ -0,0 +1,80 @@ +/* BotServ core fantasy functions + * + * (C) 2003-2005 Anope Team + * Contact us at info@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. + * + * $Id$ + * + */ +/*************************************************************************/ + +#include "module.h" + +int do_fantasy(int argc, char **argv); + +/** + * Create the hook, and tell anope about it. + * @param argc Argument count + * @param argv Argument list + * @return MOD_CONT to allow the module, MOD_STOP to stop it + **/ +int AnopeInit(int argc, char **argv) +{ + EvtHook *hook; + + moduleAddAuthor("Anope"); + moduleAddVersion("$Id$"); + moduleSetType(CORE); + hook = createEventHook(EVENT_BOT_FANTASY, do_fantasy); + moduleAddEventHook(hook); + + return MOD_CONT; +} + +/** + * Unload the module + **/ +void AnopeFini(void) +{ + +} + +/** + * Handle all csmodeutils fantasy commands. + * @param argc Argument count + * @param argv Argument list + * @return MOD_CONT or MOD_STOP + **/ +int do_fantasy(int argc, char **argv) +{ + User *u; + ChannelInfo *ci; + CSModeUtil *util = csmodeutils; + char *target; + + if (argc < 3) + return MOD_CONT; + + do { + if (stricmp(argv[0], util->bsname) == 0) { + u = finduser(argv[1]); + ci = cs_findchan(argv[2]); + if (!u || !ci) + return MOD_CONT; + + target = ((argc == 4) ? argv[3] : NULL); + + if (!target && check_access(u, ci, util->levelself)) + bot_raw_mode(u, ci, util->mode, u->nick); + else if (target && check_access(u, ci, util->level)) + bot_raw_mode(u, ci, util->mode, target); + } + } while ((++util)->name != NULL); + + return MOD_CONT; +} diff --git a/src/core/bs_fantasy_kick.c b/src/core/bs_fantasy_kick.c new file mode 100644 index 000000000..ec1e78ae6 --- /dev/null +++ b/src/core/bs_fantasy_kick.c @@ -0,0 +1,87 @@ +/* BotServ core fantasy functions + * + * (C) 2003-2005 Anope Team + * Contact us at info@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. + * + * $Id$ + * + */ +/*************************************************************************/ + +#include "module.h" + +int do_fantasy(int argc, char **argv); + +/** + * Create the hook, and tell anope about it. + * @param argc Argument count + * @param argv Argument list + * @return MOD_CONT to allow the module, MOD_STOP to stop it + **/ +int AnopeInit(int argc, char **argv) +{ + EvtHook *hook; + + moduleAddAuthor("Anope"); + moduleAddVersion("$Id$"); + moduleSetType(CORE); + + hook = createEventHook(EVENT_BOT_FANTASY, do_fantasy); + moduleAddEventHook(hook); + + return MOD_CONT; +} + +/** + * Unload the module + **/ +void AnopeFini(void) +{ + +} + +/** + * Handle kick/k fantasy commands. + * @param argc Argument count + * @param argv Argument list + * @return MOD_CONT or MOD_STOP + **/ +int do_fantasy(int argc, char **argv) +{ + User *u; + ChannelInfo *ci; + char *target = NULL; + char *reason = NULL; + + if (argc < 3) + return MOD_CONT; + + if ((stricmp(argv[0], "!kick") == 0) || (stricmp(argv[0], "!k") == 0)) { + u = finduser(argv[1]); + ci = cs_findchan(argv[2]); + if (!u || !ci) + return MOD_CONT; + + if (argc >= 4) { + target = myStrGetToken(argv[3], ' ', 0); + reason = myStrGetTokenRemainder(argv[3], ' ', 1); + } + if (!target && check_access(u, ci, CA_KICKME)) { + bot_raw_kick(u, ci, u->nick, "Requested"); + } else if (target && check_access(u, ci, CA_KICK)) { + if (!stricmp(target, ci->bi->nick)) + bot_raw_kick(u, ci, u->nick, "Oops!"); + else if (!reason) + bot_raw_kick(u, ci, target, "Requested"); + else + bot_raw_kick(u, ci, target, reason); + } + } + + return MOD_CONT; +} diff --git a/src/core/bs_fantasy_kickban.c b/src/core/bs_fantasy_kickban.c new file mode 100644 index 000000000..651b0113d --- /dev/null +++ b/src/core/bs_fantasy_kickban.c @@ -0,0 +1,90 @@ +/* BotServ core fantasy functions + * + * (C) 2003-2005 Anope Team + * Contact us at info@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. + * + * $Id$ + * + */ +/*************************************************************************/ + +#include "module.h" + +int do_fantasy(int argc, char **argv); + +/** + * Create the hook, and tell anope about it. + * @param argc Argument count + * @param argv Argument list + * @return MOD_CONT to allow the module, MOD_STOP to stop it + **/ +int AnopeInit(int argc, char **argv) +{ + EvtHook *hook; + + moduleAddAuthor("Anope"); + moduleAddVersion("$Id$"); + moduleSetType(CORE); + + hook = createEventHook(EVENT_BOT_FANTASY, do_fantasy); + moduleAddEventHook(hook); + + return MOD_CONT; +} + +/** + * Unload the module + **/ +void AnopeFini(void) +{ + +} + +/** + * Handle kickban/kb fantasy commands. + * @param argc Argument count + * @param argv Argument list + * @return MOD_CONT or MOD_STOP + **/ +int do_fantasy(int argc, char **argv) +{ + User *u; + ChannelInfo *ci; + char *target = NULL; + char *reason = NULL; + + if (argc < 3) + return MOD_CONT; + + if ((stricmp(argv[0], "!kickban") == 0) + || (stricmp(argv[0], "!kb") == 0)) { + u = finduser(argv[1]); + ci = cs_findchan(argv[2]); + if (!u || !ci) + return MOD_CONT; + + if (argc >= 4) { + target = myStrGetToken(argv[3], ' ', 0); + reason = myStrGetTokenRemainder(argv[3], ' ', 1); + } + if (!target && check_access(u, ci, CA_BANME)) { + bot_raw_ban(u, ci, u->nick, "Requested"); + } else if (target && check_access(u, ci, CA_BAN)) { + if (stricmp(target, ci->bi->nick) == 0) { + bot_raw_ban(u, ci, u->nick, "Oops!"); + } else { + if (!reason) + bot_raw_ban(u, ci, target, "Requested"); + else + bot_raw_ban(u, ci, target, reason); + } + } + } + + return MOD_CONT; +} diff --git a/src/core/bs_fantasy_owner.c b/src/core/bs_fantasy_owner.c new file mode 100644 index 000000000..ec88c966b --- /dev/null +++ b/src/core/bs_fantasy_owner.c @@ -0,0 +1,87 @@ +/* BotServ core fantasy functions + * + * (C) 2003-2005 Anope Team + * Contact us at info@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. + * + * $Id$ + * + */ +/*************************************************************************/ + +#include "module.h" + +int do_fantasy(int argc, char **argv); + +/** + * Create the hook, and tell anope about it. + * @param argc Argument count + * @param argv Argument list + * @return MOD_CONT to allow the module, MOD_STOP to stop it + **/ +int AnopeInit(int argc, char **argv) +{ + EvtHook *hook; + + moduleAddAuthor("Anope"); + moduleAddVersion("$Id$"); + moduleSetType(CORE); + + /* No need to load of we don't support owner */ + if (!ircd->owner) { + alog("Your ircd doesn't support the owner channelmode; bs_fantasy_owner won't be loaded"); + return MOD_STOP; + } + + hook = createEventHook(EVENT_BOT_FANTASY, do_fantasy); + moduleAddEventHook(hook); + + return MOD_CONT; +} + +/** + * Unload the module + **/ +void AnopeFini(void) +{ + +} + +/** + * Handle owner/deowner fantasy commands. + * @param argc Argument count + * @param argv Argument list + * @return MOD_CONT or MOD_STOP + **/ +int do_fantasy(int argc, char **argv) +{ + User *u; + ChannelInfo *ci; + + if (argc < 3) + return MOD_CONT; + + if (stricmp(argv[0], "!deowner") == 0) { + u = finduser(argv[1]); + ci = cs_findchan(argv[2]); + if (!u || !ci) + return MOD_CONT; + + if (is_founder(u, ci)) + bot_raw_mode(u, ci, ircd->ownerunset, u->nick); + } else if (stricmp(argv[0], "!owner") == 0) { + u = finduser(argv[1]); + ci = cs_findchan(argv[2]); + if (!u || !ci) + return MOD_CONT; + + if (is_founder(u, ci)) + bot_raw_mode(u, ci, ircd->ownerset, u->nick); + } + + return MOD_CONT; +} diff --git a/src/core/bs_fantasy_seen.c b/src/core/bs_fantasy_seen.c new file mode 100644 index 000000000..e218576d6 --- /dev/null +++ b/src/core/bs_fantasy_seen.c @@ -0,0 +1,136 @@ +/* BotServ core fantasy functions + * + * (C) 2003-2005 Anope Team + * Contact us at info@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. + * + * $Id$ + * + */ +/*************************************************************************/ + +#include "module.h" + +int do_fantasy(int argc, char **argv); + +/** + * Create the hook, and tell anope about it. + * @param argc Argument count + * @param argv Argument list + * @return MOD_CONT to allow the module, MOD_STOP to stop it + **/ +int AnopeInit(int argc, char **argv) +{ + EvtHook *hook; + + moduleAddAuthor("Anope"); + moduleAddVersion("$Id$"); + moduleSetType(CORE); + + hook = createEventHook(EVENT_BOT_FANTASY, do_fantasy); + moduleAddEventHook(hook); + + return MOD_CONT; +} + +/** + * Unload the module + **/ +void AnopeFini(void) +{ + +} + +/** + * Handle seen fantasy command. + * @param argc Argument count + * @param argv Argument list + * @return MOD_CONT or MOD_STOP + **/ +int do_fantasy(int argc, char **argv) +{ + User *u; + ChannelInfo *ci; + User *u2; + NickAlias *na; + ChanAccess *access; + char buf[BUFSIZE]; + char *target = NULL; + + if (argc < 4) + return MOD_CONT; + + if (stricmp(argv[0], "!seen") == 0) { + u = finduser(argv[1]); + ci = cs_findchan(argv[2]); + if (!u || !ci) + return MOD_CONT; + + target = myStrGetToken(argv[3], ' ', 0); + + if (stricmp(ci->bi->nick, target) == 0) { + /* If we look for the bot */ + snprintf(buf, sizeof(buf), getstring(u->na, BOT_SEEN_BOT), + u->nick); + anope_cmd_privmsg(ci->bi->nick, ci->name, "%s", buf); + } else if (!(na = findnick(target)) || (na->status & NS_VERBOTEN)) { + /* If the nick is not registered or forbidden */ + snprintf(buf, sizeof(buf), getstring(u->na, BOT_SEEN_UNKNOWN), + target); + anope_cmd_privmsg(ci->bi->nick, ci->name, "%s", buf); + } else if ((u2 = nc_on_chan(ci->c, na->nc))) { + /* If the nick we're looking for is on the channel, + * there are three possibilities: it's yourself, + * it's the nick we look for, it's an alias of the + * nick we look for. + */ + if (u == u2 || (u->na && u->na->nc == na->nc)) + snprintf(buf, sizeof(buf), getstring(u->na, BOT_SEEN_YOU), + u->nick); + else if (!stricmp(u2->nick, target)) + snprintf(buf, sizeof(buf), + getstring(u->na, BOT_SEEN_ON_CHANNEL), u2->nick); + else + snprintf(buf, sizeof(buf), + getstring(u->na, BOT_SEEN_ON_CHANNEL_AS), target, + u2->nick); + + anope_cmd_privmsg(ci->bi->nick, ci->name, "%s", buf); + } else if ((access = get_access_entry(na->nc, ci))) { + /* User is on the access list but not present actually. + Special case: if access->last_seen is 0 it's that we + never seen the user. + */ + if (access->last_seen) { + char durastr[192]; + duration(u->na, durastr, sizeof(durastr), + time(NULL) - access->last_seen); + snprintf(buf, sizeof(buf), getstring(u->na, BOT_SEEN_ON), + target, durastr); + } else { + snprintf(buf, sizeof(buf), + getstring(u->na, BOT_SEEN_NEVER), target); + } + anope_cmd_privmsg(ci->bi->nick, ci->name, "%s", buf); + } else if (na->nc == ci->founder) { + /* User is the founder of the channel */ + char durastr[192]; + duration(u->na, durastr, sizeof(durastr), + time(NULL) - na->last_seen); + snprintf(buf, sizeof(buf), getstring(u->na, BOT_SEEN_ON), + target, durastr); + anope_cmd_privmsg(ci->bi->nick, ci->name, "%s", buf); + } else { + /* All other cases */ + snprintf(buf, sizeof(buf), getstring(u->na, BOT_SEEN_UNKNOWN), + target); + anope_cmd_privmsg(ci->bi->nick, ci->name, "%s", buf); + } + } + + return MOD_CONT; +} diff --git a/src/core/bs_fantasy_unban.c b/src/core/bs_fantasy_unban.c new file mode 100644 index 000000000..412b36099 --- /dev/null +++ b/src/core/bs_fantasy_unban.c @@ -0,0 +1,78 @@ +/* BotServ core fantasy functions + * + * (C) 2003-2005 Anope Team + * Contact us at info@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. + * + * $Id$ + * + */ +/*************************************************************************/ + +#include "module.h" + +int do_fantasy(int argc, char **argv); + +/** + * Create the hook, and tell anope about it. + * @param argc Argument count + * @param argv Argument list + * @return MOD_CONT to allow the module, MOD_STOP to stop it + **/ +int AnopeInit(int argc, char **argv) +{ + EvtHook *hook; + + moduleAddAuthor("Anope"); + moduleAddVersion("$Id$"); + moduleSetType(CORE); + + hook = createEventHook(EVENT_BOT_FANTASY, do_fantasy); + moduleAddEventHook(hook); + + return MOD_CONT; +} + +/** + * Unload the module + **/ +void AnopeFini(void) +{ + +} + +/** + * Handle unban fantasy command. + * @param argc Argument count + * @param argv Argument list + * @return MOD_CONT or MOD_STOP + **/ +int do_fantasy(int argc, char **argv) +{ + User *u; + ChannelInfo *ci; + char *target = NULL; + + if (argc < 3) + return MOD_CONT; + + if (stricmp(argv[0], "!unban") == 0) { + u = finduser(argv[1]); + ci = cs_findchan(argv[2]); + if (!u || !ci || !check_access(u, ci, CA_UNBAN)) + return MOD_CONT; + + if (argc >= 4) + target = myStrGetToken(argv[3], ' ', 0); + if (!target) + common_unban(ci, u->nick); + else + common_unban(ci, target); + } + + return MOD_CONT; +} diff --git a/src/core/bs_help.c b/src/core/bs_help.c new file mode 100644 index 000000000..8fea7a5ad --- /dev/null +++ b/src/core/bs_help.c @@ -0,0 +1,67 @@ +/* BotServ core functions + * + * (C) 2003-2005 Anope Team + * Contact us at info@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. + * + * $Id$ + * + */ +/*************************************************************************/ + +#include "module.h" + +int do_help(User * u); + +/** + * Create the help command, and tell anope about it. + * @param argc Argument count + * @param argv Argument list + * @return MOD_CONT to allow the module, MOD_STOP to stop it + **/ +int AnopeInit(int argc, char **argv) +{ + Command *c; + + moduleAddAuthor("Anope"); + moduleAddVersion("$Id$"); + moduleSetType(CORE); + c = createCommand("HELP", do_help, NULL, -1, -1, -1, -1, -1); + moduleAddCommand(BOTSERV, c, MOD_UNIQUE); + + + return MOD_CONT; +} + +/** + * Unload the module + **/ +void AnopeFini(void) +{ + +} + + + +/** + * The /bs help command. + * @param u The user who issued the command + * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing. + **/ +int do_help(User * u) +{ + char *cmd = strtok(NULL, ""); + + if (!cmd) { + notice_help(s_BotServ, u, BOT_HELP); + moduleDisplayHelp(4, u); + notice_help(s_BotServ, u, BOT_HELP_FOOTER, BSMinUsers); + } else { + mod_help_cmd(s_BotServ, u, BOTSERV, cmd); + } + return MOD_CONT; +} diff --git a/src/core/bs_info.c b/src/core/bs_info.c new file mode 100644 index 000000000..3665b2054 --- /dev/null +++ b/src/core/bs_info.c @@ -0,0 +1,282 @@ +/* BotServ core functions + * + * (C) 2003-2005 Anope Team + * Contact us at info@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. + * + * $Id$ + * + */ +/*************************************************************************/ + +#include "module.h" + +int do_info(User * u); +void send_bot_channels(User * u, BotInfo * bi); +void myBotServHelp(User * u); + +/** + * Create the info command, and tell anope about it. + * @param argc Argument count + * @param argv Argument list + * @return MOD_CONT to allow the module, MOD_STOP to stop it + **/ +int AnopeInit(int argc, char **argv) +{ + Command *c; + + moduleAddAuthor("Anope"); + moduleAddVersion("$Id$"); + moduleSetType(CORE); + c = createCommand("INFO", do_info, NULL, BOT_HELP_INFO, -1, -1, -1, + -1); + moduleAddCommand(BOTSERV, c, MOD_UNIQUE); + + moduleSetBotHelp(myBotServHelp); + + return MOD_CONT; +} + +/** + * Unload the module + **/ +void AnopeFini(void) +{ + +} + + + +/** + * Add the help response to Anopes /bs help output. + * @param u The user who is requesting help + **/ +void myBotServHelp(User * u) +{ + notice_lang(s_BotServ, u, BOT_HELP_CMD_INFO); +} + +/** + * The /bs info command. + * @param u The user who issued the command + * @param MOD_CONT to continue processing other modules, MOD_STOP to stop processing. + **/ +int do_info(User * u) +{ + BotInfo *bi; + ChannelInfo *ci; + char *query = strtok(NULL, " "); + + int need_comma = 0, is_servadmin = is_services_admin(u); + char buf[BUFSIZE], *end; + const char *commastr = getstring(u->na, COMMA_SPACE); + + if (!query) + syntax_error(s_BotServ, u, "INFO", BOT_INFO_SYNTAX); + else if ((bi = findbot(query))) { + char buf[BUFSIZE]; + struct tm *tm; + + notice_lang(s_BotServ, u, BOT_INFO_BOT_HEADER, bi->nick); + notice_lang(s_BotServ, u, BOT_INFO_BOT_MASK, bi->user, bi->host); + notice_lang(s_BotServ, u, BOT_INFO_BOT_REALNAME, bi->real); + tm = localtime(&bi->created); + strf