#include "module.h" #define AUTHOR "ProjectDEAD" #define VERSION "1.10" /* ----------------------------------------------------------- * Name : bs_fan * Author: ProjectDEAD * Date : 05/26/04 * ----------------------------------------------------------- * Tested: Unreal(3.2) Only supported by my knowledge of Unreal3.2 * ----------------------------------------------------------- * I'd like to thank the whole anope coding team for helping me, * as well as a special thanks to Ribosome, and GeniusDex who always * have time to help me. As well as a thank you to Rob/Certus for helping * me from time to time. And a thank you to SGR, because i used some of his * code in this(he_operlist.c)! * * BTW: This is the nicest code, but it works.... * * * Things to work on: !mode is being worked on, and getting commands to * work with superadmin! * * Version 1.10: * Added define for UsersPriv which makes !users command private to ppl with * acess on that channel! * Fixed excemption nick9-10 bug... * Fixed !topic when no topicmsg is there it sets null, now it won't! * * Version 1.01: * It works!!! * * Clean up Code alot!!! It was 2 messy, + got rid of some useless things... * * Version 1.0: * It Works!!! * * I've added the following commands: * !users * Outputs user access list for that channel.... * * Things to do: * Clean up !up/!down, and include access denied.. * Plus adding many more features... * ----------------------------------------------------------- * *-------------------------Commands--------------------------- * * !admin || !ircops || !staff * Outputs admin list, code used from he_operlist.c by SGR! * ----------------------------------------------------------- * !invite user * invites a user to the current channel as long as that user is * not you, not already in that channel, and if that user is on the network! * ----------------------------------------------------------- * !topic topicmsg * Sets a topic to the channel your in * ----------------------------------------------------------- * !welcome welcomemsg * Sets an Entrymsg to that channel * ----------------------------------------------------------- * !up/!down * whatever access u have on the channel !up will give you * them modes * * * ----------------------------------------------------------- */ /*---------------------Configuration Block-------------------*/ //Set this if you want !users to only work for ppl in the user list //#define USERSPRIV //You Can Change whatever u like here... just be carful! #define OPER_ONLY "Oper" #define OPER_AND_SO "Oper + Services Oper" #define OPER_AND_SA "Oper + Services Administrator" #define OPER_AND_SRA "Oper + Services Root Administrator" #define OPER_LIST_HEADER1 "-----------------------------------------------------------------------" //#define OPER_LIST_HEADER2 " " //#define OPER_LIST_HEADER3 " " #define OPER_LIST_HEADER4 "The following global IRC Operators are online:" #define OPER_LIST_HEADER5 "-----------------------------------------------------------------------" // Oper List Appears Here. #define OPER_LIST_FOOTER1 "-----------------------------------------------------------------------" #define OPER_LIST_FOOTER2 " -> Please /whois an IRCop before trying to comminucate with them." #define OPER_LIST_FOOTER3 " -> Read (and respect) any away line information. " #define OPER_LIST_FOOTER4 " -> Do not join all channels an IRCop is in without valid cause. " #define OPER_LIST_FOOTER5 "-----------------------------------------------------------------------" #define NUM_OF_EXEMPTION_NICKS 8 #define EXEMPTIONNICK1 "raven" #define EXEMPTIONNICK2 "LoveServ" #define EXEMPTIONNICK3 "PornServ" #define EXEMPTIONNICK4 "MoraleServ" #define EXEMPTIONNICK5 "SecureServ" #define EXEMPTIONNICK6 "ConnectServ" #define EXEMPTIONNICK7 "NeoStats" #define EXEMPTIONNICK8 "StatServ" /*---------------End of Configuration Block-------------------*/ int list_global_opers(User * u); void populate_exemption_oper_list(void); char *exemption_oper_nicks[NUM_OF_EXEMPTION_NICKS]; int my_privmsg(char *source, int ac, char **av); int mynewmsg(User * u, ChannelInfo * ci); char *mod_current_buffer = NULL; char *text = NULL; static int do_set_entrymsg(User * u, ChannelInfo * ci, char *param); int AnopeInit(int argc, char **argv) { #if !defined(IRC_UNREAL) alog("[bs_fan] ERROR: IRCd not supported."); alog("[bs_fan] Initiating auto-shutdown."); return MOD_STOP; #endif // This is for the future!!! /* if ((access("modules/bs_fantasy.so", F_OK) == 0)) { alog("[bs_fan] please unload bs_fantasy.so!"); alog("[bs_fan] and delete it from services/modules dir!"); alog("[bs_fan] you cant use this module while you use mine, this module is obsolete"); return MOD_STOP; } else if ((access("modules/bs_modemoresperline.so", F_OK) == 0)) { alog("[bs_fan] please unload bs_moremodesperline.so!"); alog("[bs_fan] and delete it from services/modules dir!"); alog("[bs_fan] you cant use this module while you use mine, this module is obsolete"); return MOD_STOP; } else { */ Message * msg = NULL; int status; msg = createMessage("PRIVMSG", my_privmsg); status = moduleAddMessage(msg, MOD_HEAD); alog("Loading module bs_fan.so [Status: %d]", status); moduleAddAuthor(AUTHOR); moduleAddVersion(VERSION); populate_exemption_oper_list(); return MOD_CONT; /*}*/ } void AnopeFini(void) { alog("Unloading bs_fan.so"); } int list_global_opers(User * u) { int j = 0, i = 0, carryon = 0; User * next; User * u2; char *access; #ifdef OPER_LIST_HEADER1 notice(s_BotServ, u->nick, OPER_LIST_HEADER1); #endif #ifdef OPER_LIST_HEADER2 notice(s_BotServ, u->nick, OPER_LIST_HEADER2); #endif #ifdef OPER_LIST_HEADER3 notice(s_BotServ, u->nick, OPER_LIST_HEADER3); #endif #ifdef OPER_LIST_HEADER4 notice(s_BotServ, u->nick, OPER_LIST_HEADER4); #endif #ifdef OPER_LIST_HEADER5 notice(s_BotServ, u->nick, OPER_LIST_HEADER5); #endif for (j = 0; j < 1024; j++) { for (u2 = userlist[j]; u2; u2 = next) { next = u2->next; carryon = 0; if (finduser((u2->nick))) { #ifdef EXEMPTIONNICK1 i = 0; while (i != NUM_OF_EXEMPTION_NICKS) { i++; if (!exemption_oper_nicks[i] || !u2->nick) { break; } if (!stricmp(u2->nick, exemption_oper_nicks[i])) { carryon = 1; } } #endif if (carryon) { continue; } if (is_oper(u2)) { access = OPER_ONLY; if (is_services_oper(u2)) { access = OPER_AND_SO; } if (is_services_admin(u2)) { access = OPER_AND_SA; } if (is_services_root(u2)) { access = OPER_AND_SRA; } notice(s_BotServ, u->nick, "%-15s %s", u2->nick, access); } } } } #ifdef OPER_LIST_FOOTER1 notice(s_BotServ, u->nick, OPER_LIST_FOOTER1); #endif #ifdef OPER_LIST_FOOTER2 notice(s_BotServ, u->nick, OPER_LIST_FOOTER2); #endif #ifdef OPER_LIST_FOOTER3 notice(s_BotServ, u->nick, OPER_LIST_FOOTER3); #endif #ifdef OPER_LIST_FOOTER4 notice(s_BotServ, u->nick, OPER_LIST_FOOTER4); #endif #ifdef OPER_LIST_FOOTER5 notice(s_BotServ, u->nick, OPER_LIST_FOOTER5); #endif return MOD_CONT; } void populate_exemption_oper_list(void) { int i = 0; while (i != NUM_OF_EXEMPTION_NICKS) { i++; #ifdef EXEMPTIONNICK1 if (i == 1) { exemption_oper_nicks[i] = EXEMPTIONNICK1; continue; } #endif #ifdef EXEMPTIONNICK2 if (i == 2) { exemption_oper_nicks[i] = EXEMPTIONNICK2; continue; } #endif #ifdef EXEMPTIONNICK3 if (i == 3) { exemption_oper_nicks[i] = EXEMPTIONNICK3; continue; } #endif #ifdef EXEMPTIONNICK4 if (i == 4) { exemption_oper_nicks[i] = EXEMPTIONNICK4; continue; } #endif #ifdef EXEMPTIONNICK5 if (i == 5) { exemption_oper_nicks[i] = EXEMPTIONNICK5; continue; } #endif #ifdef EXEMPTIONNICK6 if (i == 6) { exemption_oper_nicks[i] = EXEMPTIONNICK6; continue; } #endif #ifdef EXEMPTIONNICK7 if (i == 7) { exemption_oper_nicks[i] = EXEMPTIONNICK7; continue; } #endif #ifdef EXEMPTIONNICK8 if (i == 8) { exemption_oper_nicks[i] = EXEMPTIONNICK8; continue; } #endif #ifdef EXEMPTIONNICK9 if (i == 9) { exemption_oper_nicks[i] = EXEMPTIONNICK9; continue; } #endif #ifdef EXEMPTIONNICK10 if (i == 10) { exemption_oper_nicks[i] = EXEMPTIONNICK10; continue; } #endif } } static int do_set_entrymsg(User * u, ChannelInfo * ci, char *wel) { if (ci->entry_message) free(ci->entry_message); if (wel) { ci->entry_message = sstrdup(wel); notice_lang(s_ChanServ, u, CHAN_ENTRY_MSG_CHANGED, ci->name, wel); } else { ci->entry_message = NULL; notice_lang(s_ChanServ, u, CHAN_ENTRY_MSG_UNSET, ci->name); } return MOD_CONT; } int my_privmsg(char *source, int ac, char **av) { User *u; ChannelInfo *ci; if (ac != 2) return MOD_CONT; if (!(u = finduser(source))) { return MOD_CONT; } if (*av[0] == '#') { if (s_BotServ && (ci = cs_findchan(av[0]))) if (!(ci->flags & CI_VERBOTEN) && ci->c && ci->bi) if (mod_current_buffer) { text = mod_current_buffer; if(text[0]=='!') mynewmsg(u, ci); } } return MOD_CONT; } int mynewmsg(User * u, ChannelInfo * ci) { char *cmd = NULL; char *text = NULL; char *param1 = NULL; char *param2 = NULL; char *param3 = NULL; char *param4 = NULL; char *param5 = NULL; char *params = NULL; char *newtopic = NULL; char *welcome = NULL; char dilim = ' '; if (mod_current_buffer) { text = mod_current_buffer; } cmd = myStrGetToken(text, dilim, 0); param1 = myStrGetToken(text, dilim, 1); param2 = myStrGetToken(text, dilim, 2); param3 = myStrGetToken(text, dilim, 3); param4 = myStrGetToken(text, dilim, 4); param5 = myStrGetToken(text, dilim, 5); params = moduleGetLastBuffer(); welcome = strtok(params, ""); newtopic = strtok(params, ""); if (!cmd) return MOD_CONT; /*********The Commands Start HERE!*********************/ #ifdef USERSPRIV if((ci->botflags & BS_FANTASY)&& check_access(u, ci, CA_FANTASIA)) { if (!stricmp(cmd, "!users")) { int i; notice(whosends(ci), u->nick, "The founder of %s is %s", ci->name, ci->founder->display); for (i = 0; i < ci->accesscount; i++) { ChanAccess * access = &ci->access[i]; if (i == 0) notice_lang(ci->bi->nick, u, CHAN_ACCESS_LIST_HEADER, ci->name); if (access->in_use) { if (ci->flags & CI_XOP) { notice_lang(ci->bi->nick, u, CHAN_ACCESS_LIST_XOP_FORMAT, i + 1, get_xop_level(access->level), access->nc->display); } else { notice_lang(ci->bi->nick, u, CHAN_ACCESS_LIST_AXS_FORMAT, i + 1, access->level, access->nc->display); } } } } } #else if (ci->botflags & BS_FANTASY) { if (!stricmp(cmd, "!users")) { int i; notice(whosends(ci), u->nick, "The founder of %s is %s", ci->name, ci->founder->display); for (i = 0; i < ci->accesscount; i++) { ChanAccess * access = &ci->access[i]; if (i == 0) notice_lang(ci->bi->nick, u, CHAN_ACCESS_LIST_HEADER, ci->name); if (access->in_use) { if (ci->flags & CI_XOP) { notice_lang(ci->bi->nick, u, CHAN_ACCESS_LIST_XOP_FORMAT, i + 1, get_xop_level(access->level), access->nc->display); } else { notice_lang(ci->bi->nick, u, CHAN_ACCESS_LIST_AXS_FORMAT, i + 1, access->level, access->nc->display); } } } } } #endif if (ci->botflags & BS_FANTASY) { if (!stricmp(cmd, "!admin") || (!stricmp(cmd, "!ircops") || (!stricmp(cmd, "!staff")))) { list_global_opers(u); } } if (ci->botflags & BS_FANTASY) { if (!stricmp(cmd, "!up")) { if ((is_founder(u, ci))) { send_cmd(whosends(ci), "MODE %s +qo %s %s", ci->name, u->nick, u->nick); } } if (!stricmp(cmd, "!down")) { if ((is_founder(u, ci))) { send_cmd(whosends(ci), "MODE %s -qo %s %s", ci->name, u->nick, u->nick); } } if ((!is_founder(u, ci))) { if (!stricmp(cmd, "!up") && check_access(u, ci, param1 ? CA_PROTECT : CA_PROTECTME)) { send_cmd(whosends(ci), "MODE %s +ao %s %s", ci->name, u->nick, u->nick); } else if (!stricmp(cmd, "!down") && check_access(u, ci, param1 ? CA_PROTECT : CA_PROTECTME)) { send_cmd(whosends(ci), "MODE %s -ao %s %s", ci->name, u->nick, u->nick); } else if (!stricmp(cmd, "!up") && check_access(u, ci, param1 ? CA_OPDEOP : CA_OPDEOPME)) { send_cmd(whosends(ci), "MODE %s +o %s", ci->name, u->nick); } else if (!stricmp(cmd, "!down") && check_access(u, ci, param1 ? CA_OPDEOP : CA_OPDEOPME)) { send_cmd(whosends(ci), "MODE %s -o %s", ci->name, u->nick); } else if (!stricmp(cmd, "!up") && check_access(u, ci, param1 ? CA_HALFOP : CA_HALFOPME)) { send_cmd(whosends(ci), "MODE %s +h %s", ci->name, u->nick); } else if (!stricmp(cmd, "!down") && check_access(u, ci, param1 ? CA_HALFOP : CA_HALFOPME)) { send_cmd(whosends(ci), "MODE %s -h %s", ci->name, u->nick); } else if (!stricmp(cmd, "!up") && check_access(u, ci, param1 ? CA_AUTOVOICE : CA_VOICEME)) { send_cmd(whosends(ci), "MODE %s +v %s", ci->name, u->nick); } else if (!stricmp(cmd, "!down") && check_access(u, ci,param1 ? CA_AUTOVOICE : CA_VOICEME)) { send_cmd(whosends(ci), "MODE %s -v %s", ci->name, u->nick); } } } if ((ci->botflags & BS_FANTASY)) { if (!stricmp(cmd, "!topic")) { if (!newtopic) { notice(s_BotServ, u->nick, "You have to include a topic for this to work SYNTAX: !topic topic"); } if (check_access(u, ci, CA_HALFOP) && (check_access(u, ci, CA_HALFOPME))) { send_cmd(ci->bi->nick, "TOPIC %s :%s", ci->name, newtopic); } else { notice(whosends(ci), u->nick, "%s does not have access to this command in %s", u->nick, ci->name); } } } if ((ci->botflags & BS_FANTASY)) { if (!stricmp(cmd, "!invite")) { if (!param1) { notice(whosends(ci), u->nick, "SYNTAX: !invite nick [YOU HAVE TO INCLUDE A NICK!]"); } if (check_access(u, ci, CA_OPDEOP) && (check_access(u, ci, CA_OPDEOPME))) { if (param1) { User * u2; Channel * c2; c2 = findchan(ci->name); if ((u2 = finduser(param1)) && !stricmp(u2->nick, u->nick)) { notice(whosends(ci), u->nick, "You can't invite yourself %s", u->nick); } else if ((u2 = finduser(param1)) && is_on_chan(c2, u2)) { notice(whosends(ci), u->nick, "%s is already in %s", param1, ci->name); } else if ((u2 = finduser(param1))) { send_cmd(ci->bi->nick, "INVITE %s %s", param1, ci->name); notice(whosends(ci), u->nick, "%s was invited to %s", param1, ci->name); } else { notice(whosends(ci), u->nick, "%s cannot be invited to %s %s is not on this network!", param1, ci->name, param1); } } } } } if ((ci->botflags & BS_FANTASY)) { if (!stricmp(cmd, "!welcome")) { if (!param1) { notice(whosends(ci), u->nick, "SYNTAX: !welcome text [you have to put text after !welcome smart guy!!!]"); } if (check_access(u, ci, CA_OPDEOP) && check_access(u, ci, CA_OPDEOPME)) { do_set_entrymsg(u, ci, welcome); } else { notice(whosends(ci), u->nick, "%s does not have access to this command in %s",u->nick, ci->name); } } } return MOD_CONT; }